forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitcb0cca1
committed
Fix recovery of 2PC transaction during crash recovery
A crash in the middle of a checkpoint with some two-phase state dataalready flushed to disk by this checkpoint could cause a follow-up crashrecovery to recover twice the same transaction, once from what has beenfound in pg_twophase/ at the beginning of recovery and a second timewhen replaying its corresponding record.This would lead to FATAL failures in the startup process duringrecovery, where the same transaction would have a state recovered twiceinstead of once:LOG: recovering prepared transaction 731 from shared memoryLOG: recovering prepared transaction 731 from shared memoryFATAL: lock ExclusiveLock on object 731/0/0 is already heldThis issue is fixed by skipping the addition of any 2PC state comingfrom a record whose equivalent 2PC state file has already been loaded inTwoPhaseState 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, andwould very unlikely happen. The thread that has reported the issue hasdemonstrated the bug using injection points to force a PANIC in themiddle of a checkpoint.Issue introduced in728bd99, 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 PaquierDiscussion:https://postgr.es/m/109e6994-b971-48cb-84f6-829646f18b4c.mengjuan.cmj@alibaba-inc.comBackpatch-through: 111 parent8fab4b3 commitcb0cca1
1 file changed
+33
-0
lines changedLines changed: 33 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
86 | 86 |
| |
87 | 87 |
| |
88 | 88 |
| |
| 89 | + | |
89 | 90 |
| |
90 | 91 |
| |
91 | 92 |
| |
| |||
2477 | 2478 |
| |
2478 | 2479 |
| |
2479 | 2480 |
| |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
| 2498 | + | |
| 2499 | + | |
| 2500 | + | |
| 2501 | + | |
| 2502 | + | |
| 2503 | + | |
| 2504 | + | |
| 2505 | + | |
| 2506 | + | |
| 2507 | + | |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
2480 | 2513 |
| |
2481 | 2514 |
| |
2482 | 2515 |
| |
|
0 commit comments
Comments
(0)