forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit068674f
committed
Fix possibility of logical decoding partial transaction changes.
When creating and initializing a logical slot, the restart_lsn is setto the latest WAL insertion point (or the latest replay point onstandbys). Subsequently, WAL records are decoded from that point tofind the start point for extracting changes in theDecodingContextFindStartpoint() function. Since the initialrestart_lsn could be in the middle of a transaction, the start pointmust be a consistent point where we won't see the data for partialtransactions.Previously, when not building a full snapshot, serialized snapshotswere restored, and the SnapBuild jumps to the consistent state evenwhile finding the start point. Consequently, the slot's restart_lsnand confirmed_flush could be set to the middle of a transaction. Thiscould lead to various unexpected consequences. Specifically, therewere reports of logical decoding decoding partial transactions, andassertion failures occurred because only subtransactions were decodedwithout decoding their top-level transaction until decoding the commitrecord.To resolve this issue, the changes prevent restoring the serializedsnapshot and jumping to the consistent state while finding the startpoint.On v17 and HEAD, a flag indicating whether snapshot restores should beskipped has been added to the SnapBuild struct, and SNAPBUILD_VERSIONhas been bumpded.On backbranches, the flag is stored in the LogicalDecodingContextinstead, preserving on-disk compatibility.Backpatch to all supported versions.Reported-by: Drew CallahanReviewed-by: Amit Kapila, Hayato KurodaDiscussion:https://postgr.es/m/2444AA15-D21B-4CCE-8052-52C7C2DAFE5C%40amazon.comBackpatch-through: 121 parenta9747be commit068674f
File tree
7 files changed
+122
-10
lines changed- contrib/test_decoding
- expected
- specs
- src
- backend/replication/logical
- include/replication
7 files changed
+122
-10
lines changedLines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
| 12 | + | |
12 | 13 |
| |
13 | 14 |
| |
14 | 15 |
| |
|
Lines changed: 45 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 | + |
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
62 | 62 |
| |
63 | 63 |
| |
64 | 64 |
| |
| 65 | + | |
65 | 66 |
| |
66 | 67 |
| |
67 | 68 |
| |
|
Lines changed: 46 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 | + |
Lines changed: 4 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
152 | 152 |
| |
153 | 153 |
| |
154 | 154 |
| |
| 155 | + | |
155 | 156 |
| |
156 | 157 |
| |
157 | 158 |
| |
| |||
212 | 213 |
| |
213 | 214 |
| |
214 | 215 |
| |
215 |
| - | |
| 216 | + | |
216 | 217 |
| |
217 | 218 |
| |
218 | 219 |
| |
| |||
438 | 439 |
| |
439 | 440 |
| |
440 | 441 |
| |
441 |
| - | |
| 442 | + | |
442 | 443 |
| |
443 | 444 |
| |
444 | 445 |
| |
| |||
592 | 593 |
| |
593 | 594 |
| |
594 | 595 |
| |
595 |
| - | |
| 596 | + | |
596 | 597 |
| |
597 | 598 |
| |
598 | 599 |
| |
|
Lines changed: 23 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
189 | 189 |
| |
190 | 190 |
| |
191 | 191 |
| |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
192 | 200 |
| |
193 | 201 |
| |
194 | 202 |
| |
| |||
317 | 325 |
| |
318 | 326 |
| |
319 | 327 |
| |
| 328 | + | |
320 | 329 |
| |
321 | 330 |
| |
322 | 331 |
| |
| |||
347 | 356 |
| |
348 | 357 |
| |
349 | 358 |
| |
| 359 | + | |
350 | 360 |
| |
351 | 361 |
| |
352 | 362 |
| |
| |||
1327 | 1337 |
| |
1328 | 1338 |
| |
1329 | 1339 |
| |
1330 |
| - | |
1331 |
| - | |
1332 |
| - | |
1333 |
| - | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
1334 | 1346 |
| |
1335 | 1347 |
| |
1336 | 1348 |
| |
| |||
1395 | 1407 |
| |
1396 | 1408 |
| |
1397 | 1409 |
| |
1398 |
| - | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
1399 | 1415 |
| |
| 1416 | + | |
1400 | 1417 |
| |
1401 | 1418 |
| |
1402 | 1419 |
| |
| |||
1580 | 1597 |
| |
1581 | 1598 |
| |
1582 | 1599 |
| |
1583 |
| - | |
| 1600 | + | |
1584 | 1601 |
| |
1585 | 1602 |
| |
1586 | 1603 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
62 | 62 |
| |
63 | 63 |
| |
64 | 64 |
| |
| 65 | + | |
65 | 66 |
| |
66 | 67 |
| |
67 | 68 |
| |
|
0 commit comments
Comments
(0)