forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit595b9cb
committed
Fix timeline assignment in checkpoints with 2PC transactions
Any transactions found as still prepared by a checkpoint have theirstate data read from the WAL records generated by PREPARE TRANSACTIONbefore being moved into their new location within pg_twophase/. Whilereading such records, the WAL reader uses the callbackread_local_xlog_page() to read a page, that is shared across variousparts of the system. This callback, since1148e22, has introduced anupdate of ThisTimeLineID when reading a record while in recovery, whichis potentially helpful in the context of cascading WAL senders.This update of ThisTimeLineID interacts badly with the checkpointer if apromotion happens while some 2PC data is read from its record, as, bychanging ThisTimeLineID, any follow-up WAL records would be written toan timeline older than the promoted one. This results in consistencyissues. For instance, a subsequent server restart would cause a failurein finding a valid checkpoint record, resulting in a PANIC, forinstance.This commit changes the code reading the 2PC data to reset the timelineonce the 2PC record has been read, to prevent messing up with the staticstate of the checkpointer. It would be tempting to do the same thingdirectly in read_local_xlog_page(). However, based on the discussionthat has led to1148e22, users may rely on the updates ofThisTimeLineID when a WAL record page is read in recovery, so changingthis callback could break some cases that are working currently.A TAP test reproducing the issue is added, relying on a PITR toprecisely trigger a promotion with a prepared transaction stilltracked.Per discussion with Heikki Linnakangas, Kyotaro Horiguchi, Fujii Masaoand myself.Author: Soumyadeep Chakraborty, Jimmy Yih, Kevin YeapDiscussion:https://postgr.es/m/CAE-ML+_EjH_fzfq1F3RJ1=XaaNG=-Jz-i3JqkNhXiLAsM3z-Ew@mail.gmail.comBackpatch-through: 101 parentac897c4 commit595b9cb
File tree
2 files changed
+103
-1
lines changed- src
- backend/access/transam
- test/recovery/t
2 files changed
+103
-1
lines changedLines changed: 14 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1316 | 1316 |
| |
1317 | 1317 |
| |
1318 | 1318 |
| |
1319 |
| - | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
1320 | 1324 |
| |
1321 | 1325 |
| |
1322 | 1326 |
| |
1323 | 1327 |
| |
1324 | 1328 |
| |
1325 | 1329 |
| |
1326 | 1330 |
| |
| 1331 | + | |
1327 | 1332 |
| |
1328 | 1333 |
| |
1329 | 1334 |
| |
| |||
1338 | 1343 |
| |
1339 | 1344 |
| |
1340 | 1345 |
| |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
1341 | 1354 |
| |
1342 | 1355 |
| |
1343 | 1356 |
| |
|
Lines changed: 89 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + |
0 commit comments
Comments
(0)