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: use filelock for authentication fallback storage #427

Merged
merged 2 commits into from
Dec 4, 2023

Conversation

baszalmstra
Copy link
Collaborator

@baszalmstra baszalmstra commented Dec 4, 2023

The tests for the authentication storage randomly failed. I think this was caused by multiple threads writing to the fallback storage at the same time. This was only guarded by a mutex but multiple objects referring to the same file could exists. I replaced the mutex with a filelock to ensure that the multiple threads (and processes) are synchronized.

By request I also changed the logging behavior to ensure that the warning about fallback storage is only printed once (per file).

self.path.to_string_lossy()
);
return Ok(std::collections::HashMap::new());
static WARN_GUARD: Lazy<Mutex<HashSet<PathBuf>>> =
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@wolfv this should ensure that the warning is only printed once per filename for the current process.

Copy link
Contributor

Choose a reason for hiding this comment

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

neat!

@baszalmstra baszalmstra requested a review from wolfv December 4, 2023 14:44
@baszalmstra baszalmstra marked this pull request as ready for review December 4, 2023 14:51
@baszalmstra baszalmstra changed the title fix: flaky test error fix: use filelock for authentication fallback storage Dec 4, 2023
@wolfv wolfv merged commit 5a70fc4 into conda:main Dec 4, 2023
8 checks passed
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.

2 participants