Skip to content
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

core/rawdb: implement freezer tail truncation #24027

Closed
wants to merge 1 commit into from

Conversation

holiman
Copy link
Contributor

@holiman holiman commented Dec 1, 2021

This is a WIP. More testcases are needed.
This PR implements tail truncation at arbitrary point, for individual freezer tables. It supersedes #23954 , which is mostly the same thing, the differences being:

This PR also fixes an issue with the head truncation -- the head truncation functionality on master failed to take into account that a tail truncation might have been already performed, while calculating the indexes.

// Apply the table-offset
//from = from - t.itemOffset
for {
buffer := make([]byte, indexEntrySize)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like you forgot to bump the from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doh! well spotted!
I know there must be things like this lurking, since I haven't actually defined good testcases for it yet

t.releaseFilesBefore(fileNo, false)
// In file corresponding to fileNo, we now need to delete all data prior to 'start'
destPath := t.fileName(int(fileNo))
copyFrom(destPath, destPath, uint64(start))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we truncate the data file first, a few corner cases need to be considered

e.g. if crash happens before we update the index file

  • how to handle the items which are deleted from the data file but not from the index file yet(non-existent?)
  • how to handle the items which are shifted in the tail data file but the relevant indexes are not updated yet(wrong item accessed with the original index?)

@holiman holiman closed this Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants