Skip to content

Update the cluster percentile warning when the topology grows - #878

Merged
fcostaoliveira merged 1 commit into
masterfrom
claude/percentile-bound-825
Oct 25, 2026
Merged

fcostaoliveira merged 1 commit into
masterfrom
claude/percentile-bound-825

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #825.

Problem

With --cluster-mode --rate-limiting, the up-front percentile warning (#386) took its sample bound from the first committed topology only. Since #799 a run can start on a partial slot map, and when the map heals memtier opens more endpoint connections, each with its own rate limit, so the run can record more samples than the warning said it could.

Reproduction

3-primary OSS cluster with cluster-require-full-coverage no, slots 10923-16383 removed and then restored mid-run, -t 1 -c 1 --rate-limiting 800 --test-time 6 --print-percentiles 99.99:

run warning samples
master, restored at 1 s p99.99 needs at least 10000 latency samples, but this run records at most about 9664, so it will not be resolved. 10187: over the bound, and p99.99 was resolved
this PR, restored at 1 s the same first warning, then the cluster topology grew to 3 rate-limited connections, so the percentile sample bounds above are raised: and p99.99 ... may now record up to about 14496, so it may be resolved. 11127

Change

  • Fan-out: the cluster client now publishes the largest rate-limited connection count committed so far, not just the first. It is written once per topology commit under the existing topology-summary mutex, never per request.
  • Warning updates: the main thread's once-a-second check remembers what it said about each percentile, for the run and for the window. When the fan-out grows, it prints one header line, then either the warning again with the raised bound or a "may now be resolved" note. A --requests bound doesn't depend on connections, so it isn't repeated.
  • Output: no JSON or report field carries the bound, and the window's * marker already uses each row's real count. The progress-line newline is now printed only when there is a warning; master printed it even when there was nothing to warn about.
  • README: the cluster-mode sentence about the warning is extended.

Rewording the message to "with the initial topology" was the smaller option. I didn't take it because the run would then still say a percentile "will not be resolved" when it is, with nothing to correct it.

Tests

  • New tests: two in tests/test_cluster_unowned_slots.py, built on the Keep cluster workloads progressing across partial maps and primary reconnects #799 fake cluster.
    • The cluster heals only after memtier has printed its first warnings, so the update is deterministic.
    • They check the exact warning lines, the * mark on every window row, and that a --requests warning isn't repeated.
    • Both fail on master and passed 5/5 with the fix, and each of 7 mutants of the fix fails at least one of them.
  • Related tests:
    • That file plus test_realtime_latencies.py: 34/34 standalone.
    • test_realtime_latencies.py on a 3-shard cluster: 9/9.
    • make check: 18/18.
  • Merge check: merged onto Back off CLUSTERDOWN topology refreshes per client #877 (CLUSTERDOWN refresh backoff, same refresh path), the unowned-slots file passes 26/26.

Affected versions

Introduced in 9bf3960 (#386), which is unreleased. It interacts with #799 (4018396), also unreleased.

🤖 Generated with Claude Code


Note

Low Risk
Changes stderr warnings and cluster connection accounting for percentile checks only; benchmark routing, rate limiting, and reported latencies are unchanged.

Overview
Fixes misleading unresolvable percentile warnings in cluster mode when a partial slot map heals and memtier opens more rate-limited endpoint connections (#825).

The cluster client now keeps the largest rate-limited connection fan-out seen across topology commits (not only the first). The main progress loop re-runs warn_unresolvable_percentiles whenever that count grows: it prints a short header, re-issues warnings with raised bounds, or notes when a percentile may now be resolvable. --requests bounds are unchanged by connection growth, so those run-level warnings are not repeated. Progress-line newline handling is tightened so it only runs when something is actually printed.

README documents the follow-up warnings. Integration tests simulate a healing partial CLUSTER SLOTS map and assert the exact warning/note sequence and window * markers.

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

With --cluster-mode --rate-limiting, the up-front percentile warning
(#386) took its sample bound from the first committed topology only.
Since #799 a run can start on a partial slot map, and when the map heals
memtier opens more endpoint connections, each with its own rate limit.
On a 3-primary cluster with one primary's slots removed and restored 1 s
into a 6 s run at 800 req/s, memtier warned that p99.99 "records at most
about 9664" and "will not be resolved", then recorded 10187 samples and
resolved it. The window warning's promise that the win<N>s row marks a
percentile with '*' could break the same way.

The cluster client now publishes the largest fan-out it has committed,
not the first one. The main thread checks it once per tick, as before,
and when it grows prints the warnings again with the raised bounds,
under a "the cluster topology grew to N rate-limited connections" line.
A raised bound only removes warnings, so an update revisits only the
percentiles already warned about: each gets the new bound, or a note
that it may now be resolved (by the run or by the window). A run
warning that becomes a window warning gets both. A --requests bound does
not depend on the connections and is not repeated. The update is printed
once per growth, on the main thread's tick and not on the request path,
and the last tick runs after the workers end, so it sees the final
topology. The fan-out is written only under the topology summary's
mutex, so the compare-and-store does not race between workers. The
warning is stderr-only; no JSON or report field carries the bound.

Rewording the message to "with the initial topology" would document
the gap, but the run could still warn that a percentile cannot be
resolved when it can, with nothing to correct it.

The two tests run a fake cluster that heals only after memtier has
printed its first warnings, so the update is deterministic. They check
the exact warning lines, that every win1s row marks the percentiles
still warned about, and that a --requests bound is not repeated.

Fixes #825

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

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 update logic in warn_unresolvable_percentiles and the print_topology_summary change, and it looks right to me. The fan-out only goes up and is written under s_mtx, so any overcount can only make the bound looser. Skipping the --requests run warning makes sense because run_max comes from requests * clients there and doesn't depend on rate_conns. The pw_run → pw_window case prints both lines, as the description says it should.

Both tests fail on master, and they wait until the first warnings have printed before the cluster heals, so they don't rely on sleeps. That's the kind of fails-then-passes regression test that was already accepted in #364. Since this only touches stderr and doesn't change any JSON or report field, I don't see a compatibility problem. Printing the trailing newline only when there's a warning is a small improvement.

Nitpicking: when an update only withdraws warnings (every revisited percentile turns into a note:), the header still starts with warning:, even though nothing below it is a warning anymore. I wonder if the prefix should depend on whether any warning: p... line follows, or if that's not worth the extra branch.

Since this sits in the cluster refresh path next to #877, it may be worth a second look from whoever owns cluster routing. Otherwise this looks good to merge from my side.

(would file this as an approval-leaning comment, not a block)

@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

Review summary for c8c4af1. All 7 lenses approve (semantics, output, tests, lifecycle, interactions, maintainability, build).

  • CI: 15,903 tests with 0 failed, and every per-test result matches master. The 2 new tests pass in all 6 standalone plaintext cells. Like the rest of the file, they skip in TLS and cluster cells.
  • Real cluster (3 primaries, healed mid-run): master recorded 1,002 samples after promising "at most about 604". With this PR the bound updates once per growth, even when the topology flips 8 times.
  • TSan: no report in the new code.
  • Mutants: 12 of 14 are caught.

On the warning: prefix: I kept it, because the header amends earlier warnings and the lines under it say per percentile whether each one is still a warning (warning:) or now a note:.

@fcostaoliveira
fcostaoliveira merged commit 29f63de into master Oct 25, 2026
146 checks passed
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.

Cluster percentile-warning bound uses the first topology only and is exceeded when a partial map heals

1 participant