Fix order of arguments to SubTransSetParent().
authorTom Lane
Sun, 23 Apr 2017 17:10:57 +0000 (13:10 -0400)
committerTom Lane
Sun, 23 Apr 2017 17:10:57 +0000 (13:10 -0400)
ProcessTwoPhaseBuffer (formerly StandbyRecoverPreparedTransactions)
mixed up the parent and child XIDs when calling SubTransSetParent to
record the transactions' relationship in pg_subtrans.

Remarkably, analysis by Simon Riggs suggests that this doesn't lead to
visible problems (at least, not in non-Assert builds).  That might
explain why we'd not noticed it before.  Nonetheless, it's surely wrong.

This code was born broken, so back-patch to all supported branches.

Discussion: https://postgr.es/m/20110.1492905318@sss.pgh.pa.us

src/backend/access/transam/twophase.c

index 6f82e546cb3d4c7b8b1027516bb3bfa0f867e3b9..a2804c8f033514c8b939645ed8b708a7f873ffd4 100644 (file)
@@ -1934,7 +1934,7 @@ StandbyRecoverPreparedTransactions(bool overwriteOK)
                TransactionId subxid = subxids[i];
 
                Assert(TransactionIdFollows(subxid, xid));
-               SubTransSetParent(xid, subxid, overwriteOK);
+               SubTransSetParent(subxid, xid, overwriteOK);
            }
        }
    }