Do not report txn commit/abort to the GTM via parallel worker.
authorPavan Deolasee <pavan.deolasee@gmail.com>
Thu, 21 Feb 2019 13:20:18 +0000 (18:50 +0530)
committerPavan Deolasee <pavan.deolasee@gmail.com>
Thu, 21 Feb 2019 13:34:39 +0000 (19:04 +0530)
We've seen a race condition where a parallel worker process on the coordinator
pre-maturely reports txn status to the GTM, resulting in cleanup of the txn
from the GTM. This is wrong and we must let the leader process do this.

This may not fully explain some of the recent reports we have seen with
catalog corruptions where an updated row is marked visible as its xmax is seen
as aborted. But this looks like a sane fix anyways. So push it while we
continue to investigate the reported problem.

src/backend/access/transam/xact.c

index 2de7ec0a98aa742633f37779a5c537668f5e4e22..157af416356c6df64988e5955d4b10363ebb6f23 100644 (file)
@@ -2749,7 +2749,7 @@ AtEOXact_GlobalTxn(bool commit)
 {
        TransactionState s = CurrentTransactionState;
 
-       if (IS_PGXC_LOCAL_COORDINATOR)
+       if (IS_PGXC_LOCAL_COORDINATOR && !IsParallelWorker())
        {
                if (commit)
                {
@@ -2783,7 +2783,7 @@ AtEOXact_GlobalTxn(bool commit)
         * So directly report transaction end. However this applies only if
         * the connection is directly from a client.
         */
-       else if (IsXidFromGTM)
+       else if (IsXidFromGTM && !IsParallelWorker())
        {
                IsXidFromGTM = false;
                if (commit)