Commit c454556
Merged PR 1766230: [Vacuum] Enable better vacuum cleanup Part 1
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No
### Are you introducing any new config? If yes, do you have tests with and without them being set?
Yes
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
Rum/GIN Entry Tree pages can be pruned better - Currently, over time, indexes will bloat in size.
To handle this, we walk the entry leaves on vacuum and if empty, we prune them more eagerly.
This is the first part of many in cleanup of the entry tree in RUM.
Note that while this marks the buffers as HALFDEAD - it does not reclaim the page space - that will be done in a subsequent step where the XID horizon is past all active requests. Once that is done, the page is marked recyclable and reusable.
In its current shape, this prunes empty leaves in the RUM index only if the entire page is only posting lists and marks them as half-dead. It also leaves behind the right most child of an intermediate tree for correctness.
It also doesn't handle intermediate nodes currently so as-is we will have lots of skinny trees in the index once a lot of data is deleted.
Note that this is only intended for offline /adhoc use currently since more thorough testing is needed for vacuuming. pending further tests and stress handling
----
#### AI description (iteration 1)
#### PR Classification
This pull request adds a new vacuum tree cleanup feature to the RUM index by enabling the pruning of empty pages during vacuum operations.
#### PR Summary
The update enhances the vacuum process by introducing logic to safely detect and remove empty leaf pages, improve tuple retrieval for half-dead states, and provide better logging and configuration control.
- **`pgmongo_rum/src/rumvacuum.c`**: Added the `CheckAndPruneEmptyRumPage` function and updated vacuum routines to identify, prune, and log empty pages.
- **`pgmongo_rum/src/rum.h` & `rumutil.c`**: Introduced new macros for half-dead page handling and defined the GUC variable `RumPruneEmptyPages` to control the cleanup behavior.
- **`pgmongo_rum/src/rumscan.c` & `rumentrypage.c`**: Refactored tuple retrieval functions to support the new cleanup logic by using `rumEntryGetRightMostTuple` and handling half-dead pages.
- **Test files & scripts**: Updated SQL tests and configuration scripts to validate and enable the new vacuum cleanup functionality.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->1 parent e797d39 commit c454556
4 files changed
Lines changed: 22 additions & 13 deletions
File tree
- internal/pg_documentdb_extended_rum/src
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
139 | 140 | | |
140 | 141 | | |
141 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
142 | 147 | | |
143 | 148 | | |
144 | 149 | | |
| |||
570 | 575 | | |
571 | 576 | | |
572 | 577 | | |
573 | | - | |
574 | | - | |
575 | 578 | | |
576 | 579 | | |
577 | 580 | | |
578 | 581 | | |
| 582 | + | |
579 | 583 | | |
580 | 584 | | |
| 585 | + | |
581 | 586 | | |
582 | 587 | | |
583 | 588 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
116 | | - | |
| 115 | + | |
| 116 | + | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
140 | 146 | | |
141 | 147 | | |
142 | 148 | | |
| |||
264 | 270 | | |
265 | 271 | | |
266 | 272 | | |
267 | | - | |
268 | 273 | | |
269 | 274 | | |
270 | 275 | | |
| |||
569 | 574 | | |
570 | 575 | | |
571 | 576 | | |
572 | | - | |
| 577 | + | |
573 | 578 | | |
574 | 579 | | |
575 | 580 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
901 | 901 | | |
902 | 902 | | |
903 | 903 | | |
904 | | - | |
905 | | - | |
906 | | - | |
907 | | - | |
908 | 904 | | |
909 | 905 | | |
910 | 906 | | |
911 | | - | |
912 | | - | |
913 | 907 | | |
914 | 908 | | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
915 | 913 | | |
916 | 914 | | |
917 | 915 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
0 commit comments