Skip to content

Treat ordinary workload errors as connection progress - #788

Merged
fcostaoliveira merged 2 commits into
masterfrom
codex/fix686-workload-error-progress-20261017
Oct 18, 2026
Merged

fcostaoliveira merged 2 commits into
masterfrom
codex/fix686-workload-error-progress-20261017

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

An error-only workload is aborted as a connection-stage failure even when setup succeeds and the server continuously answers requests. Ordinary ERR, READONLY, NOPERM and OOM replies never mark steady state. They also fail to reset the reconnect-attempt budget after a recovered connection serves work.

Root cause

The workload-response branch accepts only non-error replies as connection progress. That rule was introduced to keep Redis wire-protocol rejection/reconnect loops bounded, but also catches legitimate command rejections.

Fix

Count ordinary parsed workload replies as connection progress, including errors claimed for retry, and reset the connection’s reconnect budget. Preserve Redis protocol-error, max-clients (including the cluster variant), and protected-mode rejection prefixes: Redis closes after these failures, so they must not disable the startup supervisor or reset the reconnect budget. Their no-AUTH greetings can be mistaken for the first pipelined workload reply. Setup-command rejection and local parser-failure paths are unchanged.

Logical completion/error/retry accounting is unchanged. In particular, unlimited request-count retries can continue indefinitely against permanent rejection; help, man page and README now explicitly recommend finite retries or a timed workload. This does not change the retry policy discussed in #734.

Tests

  • All eight focused tests pass on the final implementation: ordinary error-only runs, RESP3 setup, reconnect recovery, protocol/accept-time rejection controls, failed setup/parser/silent peers, logical retry accounting, and run-count supervision reset. They check JSON, failed-key rows and wire counts.
  • Three focused regressions fail on base cae16bf6; the added accept-time test also fails against the initial implementation before the corresponding guards.
  • Real Redis 8.6: 16 error-only cases (ERR/NOPERM/OOM/READONLY × plaintext/TLS × RESP2/RESP3) complete the requested three-second workload with JSON count = failed-key rows = server error count (60 or 61). Two base ERR controls abort at the setup deadline. These were run before the final accept-time-only guard extension; ordinary-error focused tests also pass afterward.
  • Actual Redis maxclients=1: initial implementation incorrectly resets the reconnect budget and exits 0; final implementation rejects exactly two connections, never resets the budget, and exits 1 with --max-reconnect-attempts=1.
  • Memcache meta and binary scripted error-only workloads fail on base and complete after the fix; the legacy text parser's existing error rejection remains unchanged.
  • All 34 existing setup/slot-map tests and all 15 unit programs pass. Build, make format and make format-check pass.
  • Exact-head CI and seven independent reviews remain gates.

Affected versions

2.4.0 through 2.5.2 and master. Introduced by 2e8869effe8f14f61c083b410d66b90ae06d0f4e (#431); release applicability is verified from source history. The issue records a 2.5.2 runtime reproduction, and this PR independently reproduces on its current master base. The reconnect-reset placement arrived with ee757e71 (#456).

Fixes #686

🤖 Generated with Claude Code


Note

Medium Risk
Changes when connections are considered steady-state and how reconnect limits reset in shard_connection::process_response, which affects benchmark abort/timeout behavior under error-heavy workloads.

Overview
Ordinary workload error replies (e.g. -ERR, -OOM, -READONLY) now count as connection progress after setup: they mark steady state, disarm the startup supervisor, and reset the per-connection reconnect-attempt budget. Previously only successful replies did, so error-only workloads could hit --connection-stage-timeout and never recover reconnect limits.

Redis accept-time / wire rejections stay startup failures via is_redis_connection_rejection() (-ERR Protocol error:, max-clients, protected-mode -DENIED). Those still report connection-stage failure and do not reset reconnect budgets.

Docs (README, man page, --help) now warn that with --requests and unlimited --max-retries, perpetual command rejections can run indefinitely because workload errors are progress and --connection-stage-timeout does not cap retries.

Adds tests/test_workload_error_progress.py covering steady-state on ordinary errors, protocol vs setup failures, reconnect budget reset, retry accounting, and run-count reset behavior.

Reviewed by Cursor Bugbot for commit cff19c5. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

🤖 Automated first-pass review — a human maintainer's review is still required before merge.

Thanks for this. I went through the shard_connection.cpp change and the new test module. The core idea makes sense to me: a parsed workload reply proves setup finished, whatever it says. The tests are thorough and check JSON and failed-keys rows, not just wire counts. A few questions below.

  1. Behavior change for --requests + --retry-on-error. Default --max-retries is -1. Before this change, a run against a server that rejects every request stopped at --connection-stage-timeout with exit 2. Now it runs forever. The help text, man page and README say so, but I'm not sure that's enough for a change in default behavior. Did you consider a less-breaking split? For example, only a final reply (not claimed for retry) would count as progress. Ordinary errors without retry would still reach steady state (the --connection-stage-timeout aborts a healthy run when every reply is an error (e.g. -READONLY, -ERR), reported as connection-stage failures #686 case). Retries against a permanent rejection would stay under the stage timeout. I may be missing why test_retries_are_progress_but_not_logical_completions needs retries to outlive the setup deadline. If that's the point of the fix, a sentence on why the bounded alternative doesn't work would help, along with how this relates to --requests --retry-on-error with the default unlimited --max-retries never ends when every request keeps failing - intended? #734.

  2. Matching on server message text. is_redis_connection_rejection() matches -ERR max number of clients and -DENIED Redis is running in protected mode by prefix. If a fork or a future Redis version words these differently (I think Valkey's protected-mode message doesn't start with "Redis"), the reply falls through and counts as progress. The reconnect budget then resets on every attempt, and we're back in the unbounded CLI-fuzz follow-ups: 17 crash/hang classes (11 share connection-stage retry-loop root cause) #426-style loop this carve-out is meant to prevent. I wonder if a structural signal would be more robust than message text, e.g. "server closed right after the first reply on a fresh connection". If prefix matching is the pragmatic choice, maybe just note the assumption in the comment.

  3. Error attribution for ordinary errors. Ordinary workload errors no longer reach report_connection_stage_failure(). So if a connection later aborts for some other reason, the last server error: ... won't be available for the abort message. That's probably fine, just checking it's intended.

  4. The PR description only mentions the -ERR Protocol error: carve-out. The second commit also adds the max-clients and protected-mode cases, so it would be good to update the body so the history is accurate.

  5. Nitpicking: several assertions rely on wall-clock time (elapsed >= 3, assertLess(elapsed, 8), first_success - first_request >= 3). With CI running at PARALLELISM=2, it may be worth leaving some extra headroom so this doesn't become the next flake.

The fix itself looks right to me. I'd mainly want the unlimited-retry question answered before this merges, since it changes what an existing flag combination does by default. A second look from whoever owns the connection-stage supervisor would also help.

(would file this as a comment, not a formal block)

@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

The max-clients/protected-mode concern was valid. Redis’s networking implementation sends those errors on accept and closes; the cluster max-clients variant has different wording too. Commit cff19c5 preserves these known rejection prefixes alongside -ERR Protocol error:. New no-AUTH greeting controls cover all three accept-time messages with startup timeout and finite reconnect budgets. A normal -DENIED command-error control still counts as workload progress.

An actual private Redis maxclients=1 control reproduces the issue in the initial implementation: it resets the reconnect budget three times and exits 0. The final code sees two rejections, never resets the budget, and exits 1 with max-reconnect-attempts=1. The complete focused suite passes 8/8, including run-count reset and the malformed-frame control. All 16 real Redis ERR/NOPERM/OOM/READONLY plaintext/TLS/RESP2/RESP3 combinations complete with JSON count = failed rows = server errors; the PR body now includes completed results and validation provenance.

Ordinary LOADING/MASTERDOWN/CLUSTERDOWN responses do count as command rejections, with unchanged logical request/error/retry accounting. The README/help/man note that unlimited retries with --requests can continue indefinitely; this is not a new retry policy. Timing guards leave a seven-second margin above the one-second startup deadline and every child has a 20-second outer bound. We retain the narrow rejection classification rather than delaying all workload progress until a later socket event, which would alter normal error-only workloads and still could not guarantee the server remains connected.

@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

Counting only final replies would preserve the same misclassification for a healthy connection that is serving retriable command rejections. It would also leave the outcome dependent on whether one earlier request happened to succeed: one OK already disarms the run-wide supervisor, after which the same unlimited retry workload has no setup-time bound. The supervisor is for establishing a working connection, not an implicit per-request retry deadline. A parsed ordinary error proves that progress, while logical completion still occurs only on success or exhaustion. The delayed-recovery test demonstrates that distinction: replies continue beyond setup timeout, then exactly four logical requests complete when the peer accepts them.

The default -1 retry policy and its request-count consequences belong to #734; changing that policy/default or adding a retry deadline needs its own decision. This fix removes the accidental startup deadline and documents the consequence explicitly, with finite --max-retries or --test-time as the existing bounded controls. It does not claim an all-error workload is successful at the command level: failed-key rows, errors and logical totals remain accounted.

The rejection prefixes intentionally follow the known Redis networking implementation, not an exhaustive promise about future versions or forks. Broadly excluding every DENIED/ERR status would recreate the ordinary-command problem; inferring rejection from a later close cannot reliably undo the run-wide steady-state latch once other callbacks/connections have progressed. The known Redis protocol, max-clients and protected-mode paths have explicit controls, including real maxclients behavior. Different server wording would need its own verified classifier/control.

Ordinary workload errors remain logged and counted; they intentionally stop being attributed to setup. The PR body has been updated to include all three rejection categories and completed measurements. Eight-second failure guards leave seven seconds above the one-second setup deadline, with a 20-second subprocess safety bound; successful duration checks use the configured three-second lower bound, not an upper throughput/timing expectation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--connection-stage-timeout aborts a healthy run when every reply is an error (e.g. -READONLY, -ERR), reported as connection-stage failures

1 participant