agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
pgsql: Fix race with timeline selection in logical decoding during prom
4+ messages / 1 participants
[nested] [flat]

* pgsql: Fix race with timeline selection in logical decoding during prom
@ 2026-06-11 08:30 Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 4+ messages in thread

From: Michael Paquier @ 2026-06-11 08:30 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix race with timeline selection in logical decoding during promotion

During promotion, there is a window where RecoveryInProgress() returns
true but the WAL segments of the old timeline have already been removed.
A logical decoding could pick up the old timeline in this window when
reading a page, failing with the following error:
ERROR: requested WAL segment ... has already been removed

This issue does not lead to any data correctness issue, as retrying to
decode the data works in follow-up decoding attempts.  It impacts
availability, though.  Other WAL page read callbacks have a similar
issue, this commit takes care of what should be the noisiest code path:
logical decoding with START_REPLICATION in a WAL sender.

A TAP test, based on an injection point waiting in the startup process
after the segments have been removed/recycled, is added.  This part is
backpatched down to v17.

This issue has been causing sporadic failures in the buildfarm, and
was reproducible manually.  This issue happens since logical decoding on
standbys exists, down to v16.

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://postgr.es/m/7daef094-abf3-4672-bc23-3df4763b16a3@gmail.com
Backpatch-through: 16

Branch
------
master

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

Modified Files
--------------
src/backend/access/transam/xlog.c                  |  2 +
src/backend/replication/walsender.c                | 24 +++++++-
.../recovery/t/035_standby_logical_decoding.pl     | 69 ++++++++++++++++++++++
3 files changed, 94 insertions(+), 1 deletion(-)



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

* pgsql: Fix race with timeline selection in logical decoding during prom
@ 2026-06-11 08:30 Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 4+ messages in thread

From: Michael Paquier @ 2026-06-11 08:30 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix race with timeline selection in logical decoding during promotion

During promotion, there is a window where RecoveryInProgress() returns
true but the WAL segments of the old timeline have already been removed.
A logical decoding could pick up the old timeline in this window when
reading a page, failing with the following error:
ERROR: requested WAL segment ... has already been removed

This issue does not lead to any data correctness issue, as retrying to
decode the data works in follow-up decoding attempts.  It impacts
availability, though.  Other WAL page read callbacks have a similar
issue, this commit takes care of what should be the noisiest code path:
logical decoding with START_REPLICATION in a WAL sender.

A TAP test, based on an injection point waiting in the startup process
after the segments have been removed/recycled, is added.  This part is
backpatched down to v17.

This issue has been causing sporadic failures in the buildfarm, and
was reproducible manually.  This issue happens since logical decoding on
standbys exists, down to v16.

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://postgr.es/m/7daef094-abf3-4672-bc23-3df4763b16a3@gmail.com
Backpatch-through: 16

Branch
------
REL_18_STABLE

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

Modified Files
--------------
src/backend/access/transam/xlog.c                  |  2 +
src/backend/replication/walsender.c                | 24 +++++++-
.../recovery/t/035_standby_logical_decoding.pl     | 69 ++++++++++++++++++++++
3 files changed, 94 insertions(+), 1 deletion(-)



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

* pgsql: Fix race with timeline selection in logical decoding during prom
@ 2026-06-11 08:30 Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 4+ messages in thread

From: Michael Paquier @ 2026-06-11 08:30 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix race with timeline selection in logical decoding during promotion

During promotion, there is a window where RecoveryInProgress() returns
true but the WAL segments of the old timeline have already been removed.
A logical decoding could pick up the old timeline in this window when
reading a page, failing with the following error:
ERROR: requested WAL segment ... has already been removed

This issue does not lead to any data correctness issue, as retrying to
decode the data works in follow-up decoding attempts.  It impacts
availability, though.  Other WAL page read callbacks have a similar
issue, this commit takes care of what should be the noisiest code path:
logical decoding with START_REPLICATION in a WAL sender.

A TAP test, based on an injection point waiting in the startup process
after the segments have been removed/recycled, is added.  This part is
backpatched down to v17.

This issue has been causing sporadic failures in the buildfarm, and
was reproducible manually.  This issue happens since logical decoding on
standbys exists, down to v16.

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://postgr.es/m/7daef094-abf3-4672-bc23-3df4763b16a3@gmail.com
Backpatch-through: 16

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/16b89ff048391c7f1bb4758de203c82c1a6dd7b8

Modified Files
--------------
src/backend/access/transam/xlog.c                  |  2 +
src/backend/replication/walsender.c                | 24 +++++++-
.../recovery/t/035_standby_logical_decoding.pl     | 69 ++++++++++++++++++++++
3 files changed, 94 insertions(+), 1 deletion(-)



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

* pgsql: Fix race with timeline selection in logical decoding during prom
@ 2026-06-11 08:30 Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 4+ messages in thread

From: Michael Paquier @ 2026-06-11 08:30 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix race with timeline selection in logical decoding during promotion

During promotion, there is a window where RecoveryInProgress() returns
true but the WAL segments of the old timeline have already been removed.
A logical decoding could pick up the old timeline in this window when
reading a page, failing with the following error:
ERROR: requested WAL segment ... has already been removed

This issue does not lead to any data correctness issue, as retrying to
decode the data works in follow-up decoding attempts.  It impacts
availability, though.  Other WAL page read callbacks have a similar
issue, this commit takes care of what should be the noisiest code path:
logical decoding with START_REPLICATION in a WAL sender.

A TAP test, based on an injection point waiting in the startup process
after the segments have been removed/recycled, is added.  This part is
backpatched down to v17.

This issue has been causing sporadic failures in the buildfarm, and
was reproducible manually.  This issue happens since logical decoding on
standbys exists, down to v16.

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://postgr.es/m/7daef094-abf3-4672-bc23-3df4763b16a3@gmail.com
Backpatch-through: 16

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/8cd687c44b62cda3cc6dec88d414e8e2837dc56b

Modified Files
--------------
src/backend/replication/walsender.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)



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


end of thread, other threads:[~2026-06-11 08:30 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-06-11 08:30 pgsql: Fix race with timeline selection in logical decoding during prom Michael Paquier <michael@paquier.xyz>
2026-06-11 08:30 pgsql: Fix race with timeline selection in logical decoding during prom Michael Paquier <michael@paquier.xyz>
2026-06-11 08:30 pgsql: Fix race with timeline selection in logical decoding during prom Michael Paquier <michael@paquier.xyz>
2026-06-11 08:30 pgsql: Fix race with timeline selection in logical decoding during prom Michael Paquier <michael@paquier.xyz>

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