RedisTokenManager.link_token_to_sid currently does a separate exists check and then a set. Two workers can both observe a free token and then overwrite each other, so a client can lose its socket mapping under concurrent reconnects.
Expected: only one worker should own a given token key. The loser should get a fresh token instead of overwriting the winner.
I have a proposed fix in #6771 that uses an atomic SET NX claim with a bounded retry and a local fallback when Redis is unavailable.
Reproduction sketch:
- Run two app workers against the same Redis.
- Have two clients claim the same socket token at the same time.
- Observe one worker overwrite the other's token record.
This is the tracking issue requested on that pull request.
RedisTokenManager.link_token_to_sidcurrently does a separate exists check and then a set. Two workers can both observe a free token and then overwrite each other, so a client can lose its socket mapping under concurrent reconnects.Expected: only one worker should own a given token key. The loser should get a fresh token instead of overwriting the winner.
I have a proposed fix in #6771 that uses an atomic
SET NXclaim with a bounded retry and a local fallback when Redis is unavailable.Reproduction sketch:
This is the tracking issue requested on that pull request.