Skip to content

Commit 2ce353f

Browse files
author
Amit Kapila
committed
Tighten the concurrent abort check during decoding.
During decoding of an in-progress or prepared transaction, we detect concurrent abort with an error code ERRCODE_TRANSACTION_ROLLBACK. That is not sufficient because a callback can decide to throw that error code at other times as well. Reported-by: Tom Lane Author: Amit Kapila Reviewed-by: Dilip Kumar Discussion: https://postgr.es/m/CAA4eK1KCjPRS4aZHB48QMM4J8XOC1+TD8jo-4Yu84E+MjwqVhA@mail.gmail.com
1 parent c250062 commit 2ce353f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/backend/replication/logical/reorderbuffer.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2492,17 +2492,18 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn,
24922492
* abort of the (sub)transaction we are streaming or preparing. We
24932493
* need to do the cleanup and return gracefully on this error, see
24942494
* SetupCheckXidLive.
2495+
*
2496+
* This error code can be thrown by one of the callbacks we call during
2497+
* decoding so we need to ensure that we return gracefully only when we are
2498+
* sending the data in streaming mode and the streaming is not finished yet
2499+
* or when we are sending the data out on a PREPARE during a two-phase
2500+
* commit.
24952501
*/
2496-
if (errdata->sqlerrcode == ERRCODE_TRANSACTION_ROLLBACK)
2502+
if (errdata->sqlerrcode == ERRCODE_TRANSACTION_ROLLBACK &&
2503+
(stream_started || rbtxn_prepared(txn)))
24972504
{
2498-
/*
2499-
* This error can occur either when we are sending the data in
2500-
* streaming mode and the streaming is not finished yet or when we
2501-
* are sending the data out on a PREPARE during a two-phase
2502-
* commit.
2503-
*/
2504-
Assert(streaming || rbtxn_prepared(txn));
2505-
Assert(stream_started || rbtxn_prepared(txn));
2505+
/* curtxn must be set for streaming or prepared transactions */
2506+
Assert(curtxn);
25062507

25072508
/* Cleanup the temporary error state. */
25082509
FlushErrorState();

0 commit comments

Comments
 (0)