forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitdb59108
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 parentbdaaf1b commitdb59108
1 file changed
+33
-0
lines changedLines changed: 33 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2443 | 2443 |
| |
2444 | 2444 |
| |
2445 | 2445 |
| |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
| 2459 | + | |
| 2460 | + | |
| 2461 | + | |
| 2462 | + | |
| 2463 | + | |
| 2464 | + | |
| 2465 | + | |
| 2466 | + | |
| 2467 | + | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
2446 | 2479 |
| |
2447 | 2480 |
| |
2448 | 2481 |
| |
|
0 commit comments
Comments
(0)