Re: Refactor recovery conflict signaling a little
Heikki Linnakangas <hlinnaka@iki.fi>
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Alexander Lakhin <exclusion@gmail.com>
Cc: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>,
Chao Li <li.evan.chao@gmail.com>, Xuneng Zhou <xunengzhou@gmail.com>
Date: 2026-03-09T11:17:40Z
Lists: pgsql-hackers
Attachments
- 0001-Don-t-clear-pendingRecoveryConflicts-at-end-of-trans.patch (text/x-patch) patch 0001
On 07/03/2026 13:00, Alexander Lakhin wrote: > Hello Xuneng and Heikki, > > 04.03.2026 07:33, Xuneng Zhou wrote: >>> 03.03.2026 17:39, Heikki Linnakangas wrote: >>>> On 24/02/2026 10:00, Alexander Lakhin wrote: >>>>> The "terminating process ..." message doesn't appear when the test passes >>>>> successfully. >>>> Hmm, right, looks like something wrong in signaling the recovery conflict. I can't tell if the signal is being sent, >>>> or it's not processed correctly. Looking at the code, I don't see anything wrong. >>>> >> I was unable to reproduce the issue on an x86_64 Linux machine using >> the provided script. All test runs completed successfully without any >> failures. > > I've added debug logging (see attached) and saw the following: > !!!SignalRecoveryConflict[282363] > !!!ProcArrayEndTransaction| pendingRecoveryConflicts = 0 > !!!ProcessInterrupts[283863]| MyProc->pendingRecoveryConflicts: 0 > !!!ProcessInterrupts[283863]| MyProc->pendingRecoveryConflicts: 0 > 2026-03-07 12:21:24.544 EET walreceiver[282421] FATAL: could not > receive data from WAL stream: server closed the connection unexpectedly > This probably means the server terminated abnormally > before or while processing the request. > 2026-03-07 12:21:24.645 EET postmaster[282355] LOG: received immediate > shutdown request > 2026-03-07 12:21:24.647 EET postmaster[282355] LOG: database system is > shut down A-ha! So MyProc->pendingRecoveryConflicts is being cleared by ProcArrayEndTransaction(). If I add a small pg_usleep() to the top of ProcArrayEndTransaction(), I can readily reproduce this. Thanks for narrowing this down. The attached patch fixes it. - Heikki
Commits
-
Don't clear pendingRecoveryConflicts at end of transaction
- 138592d1b066 19 (unreleased) landed
-
Refactor ProcessRecoveryConflictInterrupt for readability
- be5257725d7f 19 (unreleased) landed
-
Separate RecoveryConflictReasons from procsignals
- 17f51ea81875 19 (unreleased) landed
-
Use ProcNumber rather than pid in ReplicationSlot
- ddc3250208bd 19 (unreleased) landed
-
Don't hint that you can reconnect when the database is dropped
- 57bff90160fd 19 (unreleased) landed
-
Remove useless errdetail_abort()
- cd375d5b6d5f 19 (unreleased) landed
-
Teach standby conflict resolution to use SIGUSR1
- a8ce974cddef 9.0.0 cited