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 case where filesystem store future dropping causes issues #496

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

allada
Copy link
Member

@allada allada commented Dec 16, 2023

In a rare case where a file is uploaded, but while the rename() function is called the future is dropped the filesystem store can get into a bad state.

fixes: #495


This change is Reviewable

Copy link
Member Author

@allada allada left a comment

Choose a reason for hiding this comment

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

+@adam-singer

Reviewable status: 0 of 3 files reviewed, all discussions resolved (waiting on @adam-singer)

Copy link
Collaborator

@MarcusSorealheis MarcusSorealheis left a comment

Choose a reason for hiding this comment

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

LGTM


/// Regression test for: https://github.com/TraceMachina/nativelink/issues/495.
#[tokio::test]
async fn update_file_future_drops_before_rename() -> Result<(), Error> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice

Copy link
Member

@adam-singer adam-singer left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @allada)


nativelink-store/src/filesystem_store.rs line 583 at r1 (raw file):

                let from_path = encoded_file_path.get_file_path();
                // Internally tokio spawns fs commands onto a blocking thread anyways.
                // Since we are already on a blocking thread, we just need the `fs` wrapper to manage

maybe spell out std::fs::rename.

Given its the std::fs::rename it manages open-file permit (via FnOnce) or is the call_with_permit missing here?


nativelink-util/src/fs.rs line 246 at r1 (raw file):

/// Acquire a permit from the open file semaphore and call a raw function.
#[inline]
pub async fn call_with_permit<R>(func: impl FnOnce() -> Result<R, Error>) -> Result<R, Error> {

Defined but not used?

Copy link
Member

@adam-singer adam-singer left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @allada)

Copy link
Member

@adam-singer adam-singer left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @allada)

Copy link

vercel bot commented Jan 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nativelink-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 18, 2024 1:09am

Copy link
Member

@adam-singer adam-singer left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 2 files at r2, all commit messages.
Dismissed @MarcusSorealheis from a discussion.
Reviewable status: :shipit: complete! 1 of 1 LGTMs obtained

In a rare case where a file is uploaded, but while the rename()
function is called the future is dropped the filesystem store can
get into a bad state.

fixes: #495
Copy link
Member

@adam-singer adam-singer left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: 1 of 1 LGTMs obtained, and pending CI: Remote / large-ubuntu-22.04

Copy link
Member

@adam-singer adam-singer left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: 1 of 1 LGTMs obtained, and pending CI: Remote / large-ubuntu-22.04

@allada allada merged commit 249322d into main Jan 18, 2024
22 checks passed
@allada allada deleted the fix-filesystem-race-condition branch January 18, 2024 14:53
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.

FilesystemStore's file write function can cause erroneous issues in other areas if future is dropped
3 participants