Fix pytest record contention issues due to non-atomic read-write - #2
Merged
Merged
Conversation
Every mutation must hold the lock across BOTH the read and the write. Reading under one acquisition and writing under a second lets a concurrent writer slip in between, and because each write serializes the whole mapping, that writer's entries are silently dropped -- they are absent from the stale snapshot being written back. Nothing ever re-adds them, so a later `update_test_status` for a dropped node ID raises `KeyError`, which surfaces as an xdist INTERNALERROR that aborts the entire session.
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.
We have been experiencing sporadic test failures on CI when xdist is enabled, especially for runners with > 2 cores (and thus multiple concurrent workers). There is a non-atomic write in the collected test record that is causing issues when multiple runners attempt to write to it simultaneously.