From 6a25d20ab6c7a40622a3da75530e919aa47b8eef Mon Sep 17 00:00:00 2001 From: Narek Galstyan Date: Thu, 5 Nov 2026 18:32:36 -0500 Subject: [PATCH 2/2] Keep the characteristics of a failed transaction block for AND CHAIN COMMIT AND CHAIN and ROLLBACK AND CHAIN start the new transaction with the characteristics of the finished one, which CommitTransactionCommand() reads when the command arrives. AbortTransaction() reverts the isolation level, read-only and deferrable settings set by BEGIN or SET TRANSACTION, along with the other GUCs. A retry loop doing ROLLBACK AND CHAIN after a serialization failure thus silently retried in READ COMMITTED. The commit restores the characteristics right after AbortTransaction() when a transaction block fails, so they last until the block ends. A failed transaction that was itself started by AND CHAIN already keeps them, because they are not set through the GUC stack. Bug present since AND CHAIN was added in v12. --- src/backend/access/transam/xact.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 49e64939667..527670f2d5f 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -3547,6 +3547,7 @@ static bool AbortCurrentTransactionInternal(void) { TransactionState s = CurrentTransactionState; + SavedTransactionCharacteristics savetc; switch (s->blockState) { @@ -3603,7 +3604,10 @@ AbortCurrentTransactionInternal(void) */ case TBLOCK_INPROGRESS: case TBLOCK_PARALLEL_INPROGRESS: + /* Restore characteristics in case AND CHAIN is coming */ + SaveTransactionCharacteristics(&savetc); AbortTransaction(); + RestoreTransactionCharacteristics(&savetc); s->blockState = TBLOCK_ABORT; /* CleanupTransaction happens when we exit TBLOCK_ABORT_END */ break; -- 2.50.1 (Apple Git-155)