Skip to content

[v26.2.x] kafka/client: authenticate under the reconnect mutex - #31273

Merged
nvartolomei merged 1 commit into
redpanda-data:v26.2.xfrom
vbotbuildovich:backport-pr-31152-v26.2.x-909
Jul 24, 2026
Merged

[v26.2.x] kafka/client: authenticate under the reconnect mutex#31273
nvartolomei merged 1 commit into
redpanda-data:v26.2.xfrom
vbotbuildovich:backport-pr-31152-v26.2.x-909

Conversation

@vbotbuildovich

Copy link
Copy Markdown
Collaborator

Backport of PR #31152

remote_broker released the reconnect mutex before authenticating, so
two concurrent dispatches on a fresh SASL connection could race: the
second caller saw the half-set-up connection, skipped auth, and sent
its request mid-handshake, which the broker rejects by dropping the
connection.

Hold the mutex across both reconnect and authentication so a concurrent
caller waits until the connection is fully established. On auth failure
discard the transport, since SASL authenticates a connection once and
recovery must reconnect.

Note: the SASL round-trips are bounded by the transport's default
request timeout rather than the caller's abort source, which now also
caps how long the reconnect mutex is held during auth. This is
deliberate: the connect/auth attempt is shared by every caller queued
on the mutex, so one caller's abort must not cut short work the others
are waiting on -- an aborting caller simply stops waiting on the mutex.

Tests cover the race and post-failure connection reuse.

(cherry picked from commit b08c929)
@vbotbuildovich vbotbuildovich added this to the v26.2.x-next milestone Jul 24, 2026
@vbotbuildovich vbotbuildovich added the kind/backport PRs targeting a stable branch label Jul 24, 2026
@nvartolomei
nvartolomei enabled auto-merge July 24, 2026 10:19
@nvartolomei
nvartolomei merged commit a632ab6 into redpanda-data:v26.2.x Jul 24, 2026
18 checks passed
@tyson-redpanda tyson-redpanda modified the milestones: v26.2.x-next, v26.2.2 Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build area/redpanda kind/backport PRs targeting a stable branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants