- Notifications
You must be signed in to change notification settings - Fork5
Commit1711882
committed
Fix transient clobbering of shared buffers during WAL replay.
RestoreBkpBlocks was in the habit of zeroing and refilling the targetbuffer; which was perfectly safe when the code was written, but is unsafeduring Hot Standby operation. The reason is that we have coding rulesthat allow backends to continue accessing a tuple in a heap relation whileholding only a pin on its buffer. Such a backend could see transientlyzeroed data, if WAL replay had occasion to change other data on the page.This has been shown to be the cause of bug #6425 from Duncan Rance (whodeserves kudos for developing a sufficiently-reproducible test case) aswell as Bridget Frey's re-report of bug #6200. It most likely explains theoriginal report as well, though we don't yet have confirmation of that.To fix, change the code so that only bytes that are supposed to change willchange, even transiently. This actually saves cycles in RestoreBkpBlocks,since it's not writing the same bytes twice.Also fix seq_redo, which has the same disease, though it has to work a bitharder to meet the requirement.So far as I can tell, no other WAL replay routines have this type of bug.In particular, the index-related replay routines, which would certainly bebroken if they had to meet the same standard, are not at risk because wedo not have coding rules that allow access to an index page when notholding a buffer lock on it.Back-patch to 9.0 where Hot Standby was added.1 parentee68a44 commit1711882
2 files changed
+24
-9
lines changedLines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3716 | 3716 |
| |
3717 | 3717 |
| |
3718 | 3718 |
| |
3719 |
| - | |
3720 |
| - | |
3721 | 3719 |
| |
| 3720 | + | |
| 3721 | + | |
3722 | 3722 |
| |
3723 | 3723 |
| |
3724 | 3724 |
| |
|
Lines changed: 22 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1521 | 1521 |
| |
1522 | 1522 |
| |
1523 | 1523 |
| |
| 1524 | + | |
1524 | 1525 |
| |
1525 | 1526 |
| |
1526 | 1527 |
| |
| |||
1536 | 1537 |
| |
1537 | 1538 |
| |
1538 | 1539 |
| |
1539 |
| - | |
1540 |
| - | |
1541 |
| - | |
1542 |
| - | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
1543 | 1554 |
| |
1544 | 1555 |
| |
1545 | 1556 |
| |
1546 | 1557 |
| |
1547 | 1558 |
| |
1548 |
| - | |
| 1559 | + | |
1549 | 1560 |
| |
1550 | 1561 |
| |
1551 | 1562 |
| |
1552 |
| - | |
1553 |
| - | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
1554 | 1567 |
| |
1555 | 1568 |
| |
| 1569 | + | |
| 1570 | + | |
1556 | 1571 |
| |
1557 | 1572 |
| |
1558 | 1573 |
| |
|
0 commit comments
Comments
(0)