pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: pg_rewind: Fix recovery delays at WAL page boundaries
6+ messages / 1 participants
[nested] [flat]

* pgsql: pg_rewind: Fix recovery delays at WAL page boundaries
@ 2026-11-20 11:44 Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Fujii Masao @ 2026-11-20 11:44 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

pg_rewind: Fix recovery delays at WAL page boundaries

After pg_rewind, a server restarted as a standby could remain unable
to accept read-only connections until the source generated more WAL,
even after replaying all available records.

The cause was pg_rewind's use of pg_current_wal_insert_lsn() to set
the target's minimum recovery point. At a WAL page boundary, this
function could return a position just past the next page's header.
Without another record to replay, recovery could not reach that
position.

Fix this by using the result of pg_current_wal_flush_lsn(), obtained
after copying the files, as the target's minimum recovery point
instead of pg_current_wal_insert_lsn(). The write-ahead rule ensures
that this position covers all WAL needed to make the copied data
consistent. In particular, after a WAL segment switch, it avoids
requiring recovery to advance past the next segment's header.

Backpatch to all supported versions.

Author: ChangAo Chen <cca5507@qq.com>
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Solai V <solai.cdac@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://www.postgresql.org/message-id/tencent_A37630454CE614AFE640C56E33B4A0F0AE05%40qq.com
Backpatch-through: 15

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4a26e36f87f6f30a93bfe1b95264b4b12d6b9ac3

Modified Files
--------------
doc/src/sgml/ref/pg_rewind.sgml   | 13 +++++++------
src/bin/pg_rewind/libpq_source.c  | 12 ++++++------
src/bin/pg_rewind/local_source.c  |  2 +-
src/bin/pg_rewind/pg_rewind.c     | 16 +++++++++++-----
src/bin/pg_rewind/rewind_source.h |  5 +++--
5 files changed, 28 insertions(+), 20 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: pg_rewind: Fix recovery delays at WAL page boundaries
@ 2026-11-20 11:44 Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Fujii Masao @ 2026-11-20 11:44 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

pg_rewind: Fix recovery delays at WAL page boundaries

After pg_rewind, a server restarted as a standby could remain unable
to accept read-only connections until the source generated more WAL,
even after replaying all available records.

The cause was pg_rewind's use of pg_current_wal_insert_lsn() to set
the target's minimum recovery point. At a WAL page boundary, this
function could return a position just past the next page's header.
Without another record to replay, recovery could not reach that
position.

Fix this by using the result of pg_current_wal_flush_lsn(), obtained
after copying the files, as the target's minimum recovery point
instead of pg_current_wal_insert_lsn(). The write-ahead rule ensures
that this position covers all WAL needed to make the copied data
consistent. In particular, after a WAL segment switch, it avoids
requiring recovery to advance past the next segment's header.

Backpatch to all supported versions.

Author: ChangAo Chen <cca5507@qq.com>
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Solai V <solai.cdac@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://www.postgresql.org/message-id/tencent_A37630454CE614AFE640C56E33B4A0F0AE05%40qq.com
Backpatch-through: 15

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/342ded94d360973d5aaa339b5cbb9d6312a3de70

Modified Files
--------------
doc/src/sgml/ref/pg_rewind.sgml   | 13 +++++++------
src/bin/pg_rewind/libpq_source.c  | 12 ++++++------
src/bin/pg_rewind/local_source.c  |  2 +-
src/bin/pg_rewind/pg_rewind.c     | 16 +++++++++++-----
src/bin/pg_rewind/rewind_source.h |  5 +++--
5 files changed, 28 insertions(+), 20 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: pg_rewind: Fix recovery delays at WAL page boundaries
@ 2026-11-20 11:44 Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Fujii Masao @ 2026-11-20 11:44 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

pg_rewind: Fix recovery delays at WAL page boundaries

After pg_rewind, a server restarted as a standby could remain unable
to accept read-only connections until the source generated more WAL,
even after replaying all available records.

The cause was pg_rewind's use of pg_current_wal_insert_lsn() to set
the target's minimum recovery point. At a WAL page boundary, this
function could return a position just past the next page's header.
Without another record to replay, recovery could not reach that
position.

Fix this by using the result of pg_current_wal_flush_lsn(), obtained
after copying the files, as the target's minimum recovery point
instead of pg_current_wal_insert_lsn(). The write-ahead rule ensures
that this position covers all WAL needed to make the copied data
consistent. In particular, after a WAL segment switch, it avoids
requiring recovery to advance past the next segment's header.

Backpatch to all supported versions.

Author: ChangAo Chen <cca5507@qq.com>
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Solai V <solai.cdac@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://www.postgresql.org/message-id/tencent_A37630454CE614AFE640C56E33B4A0F0AE05%40qq.com
Backpatch-through: 15

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/5627ce964d858e8ebf941a1aff846f68ade63972

Modified Files
--------------
doc/src/sgml/ref/pg_rewind.sgml   | 13 +++++++------
src/bin/pg_rewind/libpq_source.c  | 12 ++++++------
src/bin/pg_rewind/local_source.c  |  2 +-
src/bin/pg_rewind/pg_rewind.c     | 16 +++++++++++-----
src/bin/pg_rewind/rewind_source.h |  5 +++--
5 files changed, 28 insertions(+), 20 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: pg_rewind: Fix recovery delays at WAL page boundaries
@ 2026-11-20 11:44 Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Fujii Masao @ 2026-11-20 11:44 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

pg_rewind: Fix recovery delays at WAL page boundaries

After pg_rewind, a server restarted as a standby could remain unable
to accept read-only connections until the source generated more WAL,
even after replaying all available records.

The cause was pg_rewind's use of pg_current_wal_insert_lsn() to set
the target's minimum recovery point. At a WAL page boundary, this
function could return a position just past the next page's header.
Without another record to replay, recovery could not reach that
position.

Fix this by using the result of pg_current_wal_flush_lsn(), obtained
after copying the files, as the target's minimum recovery point
instead of pg_current_wal_insert_lsn(). The write-ahead rule ensures
that this position covers all WAL needed to make the copied data
consistent. In particular, after a WAL segment switch, it avoids
requiring recovery to advance past the next segment's header.

Backpatch to all supported versions.

Author: ChangAo Chen <cca5507@qq.com>
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Solai V <solai.cdac@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://www.postgresql.org/message-id/tencent_A37630454CE614AFE640C56E33B4A0F0AE05%40qq.com
Backpatch-through: 15

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0c1b2fae80dd659c08e72e82199266158751bbc4

Modified Files
--------------
doc/src/sgml/ref/pg_rewind.sgml   | 13 +++++++------
src/bin/pg_rewind/libpq_source.c  | 12 ++++++------
src/bin/pg_rewind/local_source.c  |  2 +-
src/bin/pg_rewind/pg_rewind.c     | 16 +++++++++++-----
src/bin/pg_rewind/rewind_source.h |  5 +++--
5 files changed, 28 insertions(+), 20 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: pg_rewind: Fix recovery delays at WAL page boundaries
@ 2026-11-20 11:44 Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Fujii Masao @ 2026-11-20 11:44 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

pg_rewind: Fix recovery delays at WAL page boundaries

After pg_rewind, a server restarted as a standby could remain unable
to accept read-only connections until the source generated more WAL,
even after replaying all available records.

The cause was pg_rewind's use of pg_current_wal_insert_lsn() to set
the target's minimum recovery point. At a WAL page boundary, this
function could return a position just past the next page's header.
Without another record to replay, recovery could not reach that
position.

Fix this by using the result of pg_current_wal_flush_lsn(), obtained
after copying the files, as the target's minimum recovery point
instead of pg_current_wal_insert_lsn(). The write-ahead rule ensures
that this position covers all WAL needed to make the copied data
consistent. In particular, after a WAL segment switch, it avoids
requiring recovery to advance past the next segment's header.

Backpatch to all supported versions.

Author: ChangAo Chen <cca5507@qq.com>
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Solai V <solai.cdac@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://www.postgresql.org/message-id/tencent_A37630454CE614AFE640C56E33B4A0F0AE05%40qq.com
Backpatch-through: 15

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/797e50e1aa2eafc669ffcfbcb6fd8ed7be422666

Modified Files
--------------
doc/src/sgml/ref/pg_rewind.sgml   | 13 +++++++------
src/bin/pg_rewind/libpq_source.c  | 12 ++++++------
src/bin/pg_rewind/local_source.c  |  2 +-
src/bin/pg_rewind/pg_rewind.c     | 16 +++++++++++-----
src/bin/pg_rewind/rewind_source.h |  5 +++--
5 files changed, 28 insertions(+), 20 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: pg_rewind: Fix recovery delays at WAL page boundaries
@ 2026-11-20 11:44 Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Fujii Masao @ 2026-11-20 11:44 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

pg_rewind: Fix recovery delays at WAL page boundaries

After pg_rewind, a server restarted as a standby could remain unable
to accept read-only connections until the source generated more WAL,
even after replaying all available records.

The cause was pg_rewind's use of pg_current_wal_insert_lsn() to set
the target's minimum recovery point. At a WAL page boundary, this
function could return a position just past the next page's header.
Without another record to replay, recovery could not reach that
position.

Fix this by using the result of pg_current_wal_flush_lsn(), obtained
after copying the files, as the target's minimum recovery point
instead of pg_current_wal_insert_lsn(). The write-ahead rule ensures
that this position covers all WAL needed to make the copied data
consistent. In particular, after a WAL segment switch, it avoids
requiring recovery to advance past the next segment's header.

Backpatch to all supported versions.

Author: ChangAo Chen <cca5507@qq.com>
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Solai V <solai.cdac@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://www.postgresql.org/message-id/tencent_A37630454CE614AFE640C56E33B4A0F0AE05%40qq.com
Backpatch-through: 15

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f1dc31245cb18e60236086207f2b8ff38d74f403

Modified Files
--------------
doc/src/sgml/ref/pg_rewind.sgml   | 13 +++++++------
src/bin/pg_rewind/libpq_source.c  | 12 ++++++------
src/bin/pg_rewind/local_source.c  |  2 +-
src/bin/pg_rewind/pg_rewind.c     | 16 +++++++++++-----
src/bin/pg_rewind/rewind_source.h |  5 +++--
5 files changed, 28 insertions(+), 20 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2026-11-20 11:44 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20 11:44 pgsql: pg_rewind: Fix recovery delays at WAL page boundaries Fujii Masao <fujii@postgresql.org>
2026-11-20 11:44 pgsql: pg_rewind: Fix recovery delays at WAL page boundaries Fujii Masao <fujii@postgresql.org>
2026-11-20 11:44 pgsql: pg_rewind: Fix recovery delays at WAL page boundaries Fujii Masao <fujii@postgresql.org>
2026-11-20 11:44 pgsql: pg_rewind: Fix recovery delays at WAL page boundaries Fujii Masao <fujii@postgresql.org>
2026-11-20 11:44 pgsql: pg_rewind: Fix recovery delays at WAL page boundaries Fujii Masao <fujii@postgresql.org>
2026-11-20 11:44 pgsql: pg_rewind: Fix recovery delays at WAL page boundaries Fujii Masao <fujii@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox