Skip to content

strelaysrv: second join of a session is refused with "already connected" although the session is not full #10952

Open

Description

@muelli

What happened?

AddConnection hands the connection to Serve with a non-blocking send on an unbuffered channel (connsChan, AddConnection). If Serve is not at its receive when the second join arrives, AddConnection returns false and the listener answers ResponseAlreadyConnected, although the session is not full. findSession has already deleted the key, so the refused side cannot retry, and the accepted side waits in a half-empty session until its own timeout.

Both invitations are written one after the other, so two clients that join as soon as they have their invitation can arrive microseconds apart.

Reproduction, v1.30.0 and ed2e0fd: one client keeps a control connection, a second asks for an invitation with client.GetInvitationFromRelay, then both call client.JoinSession at the same instant (goroutines released together), 300 rounds. In several runs 6 to 25 percent of the joins were answered incorrect response code 2: already connected (for example 94, 113, 61, 144 and 149 of 600). With one side waiting 20 ms, none of 300 were.

In an application this shows as a connection attempt failing with that error or, on the accepted side, client handshake: ... i/o timeout. About one run in ten of an integration test through a local relay failed that way.

Possibly related: #3272

A possible fix is here.

Syncthing version

1.30.0

Platform & operating system

any

Browser version

No response

Relevant log output

Activity

  1. added theissue type on Nov 12, 2026
  2. added
    bug
    needs-triage
    on Nov 12, 2026
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

    bugneeds-triage

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions