forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitc54ebcb
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 parent66debec commitc54ebcb
1 file changed
+54
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
135 | 136 | | |
136 | 137 | | |
137 | 138 | | |
| |||
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 | | |
| |||
1687 | 1714 | | |
1688 | 1715 | | |
1689 | 1716 | | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
1690 | 1728 | | |
1691 | 1729 | | |
1692 | | - | |
| 1730 | + | |
1693 | 1731 | | |
1694 | 1732 | | |
1695 | 1733 | | |
| |||
1735 | 1773 | | |
1736 | 1774 | | |
1737 | 1775 | | |
| 1776 | + | |
1738 | 1777 | | |
1739 | 1778 | | |
1740 | 1779 | | |
| |||
1756 | 1795 | | |
1757 | 1796 | | |
1758 | 1797 | | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
1759 | 1808 | | |
1760 | 1809 | | |
1761 | | - | |
| 1810 | + | |
1762 | 1811 | | |
1763 | 1812 | | |
1764 | 1813 | | |
| |||
1784 | 1833 | | |
1785 | 1834 | | |
1786 | 1835 | | |
| 1836 | + | |
| 1837 | + | |
1787 | 1838 | | |
1788 | 1839 | | |
1789 | 1840 | | |
| |||
0 commit comments
Comments
(0)