Respect client retry backoff in supervisor reconciliation - #1014
Open
antongulin wants to merge 1 commit into
Open
Respect client retry backoff in supervisor reconciliation#1014antongulin wants to merge 1 commit into
antongulin wants to merge 1 commit into
Conversation
The periodic 30s reconciliation planned ActionConnect for any enabled, unconnected server regardless of its failure history, bypassing the managed client's exponential backoff and MaxConnectionRetries give-up (the ConnectAll path already gates on ShouldRetry; the per-server reconcile path did not). A dead or 401-ing remote upstream was therefore re-dialed every 30 seconds forever - roughly 3 HTTP requests per tick, ~9k requests/day against a server that cannot answer. computeReconcilePlan now consults the client's ConnectionInfo and plans ActionNone while the backoff window is open, after the client gave up, and for servers parked in PendingAuth awaiting user OAuth login. The backoff formula is extracted from StateManager.ShouldRetry into RetryBackoffDuration so both paths share one schedule. Fixes smart-mcp-proxy#1013
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 #1013.
Impact
The supervisor's periodic 30s reconciliation planned
ActionConnectfor any enabled, unconnected server regardless of failure history, bypassing the managed client's exponential backoff andMaxConnectionRetriesgive-up. TheConnectAllpath ininternal/upstream/manager.goalready gates onStateError && !ShouldRetry()— the per-server reconcile path did not. A dead or 401-ing remote upstream was re-dialed every 30 seconds forever (~3 HTTP requests per attempt, ~9k requests/day). In our case this tripped a third-party MCP vendor's server alarms twice and got our account paused (full incident detail in #1013).Changes
internal/upstream/types/types.go— extracted the backoff formula fromStateManager.ShouldRetryintoRetryBackoffDuration(retryCount)(behavior unchanged: 1s → 2s → 4s … capped at 5min), and addedConnectionInfo.ShouldAutoReconnect(now): false while the backoff window is open, afterGaveUp/MaxConnectionRetries, and forStatePendingAuth(redialing cannot succeed until the user completes OAuth login; each attempt costs real requests against the upstream).internal/runtime/supervisor/supervisor.go—computeReconcilePlanconsultsactual.ConnectionInfo.ShouldAutoReconnect(...)before planningActionConnectand plansActionNone(with a debug log) when the client's retry policy says wait.Manual reconnects, login flows,
reconnect_on_use, and config-changeActionReconnectare unaffected — only the automatic periodic redial is gated. Once the backoff window elapses, the next reconcile tick reconnects as before.Verification
New tests:
TestRetryBackoffDuration— schedule values and overflow capsTestConnectionInfo_ShouldAutoReconnect— nil/fresh/ready/pending-auth/backoff-open/backoff-elapsed/gave-up casesTestSupervisor_Reconcile_RespectsRetryBackoff— reconcile skips a failed server inside its backoff window, a gave-up server, and a PendingAuth server; reconnects after backoff elapsesLog excerpt of the failure mode this prevents (identical cycle every 30s for two weeks):