Re: Shutdown indefinitely stuck due to unflushed FPI_FOR_HINT record
Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
From: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
To: Fujii Masao <masao.fujii@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2026-03-04T08:51:56Z
Lists: pgsql-hackers
Attachments
- v5-0001-Fix-stuck-shutdown-due-to-unflushed-records.patch (application/octet-stream) patch v5-0001
On Tue, Mar 3, 2026 at 6:29 PM Fujii Masao <masao.fujii@gmail.com> wrote: > The approach of calling XLogSetAsyncXactLSN() in RecordTransactionAbort() seems > more like an improvement than a bug fix. Since it changes > RecordTransactionAbort(), it could have unintended impact on the system. > > It may be a reasonable idea (though I'm not certain yet), but for a bug fix > I believe we should first apply the minimal change necessary to resolve > the issue. If needed, this approach could then be proposed later separately as > an improvement for the next major version. Agreed, that's definitely a change that can have a large impact. I will open a separate thread later. > As a simpler alternative, would it make sense for walsender to call > XLogFlush(GetXLogInsertRecPtr()) instead of XLogBackgroundFlush() during > shutdown? I'm not sure why walsender currently uses XLogBackgroundFlush(). > If there isn't a clear reason for that choice, directly calling XLogFlush() > might be the simpler solution. Thought? That sounds like a good solution. I've tried it and it fixes the issue. And this only changes the shutdown behaviour in the walsender. The use of XLogBackgroundFlush() has been introduced with c6c333436491, but there's no mention why it was specifically used. I guess the assumption was that a change would either be flushed with a commit, or tracked by async LSN through rollback, so XLogBackgroundFlush() would always write pending records. But this turns out to be false in the case of this bug. I've updated the patch with this approach. Regards, Anthonin Bonnefoy
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