Re: Shutdown indefinitely stuck due to unflushed FPI_FOR_HINT record
Fujii Masao <masao.fujii@gmail.com>
From: Fujii Masao <masao.fujii@gmail.com>
To: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2026-02-26T16:19:46Z
Lists: pgsql-hackers
> Shutdown may be indefinitely stuck under the following circumstances: Thanks for reporting this issue and for the patch! I was able to reproduce the problem on master. On Tue, Feb 24, 2026 at 6:47 PM Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com> wrote: > So, it looks like the root issue is more that the async LSN isn't > updated when a transaction without xid is rollbacked. > When going through CommitTransaction, such a transaction would still > go through XLogSetAsyncXactLSN. > > I've updated the patch with this new approach: XLogSetAsyncXactLSN is > now called in RecordTransactionAbort even when a xid wasn't assigned. > With this, the logical walsender is able to force the flush of the > last partial page using XLogBackgroundFlush. I'm a bit concerned that this approach could cause walwriter to attempt WAL writes more aggressively in some cases, adding overhead during normal processing. If the goal is only to prevent shutdown from getting stuck, instead, would it be sufficient for ShutdownXLOG() to call XLogSetAsyncXactLSN() just before WalSndWaitStopping()? Regards, -- Fujii Masao
Commits
-
Fix WAL flush LSN used by logical walsender during shutdown
- f15471464650 14.23 landed
- fa9f2e317562 15.18 landed
- da21ecf5798c 16.14 landed
- 8ee536c89517 17.10 landed
- 9804981386a0 18.4 landed
- d927b4bd97c8 19 (unreleased) landed
-
Use GetXLogInsertEndRecPtr in gistGetFakeLSN
- b1f14c967202 19 (unreleased) cited
-
Fix publisher shutdown hang caused by logical walsender busy loop.
- 3bf6f22ce151 14.23 landed
- 42734f296615 15.18 landed
- 82935467a033 16.14 landed
- bbbc0888b356 17.10 landed
- 3eb2fecdbbfc 18.4 landed
- 6eedb2a5fd88 19 (unreleased) landed