Skip to content

don't complete a writer acquire on a peer's reclaimed marker#571

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
dxbjavid:writer-phase2-token-check
Jun 29, 2026
Merged

don't complete a writer acquire on a peer's reclaimed marker#571
gaborbernat merged 1 commit into
tox-dev:mainfrom
dxbjavid:writer-phase2-token-check

Conversation

@dxbjavid

Copy link
Copy Markdown
Contributor

the writer acquire is two-phase, and in phase 2 (waiting for readers to drain) it refreshes the .write marker on every scan. if the writer is paused longer than stale_threshold a peer can evict that now-stale marker and reclaim the slot with its own token, but phase 2 carried on touching whatever sat at the path and reported success once the readers had gone, so the original writer would finish its acquire on top of the peer's live marker and two writers could end up believing they hold the exclusive lock at the same time. this re-checks that the marker still carries our token before refreshing it, the same identity check the heartbeat refresh and the release path already rely on, and re-claims the slot (waiting behind the peer when it currently holds .write) instead of trusting a foreign marker. the regression test drives the eviction mid phase-2 and asserts the acquire no longer completes on a stranger's marker.

@gaborbernat gaborbernat left a comment

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.

LGTM

@gaborbernat gaborbernat merged commit 22ecd6a into tox-dev:main Jun 29, 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