StandbyRecoverPreparedTransactions recovers subtrans links incorrectly
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@postgreSQL.org
Date: 2017-04-22T23:55:18Z
Lists: pgsql-hackers
Now that we've got consistent failure reports about the 009_twophase.pl
recovery test, I set out to find out why it's failing. It looks to me
like the reason is that this (twophase.c:2145):
SubTransSetParent(xid, subxid, overwriteOK);
ought to be this:
SubTransSetParent(subxid, xid, overwriteOK);
because the definition of SubTransSetParent is
void
SubTransSetParent(TransactionId xid, TransactionId parent, bool overwriteOK)
not the other way 'round.
While "git blame" blames this line on the recent commit 728bd991c,
that just moved the call from somewhere else. AFAICS this has actually
been wrong since StandbyRecoverPreparedTransactions was written,
in 361bd1662 of 2010-04-13.
It's not clear to me how much potential this has to create user data
corruption, but it doesn't look good at first glance. Discuss.
Also, when I fix that, it gets further but still crashes at the same
Assert in SubTransSetParent. The proximate cause this time seems to be
that RecoverPreparedTransactions's calculation of overwriteOK is wrong:
it's computing that as "false", but in reality the subtrans link in
question has already been set.
regards, tom lane
Commits
-
Rework handling of subtransactions in 2PC recovery
- 49e928154978 10.0 landed
-
Fix order of arguments to SubTransSetParent().
- f5885488dacb 9.6.3 landed
- 0874d4f3e183 10.0 landed
- 952e33b05275 9.2.21 landed
- a66e01bbcc88 9.5.7 landed
- 8565808733ec 9.3.17 landed
- 2e14541c4992 9.4.12 landed
-
Speedup 2PC recovery by skipping two phase state files in normal path
- 728bd991c3c4 10.0 cited