A bug in recovery prefetcher, triggering asserts / FATAL: checkpoint request failed

From: Tomas Vondra <tomas(at)vondra(dot)me>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Subject: A bug in recovery prefetcher, triggering asserts / FATAL: checkpoint request failed
Date: 2026-10-25 23:37:31
Message-ID: a797f236-286a-43e6-9b82-5f3d70bd5e99@vondra.me
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

While hacking on an improvement for the recovery prefetcher, I ran into
a pre-existing bug present since PG 15. The brief explanation is that
XLogPrefetcherBeginRead resets a bunch of stuff, but not the pointer
prefetcher->record. In some circumstances (full I/O queue, ...) that
happens to confuse XLogPrefetcherReadRecord, triggering failures:

- assert failures on development builds

Assert(lrq_completed(prefetcher->streaming_read) == 0);

- a bunch of weird/uncommon errors on regular builds

LOG: request to flush past end of generated WAL; request 0/030BBD90,
current position 0/030B9D48
ERROR: xlog flush request 0/030BBD90 is not satisfied --- flushed
only to 0/030B9D48
FATAL: checkpoint request failed

AFAICS it can happen only with reduced maintenance_io_concurrency, but
I'm not sure about that. Maybe there's a way to generate WAL records
with enough block images.

The attached patch fixes this by simply resetting the record to NULL in
XLogPrefetcherBeginRead. It also introduces a new TAP test triggering
this, using a SP-GiST index built etc.

I'm not sure if we want to add the TAP test, I'm attaching it more as a
way to reproduce the issue. Without the fix in XLogPrefetcherBeginRead,
it crashes with errors similar to the attached logs.

regards

--
Tomas Vondra

Attachment Content-Type Size
0001-Forget-the-prefetcher-s-current-record-in-XLogPrefet.patch text/x-patch 8.5 KB
failure-2.log text/x-log 3.4 KB
failure-1.log text/x-log 3.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2026-10-25 23:54:48 Re: [PATCH v1] Fix tab completion for concurrent materialized view refresh
Previous Message shihao zhong 2026-10-25 23:32:29 Re: Avoid truncated or zero-padded copies of replaced files in backups.