aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/help.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2023-07-18 13:44:27 +0900
committerMichael Paquier <michael@paquier.xyz>2023-07-18 13:44:27 +0900
commitf88bc9f3883970327598271d26afdb525112874b (patch)
tree36134f113636aa47df8036c14cf6fbfd7c6721f3 /src/bin/psql/help.c
parentefe8d8226929137f8c96f45e0904868b53ba56bc (diff)
downloadpostgresql-f88bc9f3883970327598271d26afdb525112874b.tar.gz
postgresql-f88bc9f3883970327598271d26afdb525112874b.zip
Fix recovery of 2PC transaction during crash recovery
A crash in the middle of a checkpoint with some two-phase state data already flushed to disk by this checkpoint could cause a follow-up crash recovery to recover twice the same transaction, once from what has been found in pg_twophase/ at the beginning of recovery and a second time when replaying its corresponding record. This would lead to FATAL failures in the startup process during recovery, where the same transaction would have a state recovered twice instead of once: LOG: recovering prepared transaction 731 from shared memory LOG: recovering prepared transaction 731 from shared memory FATAL: lock ExclusiveLock on object 731/0/0 is already held This issue is fixed by skipping the addition of any 2PC state coming from a record whose equivalent 2PC state file has already been loaded in TwoPhaseState at the beginning of recovery by restoreTwoPhaseData(), which is OK as long as the system has not reached a consistent state. The timing to get a messed up recovery processing is very racy, and would very unlikely happen. The thread that has reported the issue has demonstrated the bug using injection points to force a PANIC in the middle of a checkpoint. Issue introduced in 728bd99, so backpatch all the way down. Reported-by: "suyu.cmj" <mengjuan.cmj@alibaba-inc.com> Author: "suyu.cmj" <mengjuan.cmj@alibaba-inc.com> Author: Michael Paquier Discussion: https://postgr.es/m/109e6994-b971-48cb-84f6-829646f18b4c.mengjuan.cmj@alibaba-inc.com Backpatch-through: 11
Diffstat (limited to 'src/bin/psql/help.c')
0 files changed, 0 insertions, 0 deletions