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

Fix handling of swap files #2624

Merged
merged 2 commits into from
Feb 18, 2025
Merged

Fix handling of swap files #2624

merged 2 commits into from
Feb 18, 2025

Conversation

jbearer
Copy link
Member

@jbearer jbearer commented Feb 14, 2025

Cleans up some mis-handled swap files that I missed in the last fix (#2528). Thanks to NodeGuardians for identifying this.

@@ -222,41 +222,36 @@ impl Inner {
fn collect_garbage(
&mut self,
view: ViewNumber,
intervals: &[RangeInclusive<u64>],
intervals: &[RangeInclusive<ViewNumber>],
Copy link
Collaborator

Choose a reason for hiding this comment

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

I can't work out why this function takes a mutable reference to self. Is it to avoid being called in two places at once?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I think that's the idea. It's not mutating the in-memory state that Rust cares about but it's still conceptually a mutable/exclusive function since it's updating shared files and directoreis

let view_number = view;
let prune_view = ViewNumber::new(view.saturating_sub(self.view_retention));

let delete_files = |intervals: &[RangeInclusive<ViewNumber>],
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be a bit more straightforward to make delete_files a method on Inner. IIUC the only thing it takes from the scope is prune_view.

continue;
};
if v > view.u64() {
for (v, path) in view_files(self.decided_leaf_path())? {
Copy link
Collaborator

@sveitser sveitser Feb 18, 2025

Choose a reason for hiding this comment

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

More descriptive name than v? Looking at this PR diff, or file in general, I think it would be nice to be a bit more explicit with names that describe different kinds of view number. I think we should only use the bare term view if that's not ambiguous and that is no longer the case when we are comparing views.

Copy link
Collaborator

@sveitser sveitser left a comment

Choose a reason for hiding this comment

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

LGTM just some nits.

@jbearer jbearer merged commit 1f7215e into main Feb 18, 2025
54 checks passed
@jbearer jbearer deleted the jb/swp branch February 18, 2025 19:01
Copy link
Contributor

Backport failed for release-ignore-swap-files, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release-ignore-swap-files
git worktree add -d .worktree/backport-2624-to-release-ignore-swap-files origin/release-ignore-swap-files
cd .worktree/backport-2624-to-release-ignore-swap-files
git switch --create backport-2624-to-release-ignore-swap-files
git cherry-pick -x 1f7215e06e2d2e98498761f6ce9b8e1ab688a4c2

jbearer added a commit that referenced this pull request Feb 18, 2025
* Fix handling of swap files

* Refactor fs garbage collection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants