- Notifications
You must be signed in to change notification settings - Fork5
Commitc2a14bc
committed
Protect against SnapshotNow race conditions in pg_tablespace scans.
Use of SnapshotNow is known to expose us to race conditions if the tuple(s)being sought could be updated by concurrently-committing transactions.CREATE DATABASE and DROP DATABASE are particularly exposed because they doheavyweight filesystem operations during their scans of pg_tablespace,so that the scans run for a very long time compared to most. Furthermore,the potential consequences of a missed or twice-visited row are nastierthan average:* createdb() could fail with a bogus "file already exists" error, or silently fail to copy one or more tablespace's worth of files into the new database.* remove_dbtablespaces() could miss one or more tablespaces, thus failing to free filesystem space for the dropped database.* check_db_file_conflict() could likewise miss a tablespace, leading to an OID conflict that could result in data loss either immediately or in future operations. (This seems of very low probability, though, since a duplicate database OID would be unlikely to start with.)Hence, it seems worth fixing these three places to use MVCC snapshots, eventhough this will someday be superseded by a generic solution to SnapshotNowrace conditions.Back-patch to all active branches.Stephen Frost and Tom Lane1 parent530bbfa commitc2a14bc
1 file changed
+54
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
134 | 135 | | |
135 | 136 | | |
136 | 137 | | |
| |||
534 | 535 | | |
535 | 536 | | |
536 | 537 | | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
537 | 561 | | |
538 | 562 | | |
539 | 563 | | |
| |||
551 | 575 | | |
552 | 576 | | |
553 | 577 | | |
554 | | - | |
| 578 | + | |
555 | 579 | | |
556 | 580 | | |
557 | 581 | | |
| |||
656 | 680 | | |
657 | 681 | | |
658 | 682 | | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
659 | 686 | | |
660 | 687 | | |
661 | 688 | | |
| |||
1715 | 1742 | | |
1716 | 1743 | | |
1717 | 1744 | | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
1718 | 1756 | | |
1719 | 1757 | | |
1720 | | - | |
| 1758 | + | |
1721 | 1759 | | |
1722 | 1760 | | |
1723 | 1761 | | |
| |||
1763 | 1801 | | |
1764 | 1802 | | |
1765 | 1803 | | |
| 1804 | + | |
1766 | 1805 | | |
1767 | 1806 | | |
1768 | 1807 | | |
| |||
1784 | 1823 | | |
1785 | 1824 | | |
1786 | 1825 | | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
1787 | 1836 | | |
1788 | 1837 | | |
1789 | | - | |
| 1838 | + | |
1790 | 1839 | | |
1791 | 1840 | | |
1792 | 1841 | | |
| |||
1812 | 1861 | | |
1813 | 1862 | | |
1814 | 1863 | | |
| 1864 | + | |
| 1865 | + | |
1815 | 1866 | | |
1816 | 1867 | | |
1817 | 1868 | | |
| |||
0 commit comments
Comments
(0)