Skip to content

Cap late interrupted timed runs at the configured deadline - #789

Merged
fcostaoliveira merged 3 commits into
masterfrom
codex/fix747-late-interrupt-duration-20261018
Oct 23, 2026
Merged

fcostaoliveira merged 3 commits into
masterfrom
codex/fix747-late-interrupt-duration-20261018

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Interrupting a timed workload while its last reply is stalled charges the drain wait to its reported duration. With 20 completed operations, --test-time=1 interrupted after about 3.2 seconds reports 3,196 ms and 6.26 ops/sec instead of 1,000 ms and 20 ops/sec.

Root cause

The post-join interrupt finalizer uses the captured interrupt timestamp without the upper deadline bound applied by normal timed finalization.

Fix

Cap an already-started timed client's interrupt timestamp at its statistics start plus --test-time. Preserve the existing lower bound and already-finalized guard. Early interrupts, request-count runs, never-started clients, and staircase's shared start retain their semantics. Compare elapsed microseconds before constructing the deadline so very large accepted durations cannot overflow Winsock's 32-bit seconds during early interruption. A late interrupt still reports Interrupted: true: the user stopped the drain.

Tests

  • Paired private RESP peer, exactly 20 completed SETs followed by one stalled reply: on base 9ddccaac1136c41e91342a590f0eaceeddde818d, late interrupts of both one- and two-second tests report 3,196 ms / 6.26 ops/sec. With this change they report 1,000 ms / 20 ops/sec and 2,000 ms / 10 ops/sec. All exit 0 with count 20.
  • Early two-second interrupt: 444 ms before, 446 ms after. Request-count interrupt: 3,196 ms both. Natural one-second drain expiry: 1,000 ms / 20 ops/sec both, with Interrupted: false.
  • Three new integration tests pass; the late-interrupt test fails against the unchanged base while both controls pass.
  • Exact timestamp unit cases cover before-start, early, exact deadline, deadline plus one microsecond, late drain, never-started, already-ended, staircase, request-count finalization, and early interruption with UINT_MAX test time.
  • Removing the cap makes the unit checks for deadline plus one microsecond, late drain, and staircase fail; restoring it passes. Existing real Redis stalled-server shutdown, staircase shutdown, and never-reachable interrupt controls pass (3/3).
  • A 32-bit-seconds representation probe reproduces the initial Windows overflow at 400,000,000 and UINT_MAX seconds and preserves the expected 500,000 microseconds after the correction. This is a representation proof; native Windows execution is left to CI.
  • All 16 make check tests pass; formatting and whitespace checks pass. POSIX signal integration tests skip Windows; the deterministic C++ timestamp cases run on all platforms.

Affected versions

Introduced by aa9edb8c01f74e6b67fef35a84e786fdcddf4c2f (#325), first released in 2.3.0. Affects 2.3.0 through 2.5.2 and current master before this fix.

Fixes #747.

🤖 Generated with Claude Code

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

Labels

None yet

Projects

None yet

1 participant