Repository navigation
fix(reconnect): don't kill thread on duplicate connection error while a reconnect is already pending - #392
Merged
fcostaoliveira merged 3 commits intoMay 22, 2026
Conversation
…pending Fixes redis#391. shard_connection::attempt_reconnect() collapsed three semantically distinct cases into one terminal else, so the second callback in a libevent error storm (EOF + stray TLS reads during failover) always called event_base_loopbreak() — even with --max-reconnect-attempts=0 (unlimited). Add an else-if for the already-reconnecting case that silently returns; the in-flight reconnect timer decides what to do when it fires. Also adds a regression test that verifies the misleading "Maximum reconnection attempts (0) exceeded" message never appears when unlimited reconnects are configured. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
The ASAN Single Endpoint TCP TLS job timed out after 597 s (9.95 min), killing the step 2 s after all 99 tests had already passed. The CI TLS matrix jobs were also running at 10m5–10m20s — squarely at the limit. TSAN already uses 15 min; align the others to the same ceiling. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
fcostaoliveira
force-pushed
the
fix/attempt-reconnect-dup-error-during-pending-reconnect
branch
from
May 22, 2026 05:43
e33355b to
0b8e396
Compare
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
RLTest's assertFalse signature is assertFalse(val, depth=0, message=''). Passing the message string as a positional second argument landed it in depth, causing TypeError: can only concatenate str (not "int") to str when RLTest computed depth + 1 internally. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
paulorsousa
approved these changes
May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #391.
What changed
shard_connection.cpp::attempt_reconnect()previously collapsed three semantically distinct conditions into a single terminalelsebranch:!reconnect_on_error— caller opted out (terminal: yes)m_reconnecting == true— a reconnect is already pending (terminal: no — should be a no-op)m_reconnect_attempts >= max_reconnect_attempts— configured cap reached (terminal: yes)Case 2 is the bug. During a real failover, libevent delivers a small storm of connection-error callbacks per dead connection (EOF + stray TLS read errors). The first enters the happy path and schedules a reconnect timer; the rest land in the
elsebranch and callevent_base_loopbreak(), killing the per-thread event loop regardless of--max-reconnect-attemptsvalue (including the documented "0= unlimited" semantic).Fix
Add an
else iffor the "already reconnecting" case that silently returns. The terminalelsekeeps its existing behaviour for the two cases that are terminal.Test plan
make test).Issue link
Full reproduction + log evidence in #391.
Note
Medium Risk
Changes core reconnection control flow in
shard_connection::attempt_reconnect, which can affect benchmark thread liveness under error conditions; regression coverage is added to reduce risk.Overview
Prevents benchmark threads from being spuriously restarted when libevent delivers multiple connection-error callbacks while a reconnect timer is already pending (especially with
--max-reconnect-attempts=0unlimited), by treating those duplicate callbacks as a no-op instead of breaking the event loop.Adds a regression test (
test_reconnect_unlimited_no_spurious_thread_restart) that repeatedly kills connections and asserts the misleading "Maximum reconnection attempts (0) exceeded" message never appears and the run exits successfully. CI/ASAN/UBSAN workflow test step timeouts are increased from 10 to 15 minutes to reduce flakiness for the expanded test suite.Reviewed by Cursor Bugbot for commit 9a3a220. Bugbot is set up for automated code reviews on this repo. Configure here.