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

While for a successful run, I see:
2026-03-07 12:18:17.075 EET startup[285260] DETAIL:  The slot conflicted with 
xid horizon 677.
2026-03-07 12:18:17.075 EET startup[285260] CONTEXT:  WAL redo at 0/04022130 for Heap2/PRUNE_ON_ACCESS: snapshotConflictHorizon: 677, isCatalogRel: T, nplans: 0, nredirected: 0, ndead: 2, nunused: 0, dead: [35, 36]; blkref #0: rel 1663/16384/16418, blk 10
!!!SignalRecoveryConflict[285260]
!!!ProcessInterrupts[286071]| MyProc->pendingRecoveryConflicts: 16
!!!ProcessRecoveryConflictInterrupts[286071]
!!!ProcessRecoveryConflictInterrupts[286071] pending: 16, reason: 4
2026-03-07 12:18:17.075 EET walsender[286071] 035_standby_logical_decoding.pl ERROR:  canceling statement due to conflict with recovery 2026-03-07 12:18:17.075 EET walsender[286071] 035_standby_logical_decoding.pl DETAIL:  User was using a logical replication slot that must be invalidated.

(Full logs for this failed run and a good run are attached.)

Best regards,
Alexander
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 406b8253f8b..5e6b4ebbc2b 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -710,6 +710,7 @@ ProcArrayEndTransaction(PGPROC *proc, TransactionId latestXid)
 		/* be sure this is cleared in abort */
 		proc->delayChkptFlags = 0;
 
+fprintf(stderr, "!!!ProcArrayEndTransaction| pendingRecoveryConflicts = 0\n", getpid());
 		pg_atomic_write_u32(&proc->pendingRecoveryConflicts, 0);
 
 		/* must be cleared with xid/xmin: */
@@ -752,6 +753,8 @@ ProcArrayEndTransactionInternal(PGPROC *proc, TransactionId latestXid)
 	/* be sure this is cleared in abort */
 	proc->delayChkptFlags = 0;
 
+
+fprintf(stderr, "!!!ProcArrayEndTransactionInternal| pendingRecoveryConflicts = 0\n", getpid());
 	pg_atomic_write_u32(&proc->pendingRecoveryConflicts, 0);
 
 	/* must be cleared with xid/xmin: */
@@ -935,6 +938,7 @@ ProcArrayClearTransaction(PGPROC *proc)
 
 	proc->vxid.lxid = InvalidLocalTransactionId;
 	proc->xmin = InvalidTransactionId;
+fprintf(stderr, "!!!ProcArrayClearTransaction| pendingRecoveryConflicts = 0\n", getpid());
 	pg_atomic_write_u32(&proc->pendingRecoveryConflicts, 0);
 
 	Assert(!(proc->statusFlags & PROC_VACUUM_STATE_MASK));
@@ -3460,6 +3464,7 @@ SignalRecoveryConflict(PGPROC *proc, pid_t pid, RecoveryConflictReason reason)
 {
 	bool		found = false;
 
+fprintf(stderr, "!!!SignalRecoveryConflict[%d]\n", getpid());
 	LWLockAcquire(ProcArrayLock, LW_SHARED);
 
 	/*
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index d01a09dd0c4..ce499149789 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -3295,7 +3295,7 @@ ProcessRecoveryConflictInterrupts(void)
 	 */
 	Assert(!proc_exit_inprogress);
 	Assert(InterruptHoldoffCount == 0);
-
+fprintf(stderr, "!!!ProcessRecoveryConflictInterrupts[%d]\n", getpid());
 	/* Are any recovery conflict pending? */
 	pending = pg_atomic_read_membarrier_u32(&MyProc->pendingRecoveryConflicts);
 	if (pending == 0)
@@ -3313,6 +3313,7 @@ ProcessRecoveryConflictInterrupts(void)
 	{
 		if ((pending & (1 << reason)) != 0)
 		{
+fprintf(stderr, "!!!ProcessRecoveryConflictInterrupts[%d] pending: %d, reason: %d\n", getpid(), pending, reason);
 			/* clear the flag */
 			(void) pg_atomic_fetch_and_u32(&MyProc->pendingRecoveryConflicts, ~(1 << reason));
 
@@ -3506,7 +3507,9 @@ ProcessInterrupts(void)
 		}
 	}
 
-	if (pg_atomic_read_u32(&MyProc->pendingRecoveryConflicts) != 0)
+int prc = pg_atomic_read_u32(&MyProc->pendingRecoveryConflicts);
+fprintf(stderr, "!!!ProcessInterrupts[%d]| MyProc->pendingRecoveryConflicts: %d\n", getpid(), prc);
+	if (prc != 0)
 		ProcessRecoveryConflictInterrupts();
 
 	if (IdleInTransactionSessionTimeoutPending)

Attachment: 035_logs.tar.bz2
Description: BZip2 compressed data

Reply via email to