Auto-fall back to HTTP/1.1 on HTTP/2 protocol errors#410
Open
manan164 wants to merge 1 commit into
Open
Conversation
Long-lived HTTP/2 connections through some proxies/load balancers (e.g. GCP Cloud Run, AWS ALB) can produce protocol-level errors (GOAWAY storms, stale keep-alive resets). The existing self-healing reset rebuilt another HTTP/2 client that hit the same wall, so the poll loop could cycle reset->fail->reset and effectively stop polling with no CPU/memory spike. On a ProtocolError/ReadError/WriteError, if HTTP/2 is enabled, the reset now downgrades to HTTP/1.1 for the remainder of the process (sticky) instead of rebuilding HTTP/2. Default-on HTTP/2 behavior is unchanged for healthy environments. Opt out of the fallback with CONDUCTOR_HTTP2_AUTO_FALLBACK=false. Applied to both the sync (rest.py) and async (async_rest.py) clients; added unit tests for both. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
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.
Problem
Customers running workers behind proxies/load balancers that mishandle long-lived HTTP/2 (observed across GCP Cloud Run and AWS deployments) report workers that stop polling — queues back up, last-poll time drifts to tens of seconds, with no CPU or memory spike.
Root cause: HTTP/2 is enabled by default (
CONDUCTOR_HTTP2_ENABLED=true). When a long-lived h2 connection produces a protocol-level error (GOAWAY storm, stale keep-alive reset), the existing self-healing reset rebuilds another HTTP/2 client that hits the same wall. The poll loop can cyclereset → fail → reset, and because the worker only polls when it has free capacity, stalled requests pin slots and polling effectively halts.Fix
On
ProtocolError/ReadError/WriteError, if HTTP/2 is currently enabled, the connection reset now downgrades to HTTP/1.1 for the remainder of the process (sticky) instead of rebuilding HTTP/2. This breaks the failure cycle while keeping the worker self-healing — no process restart required.CONDUCTOR_HTTP2_AUTO_FALLBACK=falsekeeps retrying on HTTP/2.rest.py,TaskRunner) and async (async_rest.py,AsyncTaskRunner) clients. A one-time WARNING is logged when the downgrade happens.Tests
tests/unit/api_client/test_rest_client.py— downgrade-on-protocol-error and fallback-disabled cases.tests/unit/api_client/test_async_rest_client.py— new file, same coverage for the async client.All 17 tests in the two files pass.
Notes / scope
sleep(attempt*10)) runs while holding a worker slot, which can also starve polling regardless of transport — not addressed here.lease_extend/ memory-leak fixes are already shipped (LeaseManager, 1.3.11); this PR is only the HTTP/2 piece.🤖 Generated with Claude Code