Repository navigation
Fix index file race conditions - #625
Merged
Merged
Conversation
Previously an update truncated the index file before locking it, and every updating process fetched the mirror to the same path in the store. When several zef processes started on a fresh store at the same time, such as the parallel installs Blin runs, some of them read an empty or partially written index. The parse error was swallowed, so those processes reported "No candidates found matching identity" for distributions that exist. This fetches each mirror to a unique path that is removed afterwards, and writes the index to a unique temporary file that is then renamed over the index. Readers now see either the previous index or the complete new one, so the lock files are no longer needed.
Previously an index that failed to parse was searched as an empty ecosystem, so an install reported "No candidates found matching identity" for distributions that exist. This reports the index and the parse error instead.
Previously an update saved whatever a mirror responded with, so an error page or a truncated response replaced a good index, and every following install failed until the next update. A mirror is now parsed before it replaces the index, and a mirror that does not parse is passed over for the next one. The iteration also kept going after a mirror was saved, leaving the last mirror as the index rather than the first one that worked. It now stops at the first mirror that provides a package list. Populating the distributions reuses the package list that the update parsed instead of reading the index back.
Previously the lock file was deleted once the protected code finished. A process already waiting for it then took the lock on a file that no longer had a name, while the next process created a new file and locked that instead, so both ran the protected code at once. This keeps the lock file. An ecosystem update now fetches into a directory of its own so that the lock file the fetcher leaves behind is removed along with everything else it fetched.
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.
No description provided.