-
Notifications
You must be signed in to change notification settings - Fork 8
fix: data and metadata size keep growing to infinity #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nqd
wants to merge
9
commits into
main
Choose a base branch
from
fix-increasing-db-size
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
🟡 Heimdall Review Status
|
nqd
commented
Jul 10, 2025
reclaimed_orphans_start: u32, | ||
/// Number of reclaimed pages inside of `orphan_pages` | ||
reclaimed_orphans_end: u32, | ||
reclaimed_orphans_size: u32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename
4 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The current system has an issue that does not recycle orphaned pages. At the end, the metadata file and data file keep increasing in sizes.
Data size and metadata size when inserting 2/6/20/200 million {EOAs+storages}
With this PR the size for same tests:
Why?
Let assume the orphan list has len 55603, and range [9390, 31720) was reclaimed.
At a transaction with
snapshot_id = 5
, a new orphaned page withorphaned_at=5
pushed into OrphanPages. This page would be inserted to the list with idx=9390. Other orphaned pages will also be pushed into this already reclaimed area. When the reclaimed area are full (idx 31719 is used), the program starts to push to the end of the list.At the same transaction, the program
pop()
to allocate new pages. It first starts to look for pages at [31720, 55603); this range has orphaned_at <= snapshot_threshold (=4), then will be reclaimed. After reclaiming all pages at the right size,pop()
looks for pages at the left. The left has range [0, i] where9390 <= i < 31720
, andlist[i].orphaned_at = 5
. The program looks at the end of pages on the left with idx=i, which has a failed condition (orphaned_at <= snapshot_threshold).At the end of the transaction, orphan pages in [0, i] will not be reclaimed. This continues in the following transactions, makes the size of metafile grow up, also the data file with accumulated orphaned pages that do not get reused.
Proposal
This PR proposed a simple solution: Instead of always push() to the left of reclaimed area and pop() from the right of the orphaned part, we rotate the priority: