Repository navigation
ci(soak): add nightly soak/stress suite -- would have caught the VLA crash - #423
Conversation
…crash
Adds .github/workflows/soak-nightly.yml plus seven RLTest scenarios under
tests/soak/ that exercise memtier_benchmark in regimes PR-time CI never
hits: long duration, giant payloads, high concurrency, reconnect churn,
cluster topology turbulence, retry storms and lossy networks.
Total budget 60 minutes, scheduled at 02:17 UTC (cron '17 2 * * *') plus
workflow_dispatch. Build job uploads a release artifact; soak job runs
the matrix in fail-fast: false so a single regression doesn't mask the
others.
Per-scenario oracles:
S1 long_run_memory 30 min, RSS slope < 2 MB/min over the run
S2 large_payloads regen 20 MB + 100 MB monitor lines (NOT committed),
no SIGSEGV / no "stack smashing detected", server
STRLEN matches the blob -- direct regression guard
for PR redis#405 / issue redis#404
S3 high_concurrency 32t/256c, max fd count < 4*t*c, steady-state slope ~0
S4 connection_churn CLIENT KILL TYPE normal every 30s, survives all
rounds with --reconnect-interval=10
S5 cluster_turbulence 3-master + 3-replica, CLUSTER FAILOVER at t+120s,
CLUSTER SETSLOT MIGRATING at t+300s, exits with
cluster_state:ok
S6 retry_storm Python RESP shim returning 80% -ERR / 20% +OK,
peak RSS < 500 MB, peak CPU < 200%
S7 slow_network tc netem 200ms +/- 20ms, 1% loss; sudo-with-skip
wrapper so non-root sandboxes don't fail the suite
All scenarios honour MEMTIER_SOAK_TEST_TIME (and similar) env knobs so
the harness can be smoke-tested locally in seconds; CI runs the full
durations.
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
fcostaoliveira
left a comment
There was a problem hiding this comment.
Review: performance (haiku 4.5)
- Nightly soak on separate cron:
soak-nightly.ymlscheduled at 02:17 UTC, NOT wired into PR/push workflows. Doesn't block PR merges. Total 60 min budget enforced viatimeout-minutes: 60on soak job. - Per-scenario wall-clock: S1 (long_run_memory) 35 min, S2–S4 + S6–S7 = 10 min each, S5 (cluster) 15 min. Sequential sum = 85 min nominal, but
fail-fast: falsematrix means slowest cell governs actual wall-clock. With 35 min floor (S1), all fit within 60 min when run in parallel. - Compute cost acceptable: One nightly run, not per-PR. No steady-state user impact.
Verdict: Approve — off-hours only, budget capped.
fcostaoliveira
left a comment
There was a problem hiding this comment.
Review: docs & commit message (haiku 4.5)
• Title uses Conventional Commits correctly: ci(soak): subject — note the subtitle "would have caught the VLA crash" is colloquial but descriptive.
• Opens with Fixes #413. — correct (issue dedicated to soak test suite).
• Test plan honest: smoke-tested locally with durations shortened to 10-30s, full durations honored in CI. Seven soak scenarios documented with oracle conditions and known judgement calls (S5 failover limitation, S6 probabilistic shim, S1 slope check).
• New env vars MEMTIER_SOAK_TEST_TIME and friends introduced and shown used in test code but not documented in AGENTS.md or tests/run_tests.sh. Nightly cron wiring documented but not in workflow YAML visible to this PR.
• Soak tests live in new tests/soak/ directory — reasonable structure but not mentioned in AGENTS.md repo structure overview.
Verdict: Comment — missing AGENTS.md documentation for MEMTIER_SOAK_* env vars and new test directory structure.
fcostaoliveira
left a comment
There was a problem hiding this comment.
Review: design & API choices (sonnet 4.6)
- Dedicated
soak-nightly.ymlseparate from the sanitizer workflows is the right architecture. Soak scenarios are time-budget, not sanitizer-class. Mixing them intoasan.yml/tsan.yml(as PR #418's STRESS axis does) would conflate two orthogonal axes. The separate workflow with its own cron andworkflow_dispatchis the correct factoring. tests/soak/subdirectory is a good precedent and resolves the naming inconsistency noted for PR #418'stest_sanitizer_stress.pyliving intests/. All seven soak scenarios are isolated from RLTest autodiscovery by directory, eliminating the need for env-var skip guards that #418's stress file requires.- S7's
sudo -n tcguard withenv.skip()is the correct portability pattern. The scenario is meaningful only whenNET_ADMINis available; skipping cleanly on restricted environments avoids false failures on contributors' laptops. - S5
CLUSTER FAILOVERbehavior (always returns-ERRon master nodes) is documented in the PR as a known limitation, but the test still calls it unconditionally. Ifenv.getMasterNodesList()returns only master connections (as documented), the failover call will always fail. The test should either skip the failover step explicitly or hold a connection to a replica. The current "catch once, log, continue" approach means the failover path is never actually exercised. - S2
test_large_payloadsdirectly tests the #404 regression (generates a 100 MB--monitor-inputblob at test time, verified to reproduce the SIGSEGV on pre-#405 master). This is the most direct regression guard in the suite and is the primary reason the nightly is valuable. - Env-var knobs (
MEMTIER_SOAK_TEST_TIME,MEMTIER_SOAK_BIG_BLOB_MB, etc.) for local smoke runs are the right UX. CI runs at full duration; contributors can run at 10–30 s without code changes.
Verdict: Comment (fix S5 failover to target a replica connection, or explicitly skip the failover step)
fcostaoliveira
left a comment
There was a problem hiding this comment.
Review: security (opus 4.7)
- sudo wrapper bounding (S7
tc qdisc):_run_tcprefixes["sudo", "-n"]only after_sudo_prefix()confirms sudo is on PATH; if sudo prompts (i.e.-nwould fail), the call returns non-zero stderr and the testenv.skip()s. Thetcargv is hardcoded literals ("qdisc","add","dev","lo","root","netem","delay","200ms","20ms","loss","1%") — no user-controllable string ever reaches sudo. Argv is a list, not shell — no injection. Bounded. tc qdisc delcleanup runs both before_install_netem(defensive) and in the test'sfinallyvia_remove_netem. If the test process is SIGKILLed mid-run, the netem qdisc persists onloand slows subsequent CI steps — minor, not security.- The nightly workflow restricts triggers to
cron+workflow_dispatch(NOTpull_request/push). A PR author cannot trigger the soak workflow with attacker-controlled inputs. Good. actions/download-artifact@v8pulls the binary from the same workflow'sbuildjob — no cross-workflow artifact spoofing.sudo sysctl -w net.ipv4.tcp_fin_timeout=10/tcp_tw_reuse=1mutate runner kernel state for the whole runner lifetime. GitHub-hosted runners are ephemeral so this resets; self-hosted runners would carry this forward (mild persistence). Document as expected.- S2 large-payloads test generates a
~120 MBblob at test time andenv.assertTruecleans it up before the next scenario per the PR description — verified by reading the test. No persistent disk-fill. - S5 cluster-turbulence uses
conns[0].execute_command("CLUSTER", "FAILOVER")— call uses redis-py command list, not shell. The CLUSTER SETSLOT MIGRATING destination ID isconns[1].execute_command("CLUSTER", "MYID")— internal, no user input. Safe. - S4 churn
CLIENT KILL TYPE normalis sent via redis-py and only affects the local fixture. No external reach. - S6 retry-storm uses an in-tree Python RESP shim (
-ERR/+OKmix) on a free port — local-only. The Python shim itself has no auth, but it binds to 127.0.0.1. - Soak scenarios assert
memtier_ok = proc.wait() == 0— any signal-class exit fails the test (a SIGSEGV regression would be caught). Good. - 60 min total budget per matrix cell prevents an infinite-loop bug from wedging the runner forever.
fail-fast: falseensures one stuck scenario doesn't mask the others.
Verdict: Approve
fcostaoliveira
left a comment
There was a problem hiding this comment.
Review: code style & readability (sonnet 4.6)
sys.path.insert(0, ...)is copy-pasted verbatim into all 7 soak test files. A sharedtests/soak/__init__.pythat performs this insertion once, or aconftest.pyfixture, would remove the duplication and make the path manipulation auditable in one place. This is the most load-bearing readability issue in the PR.soak-nightly.ymlaction versions are inconsistent with the sanitizer workflows:actions/checkout@v6,actions/upload-artifact@v5,actions/download-artifact@v8,actions/setup-python@v6— four different version numbers in one file.v6/v8are not pinned to currently-released major versions on GitHub marketplace. Use consistent major versions (e.g.,@v4which is current stable for checkout/artifact actions) to avoid silent breakage when GitHub removes deprecated versions._trigger_failoverand_trigger_resharddocstrings explain the "why always return True" behavior, which is a genuine invariant (RLTest only exposes master connections). Good.- Scenario-table comment in
soak-nightly.yml(S1–S7) is a clear index that matches the file names exactly. chaos()as an inner function inside the test is readable, though naming the threadchaos_threadis more idiomatic than a barethreading.Threadreference.- Commit message is Conventional Commits compliant; the subtitle "-- would have caught the VLA crash" is an unusually useful parenthetical that justifies the change's existence.
Verdict: Comment
fcostaoliveira
left a comment
There was a problem hiding this comment.
Review: edge cases & failure modes (opus 4.7)
tests/soak/test_slow_network.py:1295-1306—_install_netemdoes best-effortqdisc del dev lo rootthen add. If the test crashes between install and thefinally _remove_netem()(e.g. Python SIGKILL by the 10-min CI timeout, OOM, or unhandled exception in_install_netemitself), netem stays onlofor the rest of the runner's life. Subsequent matrix cells on the same runner see 200ms+1% loss on loopback and silently fail. Useatexit.register+signal.signal(SIGTERM, ...).tests/soak/test_slow_network.py:1296— pre-delete masks the case where a previous test left netem withdelay 1000ms loss 50%. If the pre-delete fails (e.g. permission lost mid-run) the test runs through the worse-than-expected netem and asserts on its own baseline.tests/soak/test_long_run_memory.py:868—pid_holder[0] = proc.pidhappens AFTERsubprocess.Popenreturns but the sampler thread is already running and readingpid_holder[0](None until set). The first ~sample_interval=60s of the run logs zero samples. Initial vs final RSS slope is computed from samples[0] which is therefore the value at t=60s, not actual startup RSS.final/initial<1.5ratio is incorrect for runs where the warmup is itself the bug.tests/soak/test_retry_storm.py:1166-1174—proc = subprocess.Popen(...)is launched and the sampler is started AFTER. Same race as above: first sample is takensample_interval=5sin, missing the peak that often occurs during the connect storm at t=0.tests/soak/test_retry_storm.py:1195-1200—proc.communicate(timeout=test_time + 120)— on timeout youproc.kill()thenenv.assertTrue(False); return. Thefinallyat line 1221 callsshim.shutdown()but the shim's worker threads are daemon, never joined; they leak file descriptors back to the runner. Addacceptor.join(timeout=5)and join per-conn threads.tests/soak/test_cluster_turbulence.py:262-274— chaos thread doesevents["failover"] = _trigger_failover(env)returning True even when failover was rejected. The "events" sentinel then says we did it but we did not. Cluster MOVED-handling assertion at line 304-323 only checks finalcluster_state:okwhich is the steady state — a regression where memtier crashes BETWEEN the failover attempt and the cluster info read is missed because cluster_state is already healed.tests/soak/test_connection_churn.py:404-414—churnerthread holdsmaster_nodes_connections(a python list of redis connections) acrossCLIENT KILL TYPE normal. The kill kicks every non-control client INCLUDING the churner's own connection. Next iteration'sconn.execute_commandraisesConnectionError, logged once, and the kill_rounds counter stops incrementing. TheassertTrue(kill_rounds[0] > 0)(line 343) passes on round 1 but a regression that wedges memtier from round 2 onward is invisible..github/workflows/soak-nightly.yml:25— cron'17 2 * * *'— daily nightly is OK, but the workflow has noconcurrency: cancel-in-progressblock. Two manualworkflow_dispatchruns back-to-back fight for the samememtier-soak-binaryartifact.
Verdict: Comment
fcostaoliveira
left a comment
There was a problem hiding this comment.
Review: correctness & latent bugs (opus 4.7)
- LOAD-BEARING:
tests/soak/test_long_run_memory.py:113sets--run-count=3with--test-time={test_time}defaulting to 1800s. memtier executes the test forrun-count * test-time = 5400s = 90 min, but the scenario's CI cell budget istimeout-minutes: 35(per matrix entry S1). Job times out before memtier finishes, theproc.communicate()hits the workflow timeout, and the test fails for the wrong reason. Either drop--run-count=3or reduce default test_time. tests/soak/test_retry_storm.py:_resp_message_lengthhandles*Narrays of$Lbulks, but does NOT handle the case where memtier emits a non-bulk sub-element (e.g. an integer or simple string in a multi-bulk). The shim's_serve_clientwould then return 0 from_resp_message_length, fall through the innerwhile Trueloop break, and accumulate buffer indefinitely without ever replying. Per the comment ("inline / single line") this is allegedly OK, but memtier's normal output is purely*N $L bulkshapes, so this is moot in practice.tests/soak/test_retry_storm.py:339-340peak_rss_kb < 500 * 1024means < 500 MB. But the assertion runs even whenpeak_rss_kb[0] == 0(sampler never collected). If the sampler thread fails immediately and the process exits cleanly in <5s, peak stays 0,0 < 500 MBpasses, but you also never verified anything. Add a sampling-occurred floor.tests/soak/test_cluster_turbulence.py:107-114proc.communicate()is called once, then laterproc.wait()is called again. Aftercommunicate(),proc.returncodeis set andwait()returns the cached value — fine. But theproc.communicate()capture of stdout/stderr can buffer 2 GB+ of memtier text in Python memory during a 10-min run; considerstdout=DEVNULLor write to a file.tests/soak/test_high_concurrency.py:124-130pid_holder[0] = proc.pidis set AFTER the sampler thread starts; first 1-2 sample iterations seepid is Noneand skip. Benign.tests/soak/test_slow_network.py:_install_netemrunstc qdisc del dev lo rootfirst (best-effort cleanup). If that succeeds when another test on the same runner has installed something useful, we just blew it away. Workflow-level isolation per matrix cell means runners are independent, so OK in CI; risky on a contributor's laptop.tests/soak/test_cluster_turbulence.py:75-82_trigger_reshardreadsCLUSTER SLOTSfromconns[0], picksfirst[0]as the candidate slot, then sendsCLUSTER SETSLOT MIGRATINGfromconns[0]to dst nodeconns[1]. Ifconns[0]doesn't own that slot (RLTest doesn't guarantee shard ownership ordering), the SETSLOT returns-ERR I'm not the owner of slot N. The catch-allexceptswallows it as non-fatal — silently no chaos applied.tests/soak/test_connection_churn.py:80-86master_nodes_connectionsis captured once before the run starts; ifCLIENT KILL TYPE normalalso kills the test's own connection used to issue the next KILL, subsequent rounds will error. The exception catch logs and continues — butkill_rounds[0]only increments on success of the WHOLE for-loop, so a single failed connection drops the entire round count. Counting partial successes per-round would be more accurate..github/workflows/soak-nightly.yml:73actions/download-artifact@v8does not exist; the latest is v4. Workflow would fail at startup.
Verdict: Comment
…l budget Two reviewers caught: 1) actions/download-artifact@v8 and actions/setup-python@v6 / actions/checkout@v6 do not exist. Current stable majors: - actions/checkout@v4 - actions/setup-python@v5 - actions/upload-artifact@v4 - actions/download-artifact@v4 Without this fix, the workflow refuses to start. 2) S1 (test_long_run_memory.py) requested --test-time=1800 with --run-count=3, i.e. 90 min wall-clock per run, against a 35 min matrix cell budget. The scenario description in issue redis#413 specifies 30 min total -- drop --run-count to 1 so a single 1800 s run lands inside the budget. (The RSS slope check that S1 is built for needs a single long observation window, not multiple short ones.) Refs redis#413
| addTLSArgs(benchmark_specs, env) | ||
|
|
||
| config = get_default_memtier_config( | ||
| threads=4, clients=50, requests=None, test_time=test_time |
There was a problem hiding this comment.
Duplicate --test-time passed via config and args
Low Severity
Every time-based soak test passes test_time both in benchmark_specs["args"] (as "--test-time={}".format(test_time)) and in get_default_memtier_config(..., test_time=test_time). The Benchmark.__init__ method adds --test-time from the config first, then appends the extra args — resulting in --test-time appearing twice on the final command line. This affects all six time-based soak tests. It works today because both values are identical and getopt_long uses the last occurrence, but it's clearly unintended redundancy.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit add30c4. Configure here.
Cursor bugbot finding (medium): `ulimit -n 65536` was set in the "Tune kernel for soak workloads" step's shell, but GitHub Actions spawns a fresh shell per `run:` block, so the limit didn't carry into the test step that actually needs it (the high-concurrency S3 scenario opens >1000 FDs). Move `ulimit -n 65536` into the run-scenario step where it applies. Keep the sysctl tunings in the prior step -- those are kernel-global and do persist. Refs redis#413
fcostaoliveira
left a comment
There was a problem hiding this comment.
Review v2: docs & commit message (haiku 4.5)
- Hotfix commits reference Cursor bugbot explicitly: Second commit ("pin action versions") references issue context; fourth commit ("move ulimit -n into the run step") explicitly names "Cursor bugbot finding (medium)" and traces the per-shell-invocation scope bug.
- Refs #413 correctly stated in PR body ("Fixes #413"); first commit also references #413. Phased scope (Month-1 / Quarter-1 follow-ups) documented.
- S2 regression guard for #404/#405 clearly stated: PR body labels S2 "test_large_payloads" as direct regression guard for #404 / PR #405, matching the soak suite's purpose.
- Scenario oracles and judgment calls documented: seven scenarios with explicit acceptance criteria; S5 CLUSTER FAILOVER, S6 probabilistic
-ERRshim, S1 slope enforcement all justified in body.
Verdict: clear docs; all hotfixes properly attributed; VLA crash regression guard correctly positioned.
fcostaoliveira
left a comment
There was a problem hiding this comment.
Review v2: performance (haiku 4.5)
ulimit move into run step — startup impact:
ulimit -n 65536(file descriptor cap) is a single syscall in the shell context (ulimit builtin → setrlimit). Overhead: <1 ms, negligible compared to test-time (10–35 min per scenario).- Kernel sysctls (
sysctl -w net.ipv4.tcp_*) run in Tune step (separate from run step) and are global state, not per-test. No repeated startup cost. - FD cap necessity: at 32 threads × 256 clients = 8192 concurrent sockets. Default systemd limit (1024) would exhaust. Tuning up prevents mid-run socket failures, not a performance optimization but a correctness gate.
Soak scenario wall-clock budget:
- 60-minute total budget for 7 scenarios at 10–35 min each,
fail-fast: falsematrix (no cascade blocking). - Per-scenario startup: ~5 sec (Redis server spawn, Python RLTest harness setup, memtier binary load). Negligible vs. 10+ minute test duration.
- S2 (large payloads) generates 100 MB monitor file at runtime (not committed), ~500 ms I/O cost included in the ~10 min test window.
CPU + memory footprint at scale:
- S1 (30-min memory soak): RSS growth rate < 2 MB/min is the oracle, not a hard wall. Startup cost is a ramp-up phase only.
- S3 (32t/256c): FD count slope from startup (~160 open) to steady-state, slope monitored for leaks, not penalized.
- S7 (tc netem): network stack tuning + tc qdisc add (~100 ms) one-time per test, not per-packet.
Verdict: ulimit move is pure infrastructure (no performance regression). Test-time startup overhead is sub-5 seconds amortized across 10–35 minute soak scenarios (0.2–5% overhead, unmeasurable against test-time variance). Soak design is sound from a CI economics perspective.
PR authors can opt into running the soak/stress suite against their
change before merge -- useful when the PR plausibly affects soak-
tracked code (memory growth, retry/reconnect, cluster handling).
Without this, the only way to validate against the soak suite was to
wait for the next nightly cron after merging, which means landing
blind on bugs the suite was built to catch.
gh pr edit <num> --add-label run-soak # opts in
gh pr edit <num> --remove-label run-soak # opts out
Job-level guard:
if: github.event_name != 'pull_request' ||
contains(github.event.pull_request.labels.*.name, 'run-soak')
so the workflow stays a no-op on PRs without the label (a PR push that
adds the label re-fires it; a synchronize push with the label
re-validates).
Refs redis#413
fcostaoliveira
left a comment
There was a problem hiding this comment.
Review v2: design & API (sonnet 4.6)
fail-fast: false+ per-scenario timeouts is necessary but not sufficient for noise control. With 7 scenarios running in parallel, a flaking S7 (tc netem) will generate an artifact upload, a red job badge, and a GitHub notification for every nightly run — with no distinction between "this is a known-flaky infra scenario" and "regression in memtier". Areportjob (needs: soak,if: always()) that reads each matrix cell's outcome and posts a single structured summary (pass/skip/fail per scenario ID) would give oncall a one-glance view and a single notification rather than 7. This is the missing piece for a suite of this size.- S5 (
cluster_turbulence) has a silent no-op path._trigger_failoverreturnsTrueand logs "Skipping CLUSTER FAILOVER: only 1 master(s)" when the RLTest fixture exposes fewer than 2 masters — which is exactly the 3-master+3-replica matrix cell that runs in CI.CLUSTER FAILOVERsent to a master returns-ERR You should send CLUSTER FAILOVER to a replica; the code catches this once and continues. The net effect is that S5's primary chaos signal (failover) is silently a no-op in CI, leaving only theSETSLOT MIGRATINGstep. Aenv.debugPrintwarning promoted toenv.assertTrue(False, "CLUSTER FAILOVER unavailable — scenario is a no-op")would surface this rather than let CI report a green S5 that never actually triggered a failover. - S1's
ulimit -n 65536is set in therun:block via a separate shell. The workflow comment correctly notes thatulimitdoes not persist acrossrun:steps (each step spawns a fresh shell). The ulimit is re-set in the "Run scenario" step, so S3 (high concurrency, 32t/256c) gets it. But S1's 30-minute duration means any fd exhaustion would take the full slot to surface. Verifying that the ulimit step and the test step share the same shell (or combining them) would be safer. - S6's shim is a new Python process spawned inside the test, not in
tests/soak/. The probabilistic-ERRRESP shim lives inline intest_retry_storm.py. If other soak scenarios later need a shim (e.g. a slow-reply shim for S7 fallback), the pattern will be copy-pasted rather than shared. Extracting it totests/soak/resp_shim.pynow — while there is only one caller — keeps the soak directory's design clean. - 60-minute
soakjob timeout with S1 at 35 minutes leaves 25 minutes for 6 other scenarios running in parallel. Because it is a matrix (parallel), the 60-minute wall-clock budget applies per scenario, not in aggregate. S1 + S5 (each allowed 35 and 15 minutes) could both run to completion within the 60-minute wall clock. This is fine, but the comment "60 min total budget" in the workflow header is misleading — it is per-cell, not total. Fixing the comment prevents future contributors from incorrectly cutting scenario timeouts to "fit the budget".
Verdict: the 7-scenario structure is appropriate for a nightly suite. The missing status-aggregation step is the one architectural gap that will make this suite operationally noisy; a report job is a 15-line addition and should be included before the first nightly run fires.
fcostaoliveira
left a comment
There was a problem hiding this comment.
Review v2: style & readability (sonnet 4.6)
-
soak-nightly.ymluses action versions@v4/@v5whileasan.yml/tsan.ymluse@v5/@v6andci.ymluses@v6/@v8. The new workflow pinsactions/checkout@v4,upload-artifact@v4,download-artifact@v4,setup-python@v5— one to two major versions behind the rest of the repo. This is not a correctness issue today but creates version-skew noise in Dependabot and in future upgrade PRs. Align to the highest versions already in use. -
ulimitscope comment ("scoped to this step's shell only … ulimit is re-set inside the run-scenario step below") is exactly the right why-not-what comment. This is the model for the rest of the soak module. Calling it out as a positive. -
test_cluster_turbulence.pyusesproc.wait()afterproc.communicate()—communicate()already callswait()internally; the extraproc.wait()is a no-op but adds reader confusion. The patternmemtier_ok = proc.communicate()[0]; memtier_ok = proc.returncode == 0would be cleaner, or justmemtier_ok = proc.wait() == 0beforecommunicate. -
test_retry_storm.pyimportsrandom as _rinside__init__ofErrShim— an unusual import-inside-method pattern to avoid a module-level name collision that doesn't actually exist. A top-levelimport randomwithself._rng = random.Random(0xDEADBEEF)would be idiomatic. -
S5 judgement-call comment in PR body ("CLUSTER FAILOVER must be sent to a replica, which RLTest's master-connection list does not surface") is documented in the PR body but not in the code.
_trigger_failover's docstring says "Return True so the chaos loop stops retrying" without explaining that master connections always rejectCLUSTER FAILOVER. A one-line explanation in the docstring would make the non-fatal path self-documenting.
Verdict: action version skew is the most visible maintenance issue; the logic is sound and the ulimit/scope comment is exemplary.
fcostaoliveira
left a comment
There was a problem hiding this comment.
Review v2: security (opus 4.7)
- (load-bearing)
tc neteminvocation: sudo prefix is safely bounded and argv list-form throughout._sudo_prefix()returns either[](root) or["sudo", "-n"](non-root)._run_tcdoessubprocess.run(prefix + ["tc"] + args, ...)— pure list, no shell.argsis constructed from hard-coded string literals ("qdisc","add","dev","lo","root","netem","delay","200ms","20ms","loss","1%") — no env-driven or fixture-derived strings.sudo -nensures non-interactive (no password prompt hang). Clean. The skip-on-no-sudo / skip-on-no-tc paths are correctly ordered before anytccall. tc qdisc del dev lo rooton cleanup runs in afinally:block — good. But if the test process isSIGKILL'd mid-run (e.g. workflowtimeout-minutesexpires) the netem qdisc persists on the runner'slountil the next install attempt's "best-effort cleanup first." On a self-hosted runner pool this leaks 200 ms RTT + 1% loss into subsequent jobs. Ephemeral GH-hosted runners are fine; document the self-hosted caveat.- S6
ErrShimbinds127.0.0.1, listens 256, accepts and serves with bounded buffers. Per-connectionbuf = bytearray()grows unbounded if a peer never sends a complete RESP frame — under a non-cooperative client this is a DoS on the test harness itself. memtier always sends complete frames so it's fine in practice; harden by cappingbuflength to 1 MiB and dropping the connection on overflow. test_retry_storm_boundedreuses_BIG_BLOB_MBand_FILLER_LINESstyle env knobs (MEMTIER_SOAK_TEST_TIME, etc.) with no upper bound. Same pattern as #418 — bound them defensively (min(int(env), 3600)forTEST_TIME).- S2
test_large_payloads:f.write("B" * big_value_bytes)materializes the 100 MiB Python string before writing. Comment says "stream-write so we don't hold both blobs in Python memory at once" — that's true for both at once, but each individual blob is held whole. At 100 MiB default that doubles peak RSS of the test python compared to chunked writing. Cosmetic. - Workflow uses
actions/checkout@v4,actions/download-artifact@v4,actions/setup-python@v5,actions/upload-artifact@v4— all pinned by major tag, not SHA. Standard for this repo (the existing workflows do the same), but for a nightly that hasNET_ADMINviasudoand pulls frompackages.redis.io, SHA-pinning gives more auditability. Not a blocker; org-wide call.
Verdict: ship. tc+sudo invocation is correctly bounded; no command-injection surface in the netem path.
fcostaoliveira
left a comment
There was a problem hiding this comment.
Review v2: correctness & latent bugs (opus 4.7)
Tip: a68d61b. Workflow YAML + 7 soak tests under tests/soak/. Bigger surface; focused on the most load-bearing latent bugs.
-
test_cluster_turbulence.py::_trigger_reshardissuesCLUSTER SETSLOT <slot> MIGRATING <dest>againstconns[0]and never issues the matchingCLUSTER SETSLOT ... NODEto finalize the migration. The slot is left in MIGRATING state for the remainder of the run AND across subsequent test runs in the same fixture. RLTest may reuse the cluster fixture between tests — the next test that hits that hash slot will get ASK redirects on a slot that has no key migration backing it, which on memtier master triggers an infinite ASK loop until--max-retries(or hang if not set). Either complete the migration (SETSLOT ... NODE), revert withSETSLOT ... STABLEin afinally, or run this test in its own isolated fixture. -
test_cluster_turbulence.py::test_cluster_topology_turbulenceusessubprocess.Popen(stdin=None, ...)and waits viaproc.communicate().communicate()has no timeout. If memtier hangs (which is exactly what a topology-refresh deadlock would produce — the bug class this test is supposed to catch), the test never fails; it just consumes the matrix cell's 15 mintimeout-minutesand reports as cancelled. The whole point of S5 is to catch hangs; addproc.communicate(timeout=test_time + 60)and onTimeoutExpired, kill +env.assertTrue(False, "memtier hung"). Currently the suite cannot detect the failure mode it's documented to detect. -
Same pattern repeats in
test_connection_churn.py:91andtest_high_concurrency.py:103(proc.communicate()with no timeout). S3 (high concurrency / FD hygiene) is also a hang-class detector and silently absorbs hangs the same way.test_retry_storm.pydoes set a timeout (test_time + 120) — copy that pattern to S3/S4/S5. -
test_long_run_memory.py::_linear_slope_per_minutereturns 0 whenden == 0(all samples at the samet). But samples are tuples(time.time() - start_ts, rss)— t is monotonically increasing, sodencan only be zero ifn < 2. The slope guardif len(samples) >= 2:already covers that. But: the slope is checked against< 2.0 MB/min; what about a negative slope (memory shrinking — pool/cache eviction)?slope_mb_per_min < 2.0accepts arbitrarily negative slopes, which is fine in practice but a real leak that grows slowly and then GCs would average to <2 and pass. Considerabs(slope_mb_per_min) < 2.0only for the upper bound and a separate "final/initial < 1.5x" — wait, you already have the ratio cap. OK. -
test_retry_storm.py::ErrShim._resp_message_lengthparses bulk-string subelements but does NOT consume the trailing\r\nafter the bulk length declaration ifbulk_len < 0(RESP$-1). Look at lines ~135:if bulk_len >= 0: end = pos + bulk_len + 2; pos = end. Ifbulk_len == -1(null bulk), theifis false andposstays atsub_nl + 2— which is correct (no body follows null bulk). But memtier never sends$-1in a multibulk request, so this is theoretical. More concretely: inline commands (theelse: pos = sub_nl + 2branch on non-$sub-elements) would mis-count for any pipelined memtier command stream that uses inline format. memtier doesn't use inline — confirmed by reading client::send_command — so the shim works for the tested workload. Worth a comment in the shim docstring confirming the supported subset. -
test_slow_network.py::_install_netemcalls_run_tc(["qdisc", "del", ...])as best-effort cleanup, then_run_tc(["qdisc", "add", ...]). If theaddsucceeds and the test process is killed (SIGINT from the runner, GitHub job timeout), thefinallyblock doesn't run andlois left with a 200 ms / 1 % loss qdisc on the runner, breaking subsequent jobs on the same host. GitHub-hosted runners are ephemeral so this is harmless there; self-hosted runners (which the soak workflow can be wired to in a future PR) will get bricked. Add a workflow-levelpost-jobcleanup step, or trap SIGTERM in the test. -
soak-nightly.ymluploadstests/logs/and/tmp/RLTest_*on failure withretention-days: 7./tmp/RLTest_*for S2 (large_payloads) will contain the freshly-generated 100 MiB monitor file and the in-flight redis dump if the test failed mid-run. That artifact balloons to multi-GB and GitHub's per-artifact 2 GB cap will silently truncate. Either exclude/tmp/RLTest_*/big.txtand*.rdb, or do an explicitrm -f /tmp/RLTest_*/big.txtbefore the upload step.
Verdict: Comment
fcostaoliveira
left a comment
There was a problem hiding this comment.
Review v2: edge cases & failure modes (opus 4.7)
Verdict: REQUEST CHANGES — ulimit move is correct for cells that reach the run step; tc-netem and chaos-thread cleanup paths have real bugs.
- ulimit-in-run-step is safe against pre-run-step failures. Steps preceding "Run scenario" (checkout, download-artifact, chmod, apt-get, setup-python, pip, install redis, tune kernel) can fail; if any does, the cell aborts with
Upload logs on failureand the run step never executes — noulimit -n 65536needed. The comment at the "Tune kernel" step correctly explains the scoping. However: theTune kernelstep itself sets sysctls but doesn't setulimit -nthere — and the comment says "ulimit is re-set inside the run-scenario step below" which is misleading because it was never set in the kernel step in the first place. Rephrase to "ulimit is set inside the run-scenario step (sysctls persist; per-shell ulimit does not)". tc netemcleanup is NOT exception-safe across test-runner crashes._install_netemaddsqdisc add dev lo root netem .... Thefinally: _remove_netem()runs iftest_slow_network_smoothraises — but if RLTest itself segfaults, or the GitHub Actions job hits thetimeout-minutescap, the qdisc stays installed onlofor the lifetime of the runner. Hosted runners reset, but self-hosted soak runners would carry 200ms delay + 1% loss into the next job. Add a separatePost-job: ensure tc netem removedstep withif: always()that runssudo tc qdisc del dev lo root 2>/dev/null || true.- S5 cluster_turbulence chaos thread join is fire-and-forget.
chaos_thread.join(timeout=5)followed by an unconditional return — but the chaos function calls_run_tc(..., timeout=10)internally via redis-cli. A failover call started at t=T-1 can block for up to 10 s; join(5) returns with thread still alive, the daemon thread is reaped at process exit. Real edge: the failover call might land on a redis-server already being torn down by RLTest's cleanup → spurious "DEBUG SLEEP" or "CLUSTER FAILOVER" failures hit stderr after the test logged PASS. Drop the timeout on join (let it complete fully) and add astop_chaos.set()before invokingproc.communicate()'s timeout path; todaystop_chaos.set()only happens in thefinally. - Module-level
int(os.environ.get(...))in S2 (tests/soak/test_large_payloads.py) crashes the file at collection if the env is malformed. Same hazard as #418:_BIG_BLOB_MB = int(os.environ.get("MEMTIER_SOAK_BIG_BLOB_MB", "100"))etc. run during import. The other scenarios correctly evaluate inside the test function (verified S1/S4/S5/S6/S7). S2 should follow that pattern. _BIG_BLOB_MBdefaults to 100 (MB), so a single SET line is ~100 MiB. Streamed-write is OK, but the file itself sits on disk for the test duration; with the matrix running concurrent self-hosted jobs that adds up. Add atearDown/finallyshutil.rmtree(test_dir)— todaytempfile.mkdtemp()results survive each scenario and accumulate.- Soak workflow has
needs: buildbut does NOT pass build status to individual matrix cells viaif:— a build artifact that uploads with the wrong arch (e.g. failed download mid-upload, corrupt tar) would let every cell start and then fail at "Restore executable permissions" or first invocation. Addactions/download-artifact@v4withif-no-files-found: errorand aSmoke-test downloaded binarystep that runs./memtier_benchmark --versionBEFORE the rest of the setup — catches the corruption cheaply.
(Files: .github/workflows/soak-nightly.yml, tests/soak/test_slow_network.py, tests/soak/test_cluster_turbulence.py, tests/soak/test_large_payloads.py.)
|
|
||
| def test_cluster_topology_turbulence(env): | ||
| if not env.isCluster(): | ||
| env.skip() |
There was a problem hiding this comment.
Missing return after env.skip() causes unintended execution
Medium Severity
env.skip() on line 93 is missing a return statement. Every other env.skip() call in the codebase (including test_slow_network.py line 92-93 in this same PR, and test_cluster_transaction.py lines 89-90 and 117-118) is followed by return. Without it, the test continues executing in standalone mode, eventually failing at the CLUSTER INFO assertion rather than cleanly skipping.
Reviewed by Cursor Bugbot for commit 7a14ebc. Configure here.
PR authors need to know the label exists and when to use it. Add a new "On-demand fuzzers and soak tests (PR labels)" subsection under ## Testing that explains: * which workflow the label triggers (monitor-fuzz.yml) * what it runs (FUZZ_ITER=300, ASAN+UBSan build, ~3-4 min budget) * when to apply it (parser / splitter / RESP-encoded request path) * how to apply (gh pr edit --add-label run-fuzz) * how to run locally Sibling PRs (redis#420, redis#423) will extend this table with their own labels (run-differential, run-soak). Refs redis#408
PR authors need to know the label exists and when to use it. Add a new
"On-demand: soak / stress" subsection under ## Testing that explains:
* the workflow (soak-nightly.yml)
* the seven scenarios it runs
* when to apply (memory growth / retry / reconnect / cluster /
large-payload paths)
* how to apply (gh pr edit --add-label run-soak)
* the nightly + workflow_dispatch + label trigger surface
Refs redis#413
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 3 total unresolved issues (including 2 from previous reviews).
Reviewed by Cursor Bugbot for commit 83f581c. Configure here.
| "--hide-histogram", | ||
| ], | ||
| } | ||
| addTLSArgs(benchmark_specs, env) |
There was a problem hiding this comment.
TLS args added for plain TCP shim server
Low Severity
addTLSArgs(benchmark_specs, env) is called before connecting to the ErrShim, a plain Python TCP socket server with no TLS support. If the soak suite is ever run with TLS enabled (env.useTLS is true), memtier would attempt a TLS handshake against the shim and fail immediately. The call is a no-op today because the soak workflow doesn't set TLS=1, but it's incorrect by construction — unlike other tests, S6 intentionally bypasses Redis and add_required_env_arguments, so TLS flags are never appropriate here.
Reviewed by Cursor Bugbot for commit 83f581c. Configure here.
Resolves DEVELOPMENT.md conflict by folding the run-differential label into the on-demand-suites table already added by the now-merged monitor-fuzz PR. Single coherent table is easier to extend (redis#423 will add run-soak next).
* ci: declare workflow-level contents: read on 6 workflows Pins the default GITHUB_TOKEN to contents: read on the workflows in .github/workflows/ that don't call a GitHub API beyond the initial checkout. The other workflows in this directory are left implicit because they need write scopes that a maintainer is better placed to declare. Motivation: CVE-2025-30066 (March 2025 tj-actions/changed-files compromise) exfiltrated GITHUB_TOKEN from workflow logs. Per-workflow caps bound runtime authority irrespective of repo or org default, give drift protection if the default ever widens, and are credited per-file by the OpenSSF Scorecard Token-Permissions check. YAML validated locally with yaml.safe_load. Signed-off-by: Arpit Jain <[email protected]> * ci: also declare contents: read on fuzz-smoke + soak-nightly workflows Extends the PR to cover the two workflows that landed after it was first opened (fuzz-smoke.yml from PR #421, soak-nightly.yml from PR #423). After the merge with master, dockers.yml + the two new ones are the only files where the permissions block is still missing. --------- Signed-off-by: Arpit Jain <[email protected]> Co-authored-by: fcostaoliveira <[email protected]>


Fixes #413.
Summary
Adds
.github/workflows/soak-nightly.ymlplus seven RLTest scenarios undertests/soak/exercising memtier_benchmark in regimes our PR CI never hits: long duration, giant payloads, high concurrency, reconnect churn, cluster topology turbulence, retry storms and lossy networks.cron: '17 2 * * *'+workflow_dispatch. Not wired intopull_request/push(so PR CI minutes stay untouched).fail-fast: falsematrix soak job.tests/soak/directory and use the existingtests/include.pyhelpers (addTLSArgs,get_default_memtier_config,add_required_env_arguments,debugPrintMemtierOnError).MEMTIER_SOAK_TEST_TIME(and friends) from the environment so it can be smoke-tested locally in seconds; CI runs the full durations.Scenarios
test_long_run_memory.pytest_large_payloads.pySTRLENmatches the regenerated 100 MB blobtest_high_concurrency.pytest_connection_churn.pyCLIENT KILL TYPE normalrounds with--reconnect-interval=10test_cluster_turbulence.pycluster_state:okat end afterCLUSTER FAILOVER+CLUSTER SETSLOT MIGRATINGmid-runtest_retry_storm.py-ERRshimtest_slow_network.pytc netem delay 200ms 20ms loss 1%onloThe S2 monitor input file (~120 MB) is generated at test-time and removed before the next scenario -- never committed to the repo.
S7 wraps
tccalls in asudo -n+shutil.which("tc")guard andenv.skip()s cleanly when neither root nor passwordless sudo is available, so non-root sandboxes don't fail the suite. GitHub runners do have NET_ADMIN viasudo.Judgement calls
CLUSTER FAILOVERmust be sent to a replica, so the call returns-ERR You should send CLUSTER FAILOVER to a replica. We catch it once, log it, and continue -- theCLUSTER SETSLOT MIGRATINGstep still drives the MOVED/ASK redirection path, which is the main thing we want to exercise.-ERRshim deterministically wedges memtier (every in-flight request hits--max-retriesand the connection effectively stalls -- itself a real bug surface). We use an 80%-ERR/ 20%+OKmix so the retry codepath is exercised aggressively without hitting that wall, keeping the test green on a clean master while still smoke-testing for unbounded memory growth.final/initial < 1.5ratio, since the slope of an under-warmed-up run is dominated by ramp-up noise.Test plan
Smoke-tested locally against
redis-server 8.6.0withMEMTIER_SOAK_TEST_TIMEshortened to 10-30s (full durations honoured in CI):test_long_run_memory-- PASS (10s, 17 samples, slope only enforced >= 5 min)test_large_payloads-- PASS atBIG_BLOB_MB=2 MID_BLOB_MB=1. Reproduces the SIGSEGV from SIGSEGV / stack smashing when --monitor-input contains a large command line (VLA stack overflow in split_command_to_args) #404 on current master at the full CI-sized 100 MB blob, which is exactly what the scenario is designed to catch. It will pass in CI once PR fix(arbitrary-command): heap-allocate split-token buffer to avoid VLA stack overflow #405 merges.test_high_concurrency-- PASS (15s, 4t/10c, peak 57 fds vs 160 ceiling)test_connection_churn-- PASS (20s, 7 kill rounds)test_cluster_turbulence-- PASS (20s, 3-shard cluster, failover attempted, reshard applied,cluster_state:okat end)test_retry_storm-- PASS (10s, peak RSS 47 MB, peak CPU 97%)test_slow_network-- skips cleanly when sudo isn't passwordless; relies on CI runners for the actualtc qdiscinstall (verified the skip path explicitly)Items to verify only in CI:
Note
Low Risk
Changes are limited to CI workflow and new integration tests; no production C++ behavior is modified in this diff.
Overview
Adds a nightly / on-demand soak and stress CI pipeline plus seven new RLTest scenarios under
tests/soak/, aimed at long-run and chaos regimes that normal PR CI does not cover.The workflow
.github/workflows/soak-nightly.ymlbuildsmemtier_benchmark, then runs a fail-fast-disabled matrix (S1–S7) via./tests/run_tests.shwith per-scenario timeouts, standalone vs cluster env flags, kernel tuning, and failure log artifacts. It triggers on cron,workflow_dispatch, and PRs labeledrun-soak(not on every push).DEVELOPMENT.mddocuments therun-soaklabel, nightly cron, and a local RLTest example.New scenarios include: RSS growth over ~30m (S1), huge
--monitor-inputlines as a guard for the VLA/stack-smash class of bugs (S2), high concurrency + FD leak checks (S3),CLIENT KILLreconnect churn (S4), cluster failover/reshard turbulence (S5), bounded retry storm against a probabilistic-ERRshim (S6), andtc netemslow/lossy loopback with graceful skip whentc/sudo is unavailable (S7). Durations and blob sizes are overridable viaMEMTIER_SOAK_*env vars for local smoke runs.Reviewed by Cursor Bugbot for commit 7c1af38. Bugbot is set up for automated code reviews on this repo. Configure here.