forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit94bc27b
committed
Centralize horizon determination for temp tables, fixing bug due to skew.
This fixes a bug in the edge case where, for a temp table, heap_page_prune()can end up with a different horizon than heap_vacuum_rel(). Which can triggererrors like "ERROR: cannot freeze committed xmax ...".The bug was introduced due to interaction ofa7212be "Set cutoff xmin moreaggressively when vacuuming a temporary table." withdc7420c "snapshotscalability: Don't compute global horizons while building snapshots.".The problem is caused by lazy_scan_heap() assuming that the only reason itsHeapTupleSatisfiesVacuum() call would return HEAPTUPLE_DEAD is if the tuple isa HOT tuple, or if the tuple's inserting transaction has aborted since theheap_page_prune() call. But aftera7212be that was also possible in othercases for temp tables, because heap_page_prune() uses a different visibilitytest afterdc7420c.The fix is fairly simple: Move the special case logic for temp tables fromvacuum_set_xid_limits() to the infrastructure introduced indc7420c. Thatensures that the horizon used for pruning is at least as aggressive as the oneused by lazy_scan_heap(). The concrete horizon used for temp tables isslightly different than the logic indc7420c, but should always be asaggressive as before (see comments).A significant benefit to centralizing the logic procarray.c is that now themore aggressive horizons for temp tables does not just apply to VACUUM butalso to e.g. HOT pruning and the nbtree killtuples logic.Because isTopLevel is not needed by vacuum_set_xid_limits() anymore, Iundid the the related changes froma7212be.This commit also adds an isolation test ensuring that the more aggressivevacuuming and pruning of temp tables keeps working.Debugged-By: Amit Kapila <amit.kapila16@gmail.com>Debugged-By: Tom Lane <tgl@sss.pgh.pa.us>Debugged-By: Ashutosh Sharma <ashu.coek88@gmail.com>Author: Andres Freund <andres@anarazel.de>Discussion:https://postgr.es/m/20201014203103.72oke6hqywcyhx7s@alap3.anarazel.deDiscussion:https://postgr.es/m/20201015083735.derdzysdtqdvxshp@alap3.anarazel.de1 parent60a51c6 commit94bc27b
File tree
9 files changed
+544
-73
lines changed- src
- backend
- access/heap
- commands
- storage/ipc
- include/commands
- test/isolation
- expected
- specs
9 files changed
+544
-73
lines changedLines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
471 | 471 |
| |
472 | 472 |
| |
473 | 473 |
| |
474 |
| - | |
475 | 474 |
| |
476 | 475 |
| |
477 | 476 |
| |
|
Lines changed: 11 additions & 17 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
67 | 67 |
| |
68 | 68 |
| |
69 | 69 |
| |
70 |
| - | |
71 |
| - | |
| 70 | + | |
72 | 71 |
| |
73 |
| - | |
74 |
| - | |
75 |
| - | |
76 |
| - | |
| 72 | + | |
| 73 | + | |
77 | 74 |
| |
78 | 75 |
| |
79 | 76 |
| |
| |||
173 | 170 |
| |
174 | 171 |
| |
175 | 172 |
| |
176 |
| - | |
| 173 | + | |
177 | 174 |
| |
178 | 175 |
| |
179 | 176 |
| |
| |||
222 | 219 |
| |
223 | 220 |
| |
224 | 221 |
| |
225 |
| - | |
226 |
| - | |
| 222 | + | |
227 | 223 |
| |
228 | 224 |
| |
229 | 225 |
| |
| |||
254 | 250 |
| |
255 | 251 |
| |
256 | 252 |
| |
257 |
| - | |
| 253 | + | |
258 | 254 |
| |
259 | 255 |
| |
260 | 256 |
| |
| |||
404 | 400 |
| |
405 | 401 |
| |
406 | 402 |
| |
407 |
| - | |
| 403 | + | |
408 | 404 |
| |
409 | 405 |
| |
410 | 406 |
| |
| |||
549 | 545 |
| |
550 | 546 |
| |
551 | 547 |
| |
552 |
| - | |
553 | 548 |
| |
554 | 549 |
| |
555 | 550 |
| |
556 | 551 |
| |
557 |
| - | |
| 552 | + | |
558 | 553 |
| |
559 | 554 |
| |
560 | 555 |
| |
| |||
582 | 577 |
| |
583 | 578 |
| |
584 | 579 |
| |
585 |
| - | |
| 580 | + | |
586 | 581 |
| |
587 | 582 |
| |
588 | 583 |
| |
| |||
733 | 728 |
| |
734 | 729 |
| |
735 | 730 |
| |
736 |
| - | |
737 |
| - | |
| 731 | + | |
738 | 732 |
| |
739 | 733 |
| |
740 | 734 |
| |
| |||
832 | 826 |
| |
833 | 827 |
| |
834 | 828 |
| |
835 |
| - | |
| 829 | + | |
836 | 830 |
| |
837 | 831 |
| |
838 | 832 |
| |
|
Lines changed: 26 additions & 48 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
907 | 907 |
| |
908 | 908 |
| |
909 | 909 |
| |
910 |
| - | |
911 |
| - | |
| 910 | + | |
912 | 911 |
| |
913 | 912 |
| |
914 | 913 |
| |
| |||
934 | 933 |
| |
935 | 934 |
| |
936 | 935 |
| |
937 |
| - | |
938 | 936 |
| |
939 | 937 |
| |
940 | 938 |
| |
| |||
950 | 948 |
| |
951 | 949 |
| |
952 | 950 |
| |
953 |
| - | |
954 |
| - | |
955 |
| - | |
956 |
| - | |
957 |
| - | |
958 |
| - | |
959 |
| - | |
960 |
| - | |
961 |
| - | |
962 |
| - | |
963 |
| - | |
964 |
| - | |
965 |
| - | |
966 |
| - | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
967 | 963 |
| |
968 |
| - | |
969 |
| - | |
970 |
| - | |
971 |
| - | |
972 |
| - | |
973 |
| - | |
974 |
| - | |
975 |
| - | |
976 |
| - | |
977 |
| - | |
978 |
| - | |
979 |
| - | |
980 |
| - | |
| 964 | + | |
| 965 | + | |
981 | 966 |
| |
982 |
| - | |
| 967 | + | |
| 968 | + | |
983 | 969 |
| |
984 |
| - | |
985 |
| - | |
986 |
| - | |
987 |
| - | |
988 |
| - | |
989 |
| - | |
990 |
| - | |
991 |
| - | |
992 |
| - | |
993 |
| - | |
994 |
| - | |
995 |
| - | |
996 |
| - | |
997 |
| - | |
998 |
| - | |
999 |
| - | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
1000 | 978 |
| |
1001 | 979 |
| |
1002 | 980 |
| |
| |||
1930 | 1908 |
| |
1931 | 1909 |
| |
1932 | 1910 |
| |
1933 |
| - | |
| 1911 | + | |
1934 | 1912 |
| |
1935 | 1913 |
| |
1936 | 1914 |
| |
|
Lines changed: 55 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
131 | 131 |
| |
132 | 132 |
| |
133 | 133 |
| |
134 |
| - | |
| 134 | + | |
135 | 135 |
| |
136 | 136 |
| |
137 | 137 |
| |
| |||
153 | 153 |
| |
154 | 154 |
| |
155 | 155 |
| |
| 156 | + | |
| 157 | + | |
| 158 | + | |
156 | 159 |
| |
157 | 160 |
| |
158 | 161 |
| |
| |||
234 | 237 |
| |
235 | 238 |
| |
236 | 239 |
| |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
237 | 247 |
| |
238 | 248 |
| |
239 | 249 |
| |
| |||
257 | 267 |
| |
258 | 268 |
| |
259 | 269 |
| |
260 |
| - | |
| 270 | + | |
261 | 271 |
| |
262 | 272 |
| |
263 | 273 |
| |
264 | 274 |
| |
265 | 275 |
| |
| 276 | + | |
266 | 277 |
| |
267 | 278 |
| |
268 | 279 |
| |
| |||
1668 | 1679 |
| |
1669 | 1680 |
| |
1670 | 1681 |
| |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
1671 | 1699 |
| |
1672 | 1700 |
| |
1673 | 1701 |
| |
| |||
1760 | 1788 |
| |
1761 | 1789 |
| |
1762 | 1790 |
| |
| 1791 | + | |
1763 | 1792 |
| |
1764 | 1793 |
| |
1765 | 1794 |
| |
| |||
1785 | 1814 |
| |
1786 | 1815 |
| |
1787 | 1816 |
| |
| 1817 | + | |
1788 | 1818 |
| |
1789 | 1819 |
| |
1790 | 1820 |
| |
| |||
1844 | 1874 |
| |
1845 | 1875 |
| |
1846 | 1876 |
| |
| 1877 | + | |
| 1878 | + | |
1847 | 1879 |
| |
1848 | 1880 |
| |
1849 | 1881 |
| |
| |||
1878 | 1910 |
| |
1879 | 1911 |
| |
1880 | 1912 |
| |
| 1913 | + | |
| 1914 | + | |
1881 | 1915 |
| |
1882 | 1916 |
| |
1883 | 1917 |
| |
| |||
2054 | 2088 |
| |
2055 | 2089 |
| |
2056 | 2090 |
| |
2057 |
| - | |
2058 |
| - | |
| 2091 | + | |
| 2092 | + | |
2059 | 2093 |
| |
2060 | 2094 |
| |
2061 | 2095 |
| |
| |||
2357 | 2391 |
| |
2358 | 2392 |
| |
2359 | 2393 |
| |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
| 2402 | + | |
2360 | 2403 |
| |
2361 | 2404 |
| |
2362 | 2405 |
| |
| |||
2375 | 2418 |
| |
2376 | 2419 |
| |
2377 | 2420 |
| |
| 2421 | + | |
| 2422 | + | |
2378 | 2423 |
| |
2379 | 2424 |
| |
2380 | 2425 |
| |
| |||
3892 | 3937 |
| |
3893 | 3938 |
| |
3894 | 3939 |
| |
| 3940 | + | |
| 3941 | + | |
3895 | 3942 |
| |
3896 | 3943 |
| |
3897 | 3944 |
| |
| |||
3942 | 3989 |
| |
3943 | 3990 |
| |
3944 | 3991 |
| |
| 3992 | + | |
| 3993 | + | |
| 3994 | + | |
3945 | 3995 |
| |
3946 | 3996 |
| |
3947 | 3997 |
| |
| |||
3957 | 4007 |
| |
3958 | 4008 |
| |
3959 | 4009 |
| |
| 4010 | + | |
3960 | 4011 |
| |
3961 | 4012 |
| |
3962 | 4013 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
19 | 19 |
| |
20 | 20 |
| |
21 | 21 |
| |
22 |
| - | |
23 |
| - | |
| 22 | + | |
24 | 23 |
| |
25 | 24 |
| |
26 | 25 |
| |
|
Lines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
267 | 267 |
| |
268 | 268 |
| |
269 | 269 |
| |
270 |
| - | |
271 | 270 |
| |
272 | 271 |
| |
273 | 272 |
| |
|
0 commit comments
Comments
(0)