forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd98547e
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 parent8d1fbf9 commitd98547e
1 file changed
+54
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
132 | 133 | | |
133 | 134 | | |
134 | 135 | | |
| |||
532 | 533 | | |
533 | 534 | | |
534 | 535 | | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
535 | 559 | | |
536 | 560 | | |
537 | 561 | | |
| |||
549 | 573 | | |
550 | 574 | | |
551 | 575 | | |
552 | | - | |
| 576 | + | |
553 | 577 | | |
554 | 578 | | |
555 | 579 | | |
| |||
653 | 677 | | |
654 | 678 | | |
655 | 679 | | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
656 | 683 | | |
657 | 684 | | |
658 | 685 | | |
| |||
1698 | 1725 | | |
1699 | 1726 | | |
1700 | 1727 | | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
1701 | 1739 | | |
1702 | 1740 | | |
1703 | | - | |
| 1741 | + | |
1704 | 1742 | | |
1705 | 1743 | | |
1706 | 1744 | | |
| |||
1746 | 1784 | | |
1747 | 1785 | | |
1748 | 1786 | | |
| 1787 | + | |
1749 | 1788 | | |
1750 | 1789 | | |
1751 | 1790 | | |
| |||
1767 | 1806 | | |
1768 | 1807 | | |
1769 | 1808 | | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
1770 | 1819 | | |
1771 | 1820 | | |
1772 | | - | |
| 1821 | + | |
1773 | 1822 | | |
1774 | 1823 | | |
1775 | 1824 | | |
| |||
1795 | 1844 | | |
1796 | 1845 | | |
1797 | 1846 | | |
| 1847 | + | |
| 1848 | + | |
1798 | 1849 | | |
1799 | 1850 | | |
1800 | 1851 | | |
| |||
0 commit comments
Comments
(0)