Repository navigation
Kill memtier's own connections, first thing, in the CLIENT KILL tests (#682) - #756
Conversation
e017a6c to
85669f4
Compare
|
🤖 Automated first-pass review — a human maintainer's review is still required before merge. Thanks for this. Starting the first kill on the first
The core fix looks solid to me. I'd mainly want the scope/description sorted out and the cluster runs confirmed before this merges. |
85669f4 to
e1659f5
Compare
|
Thanks. Replies point by point to the review of 00:26:54Z:
|
test_dropped_transaction_requests_do_not_stall_requests_run failed on fast runners with "no CLIENT KILL found a memtier connection": the kill loop in _run_transaction_with_kills slept kill_interval (0.3s) before its first CLIENT KILL, and a 30000-request run can end inside that window. Nothing was killed, so the test checked nothing. The loop now polls INFO commandstats until the first MULTI arrives and kills straight away, then every kill_interval. A run can no longer end before the first wave, however fast the runner. The test also asserts that a kill dropped at least one in-flight transaction request (transaction-not-replayed), so it fails loudly if the scenario it guards is ever not reached. The other callers of the helper use --test-time and keep working; their first wave just comes earlier. Fixes #682 Co-Authored-By: Claude Opus 5.5 <[email protected]>
… tests Three --requests tests in test_reconnections.py slept before their first kill, and memtier finished well inside that sleep, so they passed without testing anything: - test_reconnect_on_connection_kill (2s sleep, 5000 requests): its only kill hit a harness connection, and its "reconnect" check matched the results path in stderr. - test_reconnect_unlimited_no_spurious_thread_restart (1s sleep): no memtier connection was killed; it only checked a message was absent. - test_reconnect_disabled_by_default (1s sleep): the kill hit an RLTest connection after memtier had exited. include.py gets helpers that snapshot the harness's client IDs before memtier starts, then wait for memtier's clients and kill only those. The tests kill on each connect and reconnect, have longer runs, and assert on what memtier itself reports: "attempting reconnection" and "Reconnection successful" in its stderr, Connection Errors in mb.json, and for the disabled case "--reconnect-on-error is not set" and a non-zero exit. _run_transaction_with_kills uses the same helpers, so its kill count no longer includes harness clients. Its INFO poll is guarded, and the --requests stall test stops killing after 10 waves. Before that cap, a cluster run was killed for the whole 60s window, close to the 90s timeout, and memtier now has to finish the run once the kills stop. Fixes #682 Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Count only TYPE normal clients as memtier's, so a replica link that connects after the snapshot is never killed. - Document that harness_client_ids assumes no harness connection opens after the snapshot (kills on the calling thread, one pooled connection). - Log a CLIENT LIST failure once instead of silently polling for 30s, and log only the first failed INFO poll in _run_transaction_with_kills. - Drop kill_memtier_clients' unused limit parameter. - test_reconnect_cluster_mode_no_assertion kills and counts only memtier's clients too. - test_reconnect_unlimited_no_spurious_thread_restart: say plainly that CLIENT KILL does not reproduce the #391 duplicate-callback storm; the test covers the unlimited-reconnect path, not that guard. Refs #682 Co-Authored-By: Claude Opus 5.5 <[email protected]>
TSAN OSS-CLUSTER failed test_dropped_transaction_requests_do_not_stall_ requests_run with "no in-flight transaction request was dropped on a kill": 32 memtier clients killed, 0 failed-keys rows. With a slow build, the 10 capped waves, 0.3s apart, landed while the connections were idle or still reconnecting (1s delay), so none of them had a request in flight. _run_transaction_with_kills now waits, before each wave, until memtier has sent a MULTI since the previous wave, so a wave never lands while every connection is reconnecting. With until_dropped, the waves keep going until a transaction-not-replayed row shows up in the failed-keys file, which memtier flushes per row. The stall test uses until_dropped with max_waves=50 (and the helper's 60s window) as the safety cap, and memtier must then still complete the run. The test_reconnections.py kill tests now pass --authenticate when the env has a password (e.g. --oss_password), as test_cluster_ask_asking does. Without it, test_reconnect_cluster_mode_no_assertion killed 0 memtier clients: it had only passed because CLIENT KILL TYPE normal also killed the harness's own connections. Refs #682 Co-Authored-By: Claude Opus 5.5 <[email protected]>
e1659f5 to
e67a529
Compare
Problem
test_retry_on_error.py::test_dropped_transaction_requests_do_not_stall_requests_runsometimes fails on fast runners withno CLIENT KILL found a memtier connection(0 >= 1). On 2026-10-16 it failed CI on two open PRs attest_retry_on_error.py:1127: #752 ("Test Single Endpoint: TCP Plaintext") and #666 (coverage-ubuntu).Review found the same flaw in three more
--requeststests intest_reconnections.py. They sleep before their first kill, memtier is already done by then, and they pass without testing anything:test_reconnect_on_connection_kill: 5000 requests and a 2 s sleep. Its only kill hit a harness connection, and its"reconnect" in stderrcheck matched the results path (.../test_reconnect_on_connection_kill/mb.json).test_reconnect_unlimited_no_spurious_thread_restart: 5000 requests and a 1 s sleep. No memtier connection was killed, and it only checked that a message was absent.test_reconnect_disabled_by_default: 10000 requests and a 1 s sleep. The kill hit an RLTest connection after memtier had exited.Root cause
Each kill loop slept a fixed time before its first
CLIENT KILL, and a--requestsrun can end inside that window. The kills also targeted everynormalclient (TYPE normal, or "any client not running CLIENT"), so kills of harness connections were counted as hits.Fix (test only)
tests/include.pygetsharness_client_ids,memtier_client_ids,wait_for_memtier_clientsandkill_memtier_clients. Before memtier starts, they snapshot the IDs of the clients already on each server. They then pollCLIENT LISTevery 1 ms and kill only the new clients, which are memtier's, and count only those._run_transaction_with_killskills as soon as the firstMULTIarrives (theINFOpoll is now inside try/except), then everykill_interval, and kills and counts only memtier's clients. The--requestsstall test stops after 10 waves (max_waves) and then has to finish the run. Before this, a cluster run was killed for the helper's whole 60 s window (62-64 s against a 90 s timeout). It now takes about 8 s. The test also asserts that a kill dropped at least one in-flight request (transaction-not-replayed).test_reconnections.pytests now use_run_with_memtier_kills. Each wave waits for memtier's clients (the first connect, then each reconnect) and kills them straight away. Runs are longer: 20000 requests per client for the two reconnect tests, and 100000 for the disabled-by-default test. The assertions check what memtier itself reports, not the results path:attempting reconnectionandReconnection successfulin memtier's stderrConnection Errors>= 1 in mb.json--reconnect-on-error is not setand a non-zero exitOther
CLIENT KILLloops I checked. None of them ends before its kills:--test-timeruns that outlast their waves: the reconnect-interval test in test_reconnections.py, test_read_preference_failover.py, test_cluster_transaction.py,_replay_churn_run,test_dropped_replays_do_not_stall_client, test_prometheus.py F17 (--test-time=5, kills every 0.5 s), and test_json_output_integrity.py's run-count killer (--run-count=3with--test-time=2, kills every 0.25 s).--test-timerun).test_reconnect_cluster_mode_no_assertion(--test-time=10) now useskill_memtier_clientstoo, so itskill_countno longer includes harness kills.Test evidence (local, redis 8.6.0)
Each batch ran 8-10 RLTest copies in parallel. "pinned" means the whole RLTest tree (python, redis, memtier) was taskset to one core.
Stall test, before vs after. On this host the real run takes about 1 s, so the old code never failed it here (0/96 standalone, 0/8 cluster). A shorter run copies a fast CI runner:
no CLIENT KILL found.Changed reconnect tests, head:
Since the third commit (e1659f5: memtier clients are now
TYPE normalonly,CLIENT LISTandINFOpoll failures are logged once, the deadlimitparameter is gone), every changed test passes again: 3 standalone runs (2 plain, 1 TLS) and 1 cluster run each, withtest_reconnect_cluster_mode_no_assertionpassing 2/2 on cluster.test_transaction_requests_are_not_retriedhas 0-ERRreplies against 40 kills standalone and 61-76 on cluster, so the tightererrors <= killedbound holds.The other helper users (
test_transaction_requests_are_not_retried,test_transaction_drops_not_logged_without_retry,test_transaction_lost_multi_is_not_continued) pass 2/2 standalone and 1/1 cluster.Mutants (each built from this tree):
if (false && reconnect_on_error ...)inattempt_reconnect)debugPrintMemtierOnErrorcall then raises on a missing redis log, which is a quirk of my runner)reconnect_on_erroron by defaultabandon_requests()removed fromdisconnect()(the #615 accounting)m_reconnectingearly return)CLIENT KILLdoes not produce the duplicate error callbacks this guard is for, on either version. The docstring now says so: the test covers the unlimited-reconnect path, not the #391 storm.Fourth commit (e67a529): TSan cluster flake and password envs
failed-keysrows. The cause was the 10-wave cap. In a slow build, its waves (0.3 s apart) landed while the connections were idle or still reconnecting (1 s delay)._run_transaction_with_killsnow waits until memtier has sent aMULTIsince the previous wave. Withuntil_dropped, it keeps killing until atransaction-not-replayedrow appears in--failed-keys-file, which memtier flushes per row. The safety cap ismax_waves=50plus the helper's 60 s window. memtier must still complete the run once the kills stop.--enable-thread-sanitizer, undersetarch -R):abandon_requestsmutant is still caught: 3/3 standalone and 2/2 cluster.test_reconnections.pykill tests now pass--authenticatewhen the env has a password, astest_cluster_ask_askingdoes. Under--oss_password, the previous head'stest_reconnect_cluster_mode_no_assertionkilled 0 memtier clients and failed. It now passes (48 kills), and so do the other three tests, standalone and on cluster.Affected versions
Test suite and CI only; release binaries are not affected. The stall test came in with 013cb85 (#615), and
git tag --contains 013cb85is empty, so no release tag has it (latest is 2.5.2). The threetest_reconnections.pytests have been vacuous on fast runners since they were added.Fixes #682. This also covers item 2 of #740 (the same failure seen on the coverage job).
🤖 Generated with Claude Code
Note
Low Risk
Test harness and CI only; no production or memtier binary behavior changes.
Overview
Fixes flaky and sometimes vacuous CLIENT KILL integration tests by targeting only memtier’s Redis clients and killing as soon as workload is visible, instead of sleeping then blasting
TYPE normal.tests/include.pyadds shared helpers: snapshot harness client IDs before memtier starts (harness_client_ids), poll for new normal clients (memtier_client_ids/wait_for_memtier_clients), andCLIENT KILL ID … SKIPME yesonly those (kill_memtier_clients).tests/test_reconnections.pyreplaces background killer threads and fixed delays with_run_with_memtier_kills(wait-for-client then kill per wave), optional--authenticatevia_add_auth_args, longer--requestsruns, and assertions on memtier stderr (attempting reconnection,Reconnection successful) andmb.jsonConnection Errors. Cluster regression test counts kills via the new helpers.tests/test_retry_on_error.pyupdates_run_transaction_with_killsto use the same memtier-only kills, trigger the first wave whenMULTIappears (not afterkill_interval), and addsmax_waves/until_droppedso the stall test stops after a real drop instead of killing for ~60s on cluster.Reviewed by Cursor Bugbot for commit e67a529. Bugbot is set up for automated code reviews on this repo. Configure here.