Commit 2ce353fc authored by Amit Kapila's avatar Amit Kapila

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
parent c250062d
...@@ -2492,17 +2492,18 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn, ...@@ -2492,17 +2492,18 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn,
* abort of the (sub)transaction we are streaming or preparing. We * abort of the (sub)transaction we are streaming or preparing. We
* need to do the cleanup and return gracefully on this error, see * need to do the cleanup and return gracefully on this error, see
* SetupCheckXidLive. * SetupCheckXidLive.
*/ *
if (errdata->sqlerrcode == ERRCODE_TRANSACTION_ROLLBACK) * This error code can be thrown by one of the callbacks we call during
{ * decoding so we need to ensure that we return gracefully only when we are
/* * sending the data in streaming mode and the streaming is not finished yet
* This error can occur either when we are sending the data in * or when we are sending the data out on a PREPARE during a two-phase
* streaming mode and the streaming is not finished yet or when we
* are sending the data out on a PREPARE during a two-phase
* commit. * commit.
*/ */
Assert(streaming || rbtxn_prepared(txn)); if (errdata->sqlerrcode == ERRCODE_TRANSACTION_ROLLBACK &&
Assert(stream_started || rbtxn_prepared(txn)); (stream_started || rbtxn_prepared(txn)))
{
/* curtxn must be set for streaming or prepared transactions */
Assert(curtxn);
/* Cleanup the temporary error state. */ /* Cleanup the temporary error state. */
FlushErrorState(); FlushErrorState();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment