Repository navigation
Add --request-timeout to fail connections whose requests are never answered - #903
Conversation
…nswered A server that completes the TCP handshake but never serves the connection (a proxy that stopped calling accept() while throttling) left every request waiting for the rest of the run: nothing errors, so --reconnect-on-error never fired, and --connection-timeout only bounds connect(). --request-timeout=SECS (0 = off, the default) arms one watchdog timer per connection. When it fires it checks only the oldest outstanding request, so replies cost no timer operation. An overdue request is treated as a connection error: logged, counted, and reconnected under --reconnect-on-error (otherwise the thread ends, as for any lost connection). Fixes redis#902 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
🤖 Automated first-pass review — a human maintainer's review is still required before merge. Thanks for this. I read through the watchdog and the tests, and the design looks sound to me. Having reply progress drive the timer, instead of per-request timestamps, avoids the pipelined-batch false positive, and the hot path stays at a branch plus a store. A few comments:
The option checklist is complete (enum, (would file this as a comment, not a formal block) |
The first version timed the oldest request from its wall-clock send time. Requests pipelined in one batch share that time, so a slow server that kept answering could be timed out, and a wall-clock step could time out every healthy connection. The watchdog now treats any reply data (or a request pushed to an idle pipeline) as progress: a window with requests outstanding and no progress is a timeout. No clocks and no per-request timestamps are involved; the hot path costs one store. Detection takes SECS to 2*SECS after the last reply. Also: skip the tests in the TLS and cluster CI cells, add a pipelined slow server test, widen the timing margins, and document that setup commands are covered. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Address review: the config comment and stderr line described the first (per-request) version. Add a cluster-mode test where the node stalls the first data request, and note that push_req() must test the pipeline before it counts the new request. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Address review: say plainly that it is not a per-request deadline (a server that keeps sending data never trips it), list the interactions (blocking commands, --connection-stage-timeout, --rate-limiting, --retry-on-error, exit code, the --request abbreviation), and reject values a 32-bit time_t cannot hold. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The macos-14 runner pool is no longer provisioned: both jobs are cancelled before any step runs with "The configuration 'macos-14-arm64-us-default' is not supported". Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Fixes #902.
A server that completes the TCP handshake but never serves the connection (e.g. a proxy that stopped calling
accept()while throttling) leaves every request on it waiting for the whole run. Nothing errors, so--reconnect-on-errornever fires, and--connection-timeoutonly boundsconnect().--request-timeout=SECS(a stall timeout, not a per-request deadline: a server that keeps sending data never trips it; values above INT_MAX are rejected) (0 = off, the default; behaviour unchanged unless set):event_add/event_delper op. A connection that never answers is detected after SECS; one that goes silent after answering, within SECS to 2*SECS.Request timeout: no reply data for at least N seconds (M requests outstanding).on stderr, counted, and reconnected under--reconnect-on-error(otherwise the thread ends and the run fails, as for any lost connection). Setup commands (AUTH/HELLO/...) are covered too.getopt_longprefix matching means the abbreviation--request(formerly unique for--requests) is now ambiguous; the full names are unaffected.configuration,--help, man page, README, bash completion, CLI validation tests and the CLI fuzzer.Not in this PR: the issue's second proposal (exit non-zero when a run completes 0 ops) — a separate behaviour change.
Tests (
tests/test_request_timeout.py): non-accepting listener with and without--reconnect-on-error; a slow-but-answering server, a slow pipelined server (--pipeline=16), and an idle connection (no false timeout); skipped in the TLS/cluster cells; JSON config. Built and run on a c7i.16xlarge Ubuntu 24.04 VM.🤖 Generated with Claude Code
Note
Medium Risk
Touches core
shard_connectionreconnect and timer paths; misconfiguration could end runs or reconnect more often than intended, but default 0 preserves prior behavior.Overview
Adds
--request-timeout=SECS(default 0, off): when set, each connection gets a libevent stall watchdog—armed when work is pending, reset when reply data is read or a request wakes an idle pipeline—so peers that never answer after connect are treated like connection errors (logged, reconnect under--reconnect-on-error, else fail the run). Values aboveINT_MAXare rejected for timer safety.Surfaces the option in help, man, README (including the
--request/--requestsambiguity note), bash completion, config dump, and JSON output.CI: legacy macOS OpenSSL 1.1 and 1.0.2 jobs move from
macos-14tomacos-15with an updated runner comment.Tests: new
tests/test_request_timeout.pyplus CLI fuzz and validation updates.Reviewed by Cursor Bugbot for commit dfbaa70. Bugbot is set up for automated code reviews on this repo. Configure here.