Skip to content

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

Merged
nvartolomei merged 1 commit into
redpanda-data:v26.1.xfrom
vbotbuildovich:ai-backport-pr-31152-v26.1.x-1784570815
Aug 12, 2026
Merged

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

Conversation

@vbotbuildovich

Copy link
Copy Markdown
Collaborator

Backport of PR #31152

  • Command: git cherry-pick -x b08c929
  • Commits backported: 1
  • Conflicts resolved: 1
  • Commits skipped (already on target): 0
  • Backport branch: ai-backport-pr-31152-v26.1.x-1784570815

Conflict details

  • b08c929 (src/v/kafka/client/test/BUILD): the commit added the granular
    //src/v/cluster:* sub-targets (client_quota_backend, cluster_utils,
    controller_log_limiter, data_migration_table, feature_backend,
    leader_balancer_strategy, node_status_backend, self_test,
    topic_metrics_watcher) plus //src/v/config and
    //src/v/kafka/client:api_types to the cluster_test deps. On v26.1.x
    //src/v/cluster is still a single monolithic target and those fine-grained
    sub-targets do not exist, so the granular deps were collapsed to the single
    //src/v/cluster target (the pattern already used by the other test targets
    in this file), keeping //src/v/config and //src/v/kafka/client:api_types.
    This satisfies every include added to cluster_test.cc
    (cluster/security_frontend.h is provided by //src/v/cluster).

@vbotbuildovich vbotbuildovich added this to the v26.1.x-next milestone Jul 20, 2026
@vbotbuildovich vbotbuildovich added the kind/backport PRs targeting a stable branch label Jul 20, 2026
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)

[v26.1.x: the test used ss::this_smp_shard_count(), which this branch's
seastar predates; replaced with ss::smp::count]
@nvartolomei
nvartolomei force-pushed the ai-backport-pr-31152-v26.1.x-1784570815 branch from 8bbd832 to f60a499 Compare August 12, 2026 11:27
@nvartolomei

Copy link
Copy Markdown
Contributor

The build failed because the backported test helper called ss::this_smp_shard_count(), which the seastar pinned on v26.1.x predates. Replaced it with the equivalent ss::smp::count and amended the commit (noted as a [v26.1.x: ...] trailer in the commit message).

Verified locally: bazel build //src/v/kafka/client:brokers //src/v/kafka/client/test:cluster_test compiles and bazel test //src/v/kafka/client/test:cluster_test passes.

@nvartolomei
nvartolomei enabled auto-merge August 12, 2026 11:56
@vbotbuildovich

Copy link
Copy Markdown
Collaborator Author

CI test results

test results on build#88621
test_status test_class test_method test_arguments test_kind job_url passed reason test_history
FLAKY(PASS) DataMigrationsApiTest test_higher_level_migration_api null integration https://buildkite.com/redpanda/redpanda/builds/88621#019ff5c9-f9c7-4a73-a285-9c690c0c712b 10/11 Test PASSES after retries.No significant increase in flaky rate(baseline=0.0000, p0=1.0000, reject_threshold=0.0100. adj_baseline=0.1000, p1=0.3487, trust_threshold=0.5000) https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=DataMigrationsApiTest&test_method=test_higher_level_migration_api

@nvartolomei
nvartolomei merged commit 90035fc into redpanda-data:v26.1.x Aug 12, 2026
16 checks passed
@tyson-redpanda tyson-redpanda modified the milestones: v26.1.x-next, v26.1.16 Aug 12, 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