forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commite5d8a99
committed
Use full 64-bit XIDs in deleted nbtree pages.
Otherwise we risk "leaking" deleted pages by making them non-recyclableindefinitely. Commit 6655a729 did the same thing for deleted pages inGiST indexes. That work was used as a starting point here.Stop storing an XID indicating the oldest bpto.xact across all deletedthough unrecycled pages in nbtree metapages. There is no longer anyreason to care about that condition/the oldest XID. It only ever madesense when wraparound was something _bt_vacuum_needs_cleanup() had toconsider.The btm_oldest_btpo_xact metapage field has been repurposed and renamed.It is now btm_last_cleanup_num_delpages, which is used to remember howmany non-recycled deleted pages remain from the last VACUUM (in practiceits value is usually the precise number of pages that were _newlydeleted_ during the specific VACUUM operation that last set the field).The general idea behind storing btm_last_cleanup_num_delpages is to useit to give _some_ consideration to non-recycled deleted pages inside_bt_vacuum_needs_cleanup() -- though never too much. We only reallyneed to avoid leaving a truly excessive number of deleted pages in anunrecycled state forever. We only do this to cover certain narrow caseswhere no other factor makes VACUUM do a full scan, and yet the indexcontinues to grow (and so actually misses out on recycling existingdeleted pages).These metapage changes result in a clear user-visible benefit: We nolonger trigger full index scans during VACUUM operations solely due tothe presence of only 1 or 2 known deleted (though unrecycled) blocksfrom a very large index. All that matters now is keeping the costs andbenefits in balance over time.Fix an issue that has been around since commit857f9c3, which added the"skip full scan of index" mechanism (i.e. the _bt_vacuum_needs_cleanup()logic). The accuracy of btm_last_cleanup_num_heap_tuples accidentallyhinged upon _when_ the source value gets stored. We now always storebtm_last_cleanup_num_heap_tuples in btvacuumcleanup(). This fixes theissue because IndexVacuumInfo.num_heap_tuples (the source field) isexpected to accurately indicate the state of the table _after_ theVACUUM completes inside btvacuumcleanup().A backpatchable fix cannot easily be extracted from this commit. Atargeted fix for the issue will follow in a later commit, though thatwon't happen today.I (pgeoghegan) have chosen to remove any mention of deleted pages in thedocumentation of the vacuum_cleanup_index_scale_factor GUC/param, sincethe presence of deleted (though unrecycled) pages is no longer of muchconcern to users. The vacuum_cleanup_index_scale_factor description inthe docs now seems rather unclear in any case, and it should probably berewritten in the near future. Perhaps some passing mention of pagedeletion will be added back at the same time.Bump XLOG_PAGE_MAGIC due to nbtree WAL records using full XIDs now.Author: Peter Geoghegan <pg@bowt.ie>Reviewed-By: Masahiko Sawada <sawada.mshk@gmail.com>Discussion:https://postgr.es/m/CAH2-WznpdHvujGUwYZ8sihX=d5u-tRYhi-F4wnV2uN2zHpMUXw@mail.gmail.com1 parent8a4f952 commite5d8a99
File tree
20 files changed
+623
-407
lines changed- contrib
- amcheck
- pageinspect
- expected
- pgstattuple
- doc/src/sgml
- src
- backend
- access
- gist
- nbtree
- rmgrdesc
- storage/ipc
- include
- access
- storage
20 files changed
+623
-407
lines changedLines changed: 56 additions & 34 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
769 | 769 |
| |
770 | 770 |
| |
771 | 771 |
| |
772 |
| - | |
| 772 | + | |
773 | 773 |
| |
774 | 774 |
| |
775 | 775 |
| |
| |||
794 | 794 |
| |
795 | 795 |
| |
796 | 796 |
| |
797 |
| - | |
798 |
| - | |
| 797 | + | |
| 798 | + | |
799 | 799 |
| |
800 | 800 |
| |
801 | 801 |
| |
802 | 802 |
| |
803 | 803 |
| |
804 |
| - | |
| 804 | + | |
805 | 805 |
| |
806 | 806 |
| |
807 | 807 |
| |
| |||
1164 | 1164 |
| |
1165 | 1165 |
| |
1166 | 1166 |
| |
1167 |
| - | |
| 1167 | + | |
1168 | 1168 |
| |
1169 | 1169 |
| |
1170 | 1170 |
| |
| |||
1520 | 1520 |
| |
1521 | 1521 |
| |
1522 | 1522 |
| |
1523 |
| - | |
| 1523 | + | |
1524 | 1524 |
| |
1525 | 1525 |
| |
1526 | 1526 |
| |
| |||
1597 | 1597 |
| |
1598 | 1598 |
| |
1599 | 1599 |
| |
1600 |
| - | |
| 1600 | + | |
1601 | 1601 |
| |
1602 | 1602 |
| |
1603 | 1603 |
| |
| |||
1900 | 1900 |
| |
1901 | 1901 |
| |
1902 | 1902 |
| |
1903 |
| - | |
1904 |
| - | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
1905 | 1906 |
| |
1906 | 1907 |
| |
1907 | 1908 |
| |
1908 | 1909 |
| |
1909 | 1910 |
| |
1910 |
| - | |
| 1911 | + | |
1911 | 1912 |
| |
1912 | 1913 |
| |
1913 | 1914 |
| |
| |||
2132 | 2133 |
| |
2133 | 2134 |
| |
2134 | 2135 |
| |
2135 |
| - | |
| 2136 | + | |
2136 | 2137 |
| |
2137 | 2138 |
| |
2138 | 2139 |
| |
| |||
2275 | 2276 |
| |
2276 | 2277 |
| |
2277 | 2278 |
| |
2278 |
| - | |
| 2279 | + | |
2279 | 2280 |
| |
2280 | 2281 |
| |
2281 | 2282 |
| |
| |||
2304 | 2305 |
| |
2305 | 2306 |
| |
2306 | 2307 |
| |
2307 |
| - | |
| 2308 | + | |
2308 | 2309 |
| |
2309 | 2310 |
| |
2310 | 2311 |
| |
| |||
2319 | 2320 |
| |
2320 | 2321 |
| |
2321 | 2322 |
| |
2322 |
| - | |
| 2323 | + | |
2323 | 2324 |
| |
2324 | 2325 |
| |
2325 | 2326 |
| |
2326 | 2327 |
| |
2327 | 2328 |
| |
2328 | 2329 |
| |
2329 |
| - | |
| 2330 | + | |
2330 | 2331 |
| |
2331 |
| - | |
| 2332 | + | |
2332 | 2333 |
| |
2333 | 2334 |
| |
2334 | 2335 |
| |
| |||
2389 | 2390 |
| |
2390 | 2391 |
| |
2391 | 2392 |
| |
2392 |
| - | |
| 2393 | + | |
2393 | 2394 |
| |
2394 | 2395 |
| |
2395 | 2396 |
| |
| |||
2983 | 2984 |
| |
2984 | 2985 |
| |
2985 | 2986 |
| |
2986 |
| - | |
2987 |
| - | |
| 2987 | + | |
| 2988 | + | |
| 2989 | + | |
2988 | 2990 |
| |
2989 |
| - | |
2990 |
| - | |
2991 |
| - | |
2992 |
| - | |
2993 |
| - | |
| 2991 | + | |
| 2992 | + | |
| 2993 | + | |
2994 | 2994 |
| |
2995 |
| - | |
2996 |
| - | |
2997 |
| - | |
2998 |
| - | |
2999 |
| - | |
3000 |
| - | |
| 2995 | + | |
| 2996 | + | |
| 2997 | + | |
| 2998 | + | |
| 2999 | + | |
| 3000 | + | |
| 3001 | + | |
| 3002 | + | |
| 3003 | + | |
| 3004 | + | |
| 3005 | + | |
| 3006 | + | |
| 3007 | + | |
| 3008 | + | |
3001 | 3009 |
| |
3002 | 3010 |
| |
3003 | 3011 |
| |
| |||
3044 | 3052 |
| |
3045 | 3053 |
| |
3046 | 3054 |
| |
3047 |
| - | |
3048 |
| - | |
3049 | 3055 |
| |
3050 | 3056 |
| |
3051 | 3057 |
| |
| |||
3054 | 3060 |
| |
3055 | 3061 |
| |
3056 | 3062 |
| |
| 3063 | + | |
| 3064 | + | |
| 3065 | + | |
| 3066 | + | |
3057 | 3067 |
| |
3058 | 3068 |
| |
3059 | 3069 |
| |
3060 |
| - | |
3061 |
| - | |
| 3070 | + | |
| 3071 | + | |
| 3072 | + | |
| 3073 | + | |
| 3074 | + | |
| 3075 | + | |
| 3076 | + | |
| 3077 | + | |
| 3078 | + | |
| 3079 | + | |
| 3080 | + | |
| 3081 | + | |
| 3082 | + | |
| 3083 | + | |
3062 | 3084 |
| |
3063 | 3085 |
| |
3064 | 3086 |
| |
|
Lines changed: 49 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
75 | 75 |
| |
76 | 76 |
| |
77 | 77 |
| |
78 |
| - | |
79 |
| - | |
80 |
| - | |
81 |
| - | |
82 |
| - | |
| 78 | + | |
83 | 79 |
| |
84 | 80 |
| |
85 | 81 |
| |
| |||
112 | 108 |
| |
113 | 109 |
| |
114 | 110 |
| |
115 |
| - | |
116 |
| - | |
117 |
| - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
118 | 138 |
| |
119 | 139 |
| |
120 | 140 |
| |
| |||
128 | 148 |
| |
129 | 149 |
| |
130 | 150 |
| |
131 |
| - | |
| 151 | + | |
132 | 152 |
| |
133 | 153 |
| |
134 | 154 |
| |
| |||
237 | 257 |
| |
238 | 258 |
| |
239 | 259 |
| |
240 |
| - | |
| 260 | + | |
241 | 261 |
| |
242 | 262 |
| |
243 | 263 |
| |
| |||
503 | 523 |
| |
504 | 524 |
| |
505 | 525 |
| |
506 |
| - | |
507 |
| - | |
508 |
| - | |
509 |
| - | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
510 | 534 |
| |
511 | 535 |
| |
512 | 536 |
| |
| |||
603 | 627 |
| |
604 | 628 |
| |
605 | 629 |
| |
606 |
| - | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
607 | 638 |
| |
608 | 639 |
| |
609 | 640 |
| |
| |||
692 | 723 |
| |
693 | 724 |
| |
694 | 725 |
| |
695 |
| - | |
696 |
| - | |
697 |
| - | |
698 |
| - | |
| 726 | + | |
699 | 727 |
| |
700 | 728 |
| |
701 | 729 |
| |
| |||
723 | 751 |
| |
724 | 752 |
| |
725 | 753 |
| |
726 |
| - | |
| 754 | + | |
| 755 | + | |
727 | 756 |
| |
728 | 757 |
| |
729 | 758 |
| |
|
Lines changed: 11 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
6 |
| - | |
7 |
| - | |
8 |
| - | |
9 |
| - | |
10 |
| - | |
11 |
| - | |
12 |
| - | |
13 |
| - | |
14 |
| - | |
15 |
| - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
16 | 16 |
| |
17 | 17 |
| |
18 | 18 |
| |
| |||
29 | 29 |
| |
30 | 30 |
| |
31 | 31 |
| |
32 |
| - | |
| 32 | + | |
33 | 33 |
| |
34 | 34 |
| |
35 | 35 |
| |
|
0 commit comments
Comments
(0)