forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd2ee542
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 parent7d27493 commitd2ee542
1 file changed
+33
-0
lines changedLines changed: 33 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2494 | 2494 |
| |
2495 | 2495 |
| |
2496 | 2496 |
| |
| 2497 | + | |
| 2498 | + | |
| 2499 | + | |
| 2500 | + | |
| 2501 | + | |
| 2502 | + | |
| 2503 | + | |
| 2504 | + | |
| 2505 | + | |
| 2506 | + | |
| 2507 | + | |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
| 2519 | + | |
| 2520 | + | |
| 2521 | + | |
| 2522 | + | |
| 2523 | + | |
| 2524 | + | |
| 2525 | + | |
| 2526 | + | |
| 2527 | + | |
| 2528 | + | |
| 2529 | + | |
2497 | 2530 |
| |
2498 | 2531 |
| |
2499 | 2532 |
| |
|
0 commit comments
Comments
(0)