- Notifications
You must be signed in to change notification settings - Fork5
Commitc6d76d7
committed
Add locking around WAL-replay modification of shared-memory variables.
Originally, most of this code assumed that no Postgres backends could berunning concurrently with it, and so no locking could be needed. Thatassumption fails in Hot Standby. While it's still true that Hot Standbybackends should never change values like nextXid, they can examine them,and consistency is important in some cases such as when computing asnapshot. Therefore, prudence requires that WAL replay code obtain therelevant locks when modifying such variables, even though it can examinethem without taking a lock. We were following that coding rule in someplaces but not all. This commit applies the coding rule uniformly to allupdates of ShmemVariableCache and MultiXactState fields; a search of thereplay routines did not find any other cases that seemed to be at risk.In addition, this commit fixes a longstanding thinko in replay of NEXTOIDand checkpoint records: we tried to advance nextOid only if it was behindthe value in the WAL record, but the comparison would draw the wrongconclusion if OID wraparound had occurred since the previous value.Better to just unconditionally assign the new value, since OID assignmentshouldn't be happening during replay anyway.The additional locking seems to be more in the nature of future-proofingthan fixing any live bug, so I am not going to back-patch it. The NEXTOIDfix will be back-patched separately.1 parent96abd81 commitc6d76d7
File tree
4 files changed
+75
-20
lines changed- src/backend
- access/transam
- storage/ipc
4 files changed
+75
-20
lines changedLines changed: 9 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1655 | 1655 |
| |
1656 | 1656 |
| |
1657 | 1657 |
| |
1658 |
| - | |
1659 |
| - | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
1660 | 1661 |
| |
1661 | 1662 |
| |
1662 | 1663 |
| |
1663 | 1664 |
| |
1664 | 1665 |
| |
1665 | 1666 |
| |
1666 | 1667 |
| |
| 1668 | + | |
1667 | 1669 |
| |
1668 | 1670 |
| |
| 1671 | + | |
1669 | 1672 |
| |
1670 | 1673 |
| |
1671 | 1674 |
| |
| |||
1674 | 1677 |
| |
1675 | 1678 |
| |
1676 | 1679 |
| |
1677 |
| - | |
| 1680 | + | |
| 1681 | + | |
1678 | 1682 |
| |
1679 | 1683 |
| |
1680 | 1684 |
| |
1681 | 1685 |
| |
1682 | 1686 |
| |
| 1687 | + | |
1683 | 1688 |
| |
1684 | 1689 |
| |
1685 | 1690 |
| |
| |||
1691 | 1696 |
| |
1692 | 1697 |
| |
1693 | 1698 |
| |
| 1699 | + | |
1694 | 1700 |
| |
1695 | 1701 |
| |
1696 | 1702 |
| |
|
Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1715 | 1715 |
| |
1716 | 1716 |
| |
1717 | 1717 |
| |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
1718 | 1722 |
| |
1719 | 1723 |
| |
1720 | 1724 |
| |
| |||
1726 | 1730 |
| |
1727 | 1731 |
| |
1728 | 1732 |
| |
| 1733 | + | |
1729 | 1734 |
| |
1730 | 1735 |
| |
| 1736 | + | |
1731 | 1737 |
| |
1732 | 1738 |
| |
1733 | 1739 |
| |
|
Lines changed: 36 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6625 | 6625 |
| |
6626 | 6626 |
| |
6627 | 6627 |
| |
6628 |
| - | |
| 6628 | + | |
| 6629 | + | |
| 6630 | + | |
| 6631 | + | |
| 6632 | + | |
| 6633 | + | |
| 6634 | + | |
6629 | 6635 |
| |
6630 | 6636 |
| |
6631 | 6637 |
| |
| 6638 | + | |
6632 | 6639 |
| |
6633 | 6640 |
| |
| 6641 | + | |
6634 | 6642 |
| |
6635 | 6643 |
| |
6636 | 6644 |
| |
| |||
6656 | 6664 |
| |
6657 | 6665 |
| |
6658 | 6666 |
| |
| 6667 | + | |
6659 | 6668 |
| |
6660 | 6669 |
| |
6661 | 6670 |
| |
| |||
6971 | 6980 |
| |
6972 | 6981 |
| |
6973 | 6982 |
| |
| 6983 | + | |
6974 | 6984 |
| |
6975 | 6985 |
| |
| 6986 | + | |
6976 | 6987 |
| |
6977 | 6988 |
| |
6978 | 6989 |
| |
| |||
8547 | 8558 |
| |
8548 | 8559 |
| |
8549 | 8560 |
| |
| 8561 | + | |
| 8562 | + | |
| 8563 | + | |
| 8564 | + | |
| 8565 | + | |
| 8566 | + | |
| 8567 | + | |
8550 | 8568 |
| |
8551 |
| - | |
8552 |
| - | |
8553 |
| - | |
8554 |
| - | |
8555 |
| - | |
| 8569 | + | |
| 8570 | + | |
| 8571 | + | |
| 8572 | + | |
8556 | 8573 |
| |
8557 | 8574 |
| |
8558 | 8575 |
| |
8559 | 8576 |
| |
8560 | 8577 |
| |
8561 | 8578 |
| |
8562 | 8579 |
| |
| 8580 | + | |
8563 | 8581 |
| |
| 8582 | + | |
| 8583 | + | |
8564 | 8584 |
| |
8565 | 8585 |
| |
| 8586 | + | |
8566 | 8587 |
| |
8567 | 8588 |
| |
8568 | 8589 |
| |
| |||
8575 | 8596 |
| |
8576 | 8597 |
| |
8577 | 8598 |
| |
8578 |
| - | |
| 8599 | + | |
8579 | 8600 |
| |
8580 | 8601 |
| |
8581 | 8602 |
| |
| |||
8641 | 8662 |
| |
8642 | 8663 |
| |
8643 | 8664 |
| |
8644 |
| - | |
| 8665 | + | |
| 8666 | + | |
8645 | 8667 |
| |
8646 | 8668 |
| |
8647 | 8669 |
| |
8648 |
| - | |
8649 |
| - | |
8650 |
| - | |
8651 |
| - | |
8652 |
| - | |
| 8670 | + | |
| 8671 | + | |
| 8672 | + | |
| 8673 | + | |
| 8674 | + | |
| 8675 | + | |
8653 | 8676 |
| |
8654 | 8677 |
| |
8655 | 8678 |
| |
|
Lines changed: 24 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
654 | 654 |
| |
655 | 655 |
| |
656 | 656 |
| |
657 |
| - | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
658 | 668 |
| |
659 | 669 |
| |
660 | 670 |
| |
| 671 | + | |
| 672 | + | |
661 | 673 |
| |
| 674 | + | |
| 675 | + | |
662 | 676 |
| |
663 |
| - | |
664 | 677 |
| |
665 | 678 |
| |
666 |
| - | |
667 |
| - | |
668 | 679 |
| |
669 | 680 |
| |
670 | 681 |
| |
| |||
1690 | 1701 |
| |
1691 | 1702 |
| |
1692 | 1703 |
| |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
1693 | 1711 |
| |
1694 | 1712 |
| |
1695 | 1713 |
| |
| |||
2609 | 2627 |
| |
2610 | 2628 |
| |
2611 | 2629 |
| |
| 2630 | + | |
2612 | 2631 |
| |
| 2632 | + | |
2613 | 2633 |
| |
2614 | 2634 |
| |
2615 | 2635 |
| |
|
0 commit comments
Comments
(0)