forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit92c1f91
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 parent801babf commit92c1f91
1 file changed
+54
-3
lines changedLines changed: 54 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
132 | 132 |
| |
133 | 133 |
| |
134 | 134 |
| |
| 135 | + | |
135 | 136 |
| |
136 | 137 |
| |
137 | 138 |
| |
| |||
587 | 588 |
| |
588 | 589 |
| |
589 | 590 |
| |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
590 | 614 |
| |
591 | 615 |
| |
592 | 616 |
| |
| |||
604 | 628 |
| |
605 | 629 |
| |
606 | 630 |
| |
607 |
| - | |
| 631 | + | |
608 | 632 |
| |
609 | 633 |
| |
610 | 634 |
| |
| |||
708 | 732 |
| |
709 | 733 |
| |
710 | 734 |
| |
| 735 | + | |
| 736 | + | |
| 737 | + | |
711 | 738 |
| |
712 | 739 |
| |
713 | 740 |
| |
| |||
1692 | 1719 |
| |
1693 | 1720 |
| |
1694 | 1721 |
| |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
1695 | 1733 |
| |
1696 | 1734 |
| |
1697 |
| - | |
| 1735 | + | |
1698 | 1736 |
| |
1699 | 1737 |
| |
1700 | 1738 |
| |
| |||
1740 | 1778 |
| |
1741 | 1779 |
| |
1742 | 1780 |
| |
| 1781 | + | |
1743 | 1782 |
| |
1744 | 1783 |
| |
1745 | 1784 |
| |
| |||
1761 | 1800 |
| |
1762 | 1801 |
| |
1763 | 1802 |
| |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
1764 | 1813 |
| |
1765 | 1814 |
| |
1766 |
| - | |
| 1815 | + | |
1767 | 1816 |
| |
1768 | 1817 |
| |
1769 | 1818 |
| |
| |||
1789 | 1838 |
| |
1790 | 1839 |
| |
1791 | 1840 |
| |
| 1841 | + | |
| 1842 | + | |
1792 | 1843 |
| |
1793 | 1844 |
| |
1794 | 1845 |
| |
|
0 commit comments
Comments
(0)