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: retry writing lockfile on failure #24052

Merged
merged 2 commits into from
Jun 1, 2024

Conversation

dsherret
Copy link
Member

Ran into this running the deno_graph ecosystem tests where many processes writing to the same path at the same time would cause an error.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
loop {
match atomic_write_file(file_path, data.as_ref(), mode) {
Ok(()) => return Ok(()),
Err(err) => {
Copy link
Member Author

@dsherret dsherret May 30, 2024

Choose a reason for hiding this comment

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

Should we be selective on error kind? Note: atomic_write_file already handles creating the directory when it doesn't exist.

@@ -84,7 +84,7 @@ pub fn write_lockfile_if_has_changes(
};
// do an atomic write to reduce the chance of multiple deno
// processes corrupting the file
atomic_write_file(&lockfile.filename, bytes, cache::CACHE_PERM)
atomic_write_file_with_retries(&lockfile.filename, bytes, cache::CACHE_PERM)
Copy link
Member Author

Choose a reason for hiding this comment

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

Confirmed this retrying fixed the rare issue I was having in deno_graph's ecosystem tests.

@dsherret dsherret requested a review from bartlomieju May 31, 2024 21:00
@dsherret dsherret merged commit 38ff9fa into denoland:main Jun 1, 2024
17 checks passed
@dsherret dsherret deleted the fix_retry_writing_lockfile branch June 1, 2024 03:25
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