Skip to content

only unlink the writer marker on release if it is still ours#566

Merged
gaborbernat merged 2 commits into
tox-dev:mainfrom
dxbjavid:writer-marker-release-token-check
Jun 19, 2026
Merged

only unlink the writer marker on release if it is still ours#566
gaborbernat merged 2 commits into
tox-dev:mainfrom
dxbjavid:writer-marker-release-token-check

Conversation

@dxbjavid

Copy link
Copy Markdown
Contributor

If a writer is paused past stale_threshold (a long GC pause, SIGSTOP, a suspended VM) a peer evicts its now-stale .write marker, claims the writer slot and writes its own marker at the same path; the original holder still has _hold set, so on release it unlinks .write by path and deletes the peer's live marker, letting a second writer in and breaking mutual exclusion. The phase-2 timeout cleanup in _acquire_writer_slot has the same shape. Both now read the marker under the state lock and unlink only when the stored token is still ours, which is the same token re-check the stale-break path already relies on.

@@ -379,7 +379,23 @@ def release(self, *, force: bool = False) -> None:
if hold.is_reader:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

src/filelock/_soft_rw/_sync.py:389: serialises ==> serializes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good catch, fixed - switched it to serializes to match the rest of the tree.

@gaborbernat gaborbernat merged commit 64f0c29 into tox-dev:main Jun 19, 2026
33 checks passed
@dxbjavid

Copy link
Copy Markdown
Contributor Author

Thanks

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