Improve Gridstore wipe/clear functionality#6614
Merged
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
JojiiOfficial
approved these changes
May 30, 2025
d24185d to
19c3729
Compare
17 tasks
coszio
approved these changes
May 30, 2025
generall
approved these changes
May 30, 2025
agourlay
approved these changes
Jun 2, 2025
12 tasks
generall
pushed a commit
that referenced
this pull request
Jul 17, 2025
* Gridstore config can be Copy * Add test asserting wipe behavior * Add clear function to Gridstore * Make wipe take ownership, use new clear function everywhere * Add comment to emphasize wipe behavior * Propagate errors
This was referenced Dec 5, 2025
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
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.
Gridstore has a
wipefunction which drops storage, it did take a&mut selfreference. It was problematic.It is fine to use to clear, close and remove storage. But, it's not fine to clear storage and reuse storage afterwards. It leaves the storage in an inconsistent state. I therefore consider this to be a nasty footgun, and I'd argue it must take ownership to disallow reuse.
I've added a test to show the problematic behavior. It calls wipe the same way as we do on other storages, producing this panic:
To fix the problem I've done two things:
wipe(mut self)take ownership to disallow reuseclear(&mut self)to clear and get into the initial state (one empty page), allowing reuseThe clear function is naively implemented removing the directory and recreating storage, but I don't see this as a huge problem.
I actually discovered this problem while implementing #6609. It puzzled me for more than an hour, which is why I'm fixing it now.
All Submissions:
devbranch. Did you create your branch fromdev?New Feature Submissions:
cargo +nightly fmt --allcommand prior to submission?cargo clippy --all --all-featurescommand?