pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Forget the prefetcher's current record in XLogPrefetcherBeginRea
9+ messages / 3 participants
[nested] [flat]
* pgsql: Forget the prefetcher's current record in XLogPrefetcherBeginRea
@ 2026-11-19 18:23 Tomas Vondra <tomas.vondra@postgresql.org>
0 siblings, 1 reply; 9+ messages in thread
From: Tomas Vondra @ 2026-11-19 18:23 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Forget the prefetcher's current record in XLogPrefetcherBeginRead()
XLogPrefetcherBeginRead() reset the decoder's record queue, but not
prefetcher->record, whose block references XLogPrefetcherNextBlock()
examines. The next read then continued with the remaining block
references of that stale record, before decoding the record at the new
read position.
FinishWalRecovery() re-reads the last replayed record to find the end
of WAL. When recovery stops at a recovery target, the prefetcher may
be part-way through a later record, and if its remaining block
references fill up the I/O queue, no record is decoded. This fails an
assertion in XLogPrefetcherReadRecord(). Without assertions, the start
of the last replayed record silently becomes the end of WAL, the new
timeline branches off at the wrong point, and the end-of-recovery
checkpoint fails with "xlog flush request ... is not satisfied". The
recovery signal file is gone by then, so a restart performs crash
recovery past the recovery target.
This mostly happens with maintenance_io_concurrency set to 7 or less,
and a recovery target shortly before an XLOG_FPI record written by an
index build, CLUSTER or similar operation, as such records carry up to
XLR_MAX_BLOCK_ID block references that need no I/O.
Fix by forgetting the current record in XLogPrefetcherBeginRead(). The
other callers run before the redo loop, when there is no current record.
Add a TAP test that stops recovery shortly before a multi-block XLOG_FPI
record of an SP-GiST index build, with maintenance_io_concurrency = 1.
The test uses SP-GiST rather than B-tree, so that it works unchanged in
the back branches. B-tree builds before 17 WAL-log each page in a
separate XLOG_FPI record with a single block reference, so the
prefetcher is never part-way through such a record.
Author: Tomas Vondra <tomas@vondra.me>
Reviewed-by: surya poondla <suryapoondla4@gmail.com>
Reviewed-by: shihao zhong <zhong950419@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/a797f236-286a-43e6-9b82-5f3d70bd5e99@vondra.me
Backpatch-through: 15
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/736ecc413b38555637802ccd8dfd35f034235796
Modified Files
--------------
src/backend/access/transam/xlogprefetcher.c | 3 +
src/test/recovery/meson.build | 1 +
.../recovery/t/061_recovery_target_prefetch.pl | 94 ++++++++++++++++++++++
3 files changed, 98 insertions(+)
^ permalink raw reply [nested|flat] 9+ messages in thread
* pgsql: Forget the prefetcher's current record in XLogPrefetcherBeginRea
@ 2026-11-19 18:23 Tomas Vondra <tomas.vondra@postgresql.org>
0 siblings, 0 replies; 9+ messages in thread
From: Tomas Vondra @ 2026-11-19 18:23 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Forget the prefetcher's current record in XLogPrefetcherBeginRead()
XLogPrefetcherBeginRead() reset the decoder's record queue, but not
prefetcher->record, whose block references XLogPrefetcherNextBlock()
examines. The next read then continued with the remaining block
references of that stale record, before decoding the record at the new
read position.
FinishWalRecovery() re-reads the last replayed record to find the end
of WAL. When recovery stops at a recovery target, the prefetcher may
be part-way through a later record, and if its remaining block
references fill up the I/O queue, no record is decoded. This fails an
assertion in XLogPrefetcherReadRecord(). Without assertions, the start
of the last replayed record silently becomes the end of WAL, the new
timeline branches off at the wrong point, and the end-of-recovery
checkpoint fails with "xlog flush request ... is not satisfied". The
recovery signal file is gone by then, so a restart performs crash
recovery past the recovery target.
This mostly happens with maintenance_io_concurrency set to 7 or less,
and a recovery target shortly before an XLOG_FPI record written by an
index build, CLUSTER or similar operation, as such records carry up to
XLR_MAX_BLOCK_ID block references that need no I/O.
Fix by forgetting the current record in XLogPrefetcherBeginRead(). The
other callers run before the redo loop, when there is no current record.
Add a TAP test that stops recovery shortly before a multi-block XLOG_FPI
record of an SP-GiST index build, with maintenance_io_concurrency = 1.
The test uses SP-GiST rather than B-tree, so that it works unchanged in
the back branches. B-tree builds before 17 WAL-log each page in a
separate XLOG_FPI record with a single block reference, so the
prefetcher is never part-way through such a record.
Author: Tomas Vondra <tomas@vondra.me>
Reviewed-by: surya poondla <suryapoondla4@gmail.com>
Reviewed-by: shihao zhong <zhong950419@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/a797f236-286a-43e6-9b82-5f3d70bd5e99@vondra.me
Backpatch-through: 15
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/61b11a31bf4466983156a44d2a299cffed3529e3
Modified Files
--------------
src/backend/access/transam/xlogprefetcher.c | 3 +
src/test/recovery/meson.build | 1 +
.../recovery/t/061_recovery_target_prefetch.pl | 94 ++++++++++++++++++++++
3 files changed, 98 insertions(+)
^ permalink raw reply [nested|flat] 9+ messages in thread
* pgsql: Forget the prefetcher's current record in XLogPrefetcherBeginRea
@ 2026-11-19 18:24 Tomas Vondra <tomas.vondra@postgresql.org>
0 siblings, 0 replies; 9+ messages in thread
From: Tomas Vondra @ 2026-11-19 18:24 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Forget the prefetcher's current record in XLogPrefetcherBeginRead()
XLogPrefetcherBeginRead() reset the decoder's record queue, but not
prefetcher->record, whose block references XLogPrefetcherNextBlock()
examines. The next read then continued with the remaining block
references of that stale record, before decoding the record at the new
read position.
FinishWalRecovery() re-reads the last replayed record to find the end
of WAL. When recovery stops at a recovery target, the prefetcher may
be part-way through a later record, and if its remaining block
references fill up the I/O queue, no record is decoded. This fails an
assertion in XLogPrefetcherReadRecord(). Without assertions, the start
of the last replayed record silently becomes the end of WAL, the new
timeline branches off at the wrong point, and the end-of-recovery
checkpoint fails with "xlog flush request ... is not satisfied". The
recovery signal file is gone by then, so a restart performs crash
recovery past the recovery target.
This mostly happens with maintenance_io_concurrency set to 7 or less,
and a recovery target shortly before an XLOG_FPI record written by an
index build, CLUSTER or similar operation, as such records carry up to
XLR_MAX_BLOCK_ID block references that need no I/O.
Fix by forgetting the current record in XLogPrefetcherBeginRead(). The
other callers run before the redo loop, when there is no current record.
Add a TAP test that stops recovery shortly before a multi-block XLOG_FPI
record of an SP-GiST index build, with maintenance_io_concurrency = 1.
The test uses SP-GiST rather than B-tree, so that it works unchanged in
the back branches. B-tree builds before 17 WAL-log each page in a
separate XLOG_FPI record with a single block reference, so the
prefetcher is never part-way through such a record.
Author: Tomas Vondra <tomas@vondra.me>
Reviewed-by: surya poondla <suryapoondla4@gmail.com>
Reviewed-by: shihao zhong <zhong950419@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/a797f236-286a-43e6-9b82-5f3d70bd5e99@vondra.me
Backpatch-through: 15
Branch
------
REL_18_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/36ff18f948418e059b5dee49a01928dd9d983004
Modified Files
--------------
src/backend/access/transam/xlogprefetcher.c | 3 +
src/test/recovery/meson.build | 1 +
.../recovery/t/061_recovery_target_prefetch.pl | 94 ++++++++++++++++++++++
3 files changed, 98 insertions(+)
^ permalink raw reply [nested|flat] 9+ messages in thread
* pgsql: Forget the prefetcher's current record in XLogPrefetcherBeginRea
@ 2026-11-19 18:24 Tomas Vondra <tomas.vondra@postgresql.org>
0 siblings, 0 replies; 9+ messages in thread
From: Tomas Vondra @ 2026-11-19 18:24 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Forget the prefetcher's current record in XLogPrefetcherBeginRead()
XLogPrefetcherBeginRead() reset the decoder's record queue, but not
prefetcher->record, whose block references XLogPrefetcherNextBlock()
examines. The next read then continued with the remaining block
references of that stale record, before decoding the record at the new
read position.
FinishWalRecovery() re-reads the last replayed record to find the end
of WAL. When recovery stops at a recovery target, the prefetcher may
be part-way through a later record, and if its remaining block
references fill up the I/O queue, no record is decoded. This fails an
assertion in XLogPrefetcherReadRecord(). Without assertions, the start
of the last replayed record silently becomes the end of WAL, the new
timeline branches off at the wrong point, and the end-of-recovery
checkpoint fails with "xlog flush request ... is not satisfied". The
recovery signal file is gone by then, so a restart performs crash
recovery past the recovery target.
This mostly happens with maintenance_io_concurrency set to 7 or less,
and a recovery target shortly before an XLOG_FPI record written by an
index build, CLUSTER or similar operation, as such records carry up to
XLR_MAX_BLOCK_ID block references that need no I/O.
Fix by forgetting the current record in XLogPrefetcherBeginRead(). The
other callers run before the redo loop, when there is no current record.
Add a TAP test that stops recovery shortly before a multi-block XLOG_FPI
record of an SP-GiST index build, with maintenance_io_concurrency = 1.
The test uses SP-GiST rather than B-tree, so that it works unchanged in
the back branches. B-tree builds before 17 WAL-log each page in a
separate XLOG_FPI record with a single block reference, so the
prefetcher is never part-way through such a record.
Author: Tomas Vondra <tomas@vondra.me>
Reviewed-by: surya poondla <suryapoondla4@gmail.com>
Reviewed-by: shihao zhong <zhong950419@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/a797f236-286a-43e6-9b82-5f3d70bd5e99@vondra.me
Backpatch-through: 15
Branch
------
REL_17_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/43522ad56b4afb2056a14e32de69043fc2e17c58
Modified Files
--------------
src/backend/access/transam/xlogprefetcher.c | 3 +
src/test/recovery/meson.build | 1 +
.../recovery/t/061_recovery_target_prefetch.pl | 94 ++++++++++++++++++++++
3 files changed, 98 insertions(+)
^ permalink raw reply [nested|flat] 9+ messages in thread
* pgsql: Forget the prefetcher's current record in XLogPrefetcherBeginRea
@ 2026-11-19 18:24 Tomas Vondra <tomas.vondra@postgresql.org>
0 siblings, 0 replies; 9+ messages in thread
From: Tomas Vondra @ 2026-11-19 18:24 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Forget the prefetcher's current record in XLogPrefetcherBeginRead()
XLogPrefetcherBeginRead() reset the decoder's record queue, but not
prefetcher->record, whose block references XLogPrefetcherNextBlock()
examines. The next read then continued with the remaining block
references of that stale record, before decoding the record at the new
read position.
FinishWalRecovery() re-reads the last replayed record to find the end
of WAL. When recovery stops at a recovery target, the prefetcher may
be part-way through a later record, and if its remaining block
references fill up the I/O queue, no record is decoded. This fails an
assertion in XLogPrefetcherReadRecord(). Without assertions, the start
of the last replayed record silently becomes the end of WAL, the new
timeline branches off at the wrong point, and the end-of-recovery
checkpoint fails with "xlog flush request ... is not satisfied". The
recovery signal file is gone by then, so a restart performs crash
recovery past the recovery target.
This mostly happens with maintenance_io_concurrency set to 7 or less,
and a recovery target shortly before an XLOG_FPI record written by an
index build, CLUSTER or similar operation, as such records carry up to
XLR_MAX_BLOCK_ID block references that need no I/O.
Fix by forgetting the current record in XLogPrefetcherBeginRead(). The
other callers run before the redo loop, when there is no current record.
Add a TAP test that stops recovery shortly before a multi-block XLOG_FPI
record of an SP-GiST index build, with maintenance_io_concurrency = 1.
The test uses SP-GiST rather than B-tree, so that it works unchanged in
the back branches. B-tree builds before 17 WAL-log each page in a
separate XLOG_FPI record with a single block reference, so the
prefetcher is never part-way through such a record.
Author: Tomas Vondra <tomas@vondra.me>
Reviewed-by: surya poondla <suryapoondla4@gmail.com>
Reviewed-by: shihao zhong <zhong950419@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/a797f236-286a-43e6-9b82-5f3d70bd5e99@vondra.me
Backpatch-through: 15
Branch
------
REL_16_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/9d92394052773ce52ea2ee39bf9678a8bffe119d
Modified Files
--------------
src/backend/access/transam/xlogprefetcher.c | 3 +
src/test/recovery/meson.build | 1 +
.../recovery/t/061_recovery_target_prefetch.pl | 94 ++++++++++++++++++++++
3 files changed, 98 insertions(+)
^ permalink raw reply [nested|flat] 9+ messages in thread
* pgsql: Forget the prefetcher's current record in XLogPrefetcherBeginRea
@ 2026-11-19 18:24 Tomas Vondra <tomas.vondra@postgresql.org>
0 siblings, 0 replies; 9+ messages in thread
From: Tomas Vondra @ 2026-11-19 18:24 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Forget the prefetcher's current record in XLogPrefetcherBeginRead()
XLogPrefetcherBeginRead() reset the decoder's record queue, but not
prefetcher->record, whose block references XLogPrefetcherNextBlock()
examines. The next read then continued with the remaining block
references of that stale record, before decoding the record at the new
read position.
FinishWalRecovery() re-reads the last replayed record to find the end
of WAL. When recovery stops at a recovery target, the prefetcher may
be part-way through a later record, and if its remaining block
references fill up the I/O queue, no record is decoded. This fails an
assertion in XLogPrefetcherReadRecord(). Without assertions, the start
of the last replayed record silently becomes the end of WAL, the new
timeline branches off at the wrong point, and the end-of-recovery
checkpoint fails with "xlog flush request ... is not satisfied". The
recovery signal file is gone by then, so a restart performs crash
recovery past the recovery target.
This mostly happens with maintenance_io_concurrency set to 7 or less,
and a recovery target shortly before an XLOG_FPI record written by an
index build, CLUSTER or similar operation, as such records carry up to
XLR_MAX_BLOCK_ID block references that need no I/O.
Fix by forgetting the current record in XLogPrefetcherBeginRead(). The
other callers run before the redo loop, when there is no current record.
Add a TAP test that stops recovery shortly before a multi-block XLOG_FPI
record of an SP-GiST index build, with maintenance_io_concurrency = 1.
The test uses SP-GiST rather than B-tree, so that it works unchanged in
the back branches. B-tree builds before 17 WAL-log each page in a
separate XLOG_FPI record with a single block reference, so the
prefetcher is never part-way through such a record.
Author: Tomas Vondra <tomas@vondra.me>
Reviewed-by: surya poondla <suryapoondla4@gmail.com>
Reviewed-by: shihao zhong <zhong950419@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/a797f236-286a-43e6-9b82-5f3d70bd5e99@vondra.me
Backpatch-through: 15
Branch
------
REL_15_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/2155036437603846ddb56997a8899ede263d8186
Modified Files
--------------
src/backend/access/transam/xlogprefetcher.c | 3 +
.../recovery/t/061_recovery_target_prefetch.pl | 94 ++++++++++++++++++++++
2 files changed, 97 insertions(+)
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: pgsql: Forget the prefetcher's current record in XLogPrefetcherBeginRea
@ 2026-11-20 05:44 Michael Paquier <michael@paquier.xyz>
parent: Tomas Vondra <tomas.vondra@postgresql.org>
0 siblings, 1 reply; 9+ messages in thread
From: Michael Paquier @ 2026-11-20 05:44 UTC (permalink / raw)
To: Tomas Vondra <tomas.vondra@postgresql.org>; +Cc: pgsql-committers@lists.postgresql.org
On Thu, Nov 19, 2026 at 06:23:46PM +0000, Tomas Vondra wrote:
> Forget the prefetcher's current record in XLogPrefetcherBeginRead()
>
> XLogPrefetcherBeginRead() reset the decoder's record queue, but not
> prefetcher->record, whose block references XLogPrefetcherNextBlock()
> examines. The next read then continued with the remaining block
> references of that stale record, before decoding the record at the new
> read position.
Since this commit, the buildfarm is unstable on various branches for
various hosts, for branches up to 17. Two examples:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=longfin&dt=2026-11-20%2005%3A13%3A08
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=indri&dt=2026-11-20%2005%3A00%3A27
And here is your failure, from the logs of the standby host in test
061:
2026-11-20 00:07:37.476 EST [33350:1] LOG: invalid value for
parameter "maintenance_io_concurrency": 1
2026-11-20 00:07:37.476 EST [33350:2] DETAIL:
"maintenance_io_concurrency" must be set to 0 on platforms that lack
posix_fadvise().
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: pgsql: Forget the prefetcher's current record in XLogPrefetcherBeginRea
@ 2026-11-20 11:17 Tomas Vondra <tomas@vondra.me>
parent: Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 9+ messages in thread
From: Tomas Vondra @ 2026-11-20 11:17 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; Tomas Vondra <tomas.vondra@postgresql.org>; +Cc: pgsql-committers@lists.postgresql.org
On 11/20/26 06:44, Michael Paquier wrote:
> On Thu, Nov 19, 2026 at 06:23:46PM +0000, Tomas Vondra wrote:
>> Forget the prefetcher's current record in XLogPrefetcherBeginRead()
>>
>> XLogPrefetcherBeginRead() reset the decoder's record queue, but not
>> prefetcher->record, whose block references XLogPrefetcherNextBlock()
>> examines. The next read then continued with the remaining block
>> references of that stale record, before decoding the record at the new
>> read position.
>
> Since this commit, the buildfarm is unstable on various branches for
> various hosts, for branches up to 17. Two examples:
> https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=longfin&dt=2026-11-20%2005%3A13%3A08
> https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=indri&dt=2026-11-20%2005%3A00%3A27
>
> And here is your failure, from the logs of the standby host in test
> 061:
> 2026-11-20 00:07:37.476 EST [33350:1] LOG: invalid value for
> parameter "maintenance_io_concurrency": 1
> 2026-11-20 00:07:37.476 EST [33350:2] DETAIL:
> "maintenance_io_concurrency" must be set to 0 on platforms that lack
> posix_fadvise().
> --
Yes, this was discussed in [1]. I just pushed a fix, so that the test is
skipped on platforms without posix_fadvise (on 15-17).
thanks
[1]
https://postgr.es/m/CAHGQGwHQkzvPCd9_RdsBM_Y7iNkzDQAMm8CBgzkVAxcSp60Xow@mail.gmail.com
--
Tomas Vondra
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: pgsql: Forget the prefetcher's current record in XLogPrefetcherBeginRea
@ 2026-11-20 22:19 Michael Paquier <michael@paquier.xyz>
parent: Tomas Vondra <tomas@vondra.me>
0 siblings, 0 replies; 9+ messages in thread
From: Michael Paquier @ 2026-11-20 22:19 UTC (permalink / raw)
To: Tomas Vondra <tomas@vondra.me>; +Cc: Tomas Vondra <tomas.vondra@postgresql.org>; pgsql-committers@lists.postgresql.org
On Fri, Nov 20, 2026 at 12:17:32PM +0100, Tomas Vondra wrote:
> Yes, this was discussed in [1]. I just pushed a fix, so that the test is
> skipped on platforms without posix_fadvise (on 15-17).
Thanks for the fix.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~2026-11-20 22:19 UTC | newest]
Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 18:23 pgsql: Forget the prefetcher's current record in XLogPrefetcherBeginRea Tomas Vondra <tomas.vondra@postgresql.org>
2026-11-20 05:44 ` Michael Paquier <michael@paquier.xyz>
2026-11-20 11:17 ` Tomas Vondra <tomas@vondra.me>
2026-11-20 22:19 ` Michael Paquier <michael@paquier.xyz>
2026-11-19 18:23 pgsql: Forget the prefetcher's current record in XLogPrefetcherBeginRea Tomas Vondra <tomas.vondra@postgresql.org>
2026-11-19 18:24 pgsql: Forget the prefetcher's current record in XLogPrefetcherBeginRea Tomas Vondra <tomas.vondra@postgresql.org>
2026-11-19 18:24 pgsql: Forget the prefetcher's current record in XLogPrefetcherBeginRea Tomas Vondra <tomas.vondra@postgresql.org>
2026-11-19 18:24 pgsql: Forget the prefetcher's current record in XLogPrefetcherBeginRea Tomas Vondra <tomas.vondra@postgresql.org>
2026-11-19 18:24 pgsql: Forget the prefetcher's current record in XLogPrefetcherBeginRea Tomas Vondra <tomas.vondra@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