Skip to content

Redis socket tokens can be overwritten under concurrent claim #6881

Description

@anxkhn

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:

  1. Run two app workers against the same Redis.
  2. Have two clients claim the same socket token at the same time.
  3. Observe one worker overwrite the other's token record.

This is the tracking issue requested on that pull request.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions