- Notifications
You must be signed in to change notification settings - Fork5
Commit21b446d
committed
Fix CLUSTER/VACUUM FULL for toast values owned by recently-updated rows.
In commit7b0d0e9, I made CLUSTER andVACUUM FULL try to preserve toast value OIDs from the original toast tableto the new one. However, if we have to copy both live and recently-deadversions of a row that has a toasted column, those versions may wellreference the same toast value with the same OID. The patch then led toduplicate-key failures as we tried to insert the toast value twice with thesame OID. (The previous behavior was not very desirable either, since itwould have silently inserted the same value twice with different OIDs.That wastes space, but what's worse is that the toast values inserted foralready-dead heap rows would not be reclaimed by subsequent ordinaryVACUUMs, since they go into the new toast table marked live not deleted.)To fix, check if the copied OID already exists in the new toast table, andif so, assume that it stores the desired value. This is reasonably safesince the only case where we will copy an OID from a previous toast pointeris when toast_insert_or_update was given that toast pointer and so we justpulled the data from the old table; if we got two different values that waythen we have big problems anyway. We do have to assume that no otherbackend is inserting items into the new toast table concurrently, butthat's surely safe for CLUSTER and VACUUM FULL.Per bug #6393 from Maxim Boguk. Back-patch to 9.0, same as the previouspatch.1 parentde5a08c commit21b446d
File tree
3 files changed
+62
-19
lines changed- src
- backend
- access/heap
- commands
- include/utils
3 files changed
+62
-19
lines changedLines changed: 53 additions & 14 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
76 | 76 |
| |
77 | 77 |
| |
78 | 78 |
| |
79 |
| - | |
| 79 | + | |
| 80 | + | |
80 | 81 |
| |
81 | 82 |
| |
82 | 83 |
| |
| |||
1342 | 1343 |
| |
1343 | 1344 |
| |
1344 | 1345 |
| |
| 1346 | + | |
| 1347 | + | |
1345 | 1348 |
| |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
1346 | 1374 |
| |
1347 | 1375 |
| |
1348 | 1376 |
| |
| |||
1356 | 1384 |
| |
1357 | 1385 |
| |
1358 | 1386 |
| |
1359 |
| - | |
1360 |
| - | |
| 1387 | + | |
| 1388 | + | |
1361 | 1389 |
| |
1362 | 1390 |
| |
1363 | 1391 |
| |
| |||
1495 | 1523 |
| |
1496 | 1524 |
| |
1497 | 1525 |
| |
1498 |
| - | |
| 1526 | + | |
1499 | 1527 |
| |
1500 | 1528 |
| |
1501 | 1529 |
| |
1502 | 1530 |
| |
1503 | 1531 |
| |
1504 |
| - | |
| 1532 | + | |
1505 | 1533 |
| |
1506 | 1534 |
| |
1507 |
| - | |
1508 | 1535 |
| |
1509 | 1536 |
| |
1510 | 1537 |
| |
1511 |
| - | |
1512 |
| - | |
1513 |
| - | |
1514 |
| - | |
1515 |
| - | |
1516 | 1538 |
| |
1517 | 1539 |
| |
1518 | 1540 |
| |
| |||
1530 | 1552 |
| |
1531 | 1553 |
| |
1532 | 1554 |
| |
1533 |
| - | |
1534 |
| - | |
1535 |
| - | |
1536 | 1555 |
| |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
1537 | 1576 |
| |
1538 | 1577 |
| |
1539 | 1578 |
| |
|
Lines changed: 7 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
787 | 787 |
| |
788 | 788 |
| |
789 | 789 |
| |
790 |
| - | |
791 |
| - | |
792 |
| - | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
793 | 794 |
| |
794 | 795 |
| |
795 | 796 |
| |
796 | 797 |
| |
797 | 798 |
| |
798 | 799 |
| |
799 |
| - | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
800 | 803 |
| |
801 | 804 |
| |
802 | 805 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
159 | 159 |
| |
160 | 160 |
| |
161 | 161 |
| |
162 |
| - | |
| 162 | + | |
| 163 | + | |
163 | 164 |
| |
164 | 165 |
| |
165 | 166 |
| |
|
0 commit comments
Comments
(0)