forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commite9edc1b
committed
Fix logical decoding error when system table w/ toast is repeatedly rewritten.
Repeatedly rewriting a mapped catalog table with VACUUM FULL orCLUSTER could cause logical decoding to fail with:ERROR, "could not map filenode \"%s\" to relation OID"To trigger the problem the rewritten catalog had to have live tupleswith toasted columns.The problem was triggered as during catalog table rewrites theheap_insert() check that prevents logical decoding information to beemitted for system catalogs, failed to treat the new heap's toast tableas a system catalog (because the new heap is not recognized as acatalog table via RelationIsLogicallyLogged()). The relmapper, incontrast to the normal catalog contents, does not contain historicalinformation. After a single rewrite of a mapped table the new relationis known to the relmapper, but if the table is rewritten twice beforelogical decoding occurs, the relfilenode cannot be mapped to arelation anymore. Which then leads us to error out. This onlyhappens for toast tables, because the main table contents aren'tre-inserted with heap_insert().The fix is simple, add a new heap_insert() flag that prevents logicaldecoding information from being emitted, and accept during decodingthat there might not be tuple data for toast tables.Unfortunately that does not fix pre-existing logical decodingerrors. Doing so would require not throwing an error when a filenodecannot be mapped to a relation during decoding, and that seems toolikely to hide bugs. If it's crucial to fix decoding for an existingslot, temporarily changing the ERROR in ReorderBufferCommit() to aWARNING appears to be the best fix.Author: Andres FreundDiscussion:https://postgr.es/m/20180914021046.oi7dm4ra3ot2g2kt@alap3.anarazel.deBackpatch: 9.4-, where logical decoding was introduced1 parentef49305 commite9edc1b
File tree
6 files changed
+163
-10
lines changed- contrib/test_decoding
- expected
- sql
- src
- backend
- access/heap
- replication/logical
- include/access
6 files changed
+163
-10
lines changedLines changed: 75 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 | 2 |
| |
3 | 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 | + | |
4 | 59 |
| |
5 | 60 |
| |
6 | 61 |
| |
| |||
76 | 131 |
| |
77 | 132 |
| |
78 | 133 |
| |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
79 | 151 |
| |
80 | 152 |
| |
81 | 153 |
| |
82 | 154 |
| |
83 | 155 |
| |
84 | 156 |
| |
85 | 157 |
| |
| 158 | + | |
| 159 | + | |
| 160 | + |
Lines changed: 41 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 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 | + | |
6 | 35 |
| |
7 | 36 |
| |
8 | 37 |
| |
| |||
57 | 86 |
| |
58 | 87 |
| |
59 | 88 |
| |
60 |
| - | |
61 | 89 |
| |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
62 | 99 |
| |
| 100 | + | |
| 101 | + | |
| 102 | + |
Lines changed: 10 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2435 | 2435 |
| |
2436 | 2436 |
| |
2437 | 2437 |
| |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
2438 | 2443 |
| |
2439 | 2444 |
| |
2440 | 2445 |
| |
| |||
2563 | 2568 |
| |
2564 | 2569 |
| |
2565 | 2570 |
| |
2566 |
| - | |
| 2571 | + | |
| 2572 | + | |
2567 | 2573 |
| |
2568 | 2574 |
| |
2569 | 2575 |
| |
| |||
2728 | 2734 |
| |
2729 | 2735 |
| |
2730 | 2736 |
| |
| 2737 | + | |
| 2738 | + | |
| 2739 | + | |
2731 | 2740 |
| |
2732 | 2741 |
| |
2733 | 2742 |
| |
|
Lines changed: 16 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
652 | 652 |
| |
653 | 653 |
| |
654 | 654 |
| |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
655 | 669 |
| |
656 |
| - | |
657 |
| - | |
658 |
| - | |
| 670 | + | |
| 671 | + | |
659 | 672 |
| |
660 | 673 |
| |
661 | 674 |
| |
|
Lines changed: 20 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1527 | 1527 |
| |
1528 | 1528 |
| |
1529 | 1529 |
| |
1530 |
| - | |
1531 |
| - | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
1532 | 1540 |
| |
1533 | 1541 |
| |
1534 | 1542 |
| |
| |||
1590 | 1598 |
| |
1591 | 1599 |
| |
1592 | 1600 |
| |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
1593 | 1605 |
| |
1594 |
| - | |
1595 |
| - | |
1596 |
| - | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
1597 | 1612 |
| |
1598 | 1613 |
| |
1599 | 1614 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
29 | 29 |
| |
30 | 30 |
| |
31 | 31 |
| |
| 32 | + | |
32 | 33 |
| |
33 | 34 |
| |
34 | 35 |
| |
|
0 commit comments
Comments
(0)