Repository navigation
Don't continue a standalone --transaction block after a reconnect drops its MULTI - #634
Conversation
7539e2f to
a3037ed
Compare
|
🤖 Automated first-pass review — a human maintainer's review is still required before merge. Thanks, this reads well. It's the same rule #607 added in Things I checked that hold up:
One question, not a blocker: the only signal that a block was skipped is Nitpicking: the man page change also rewrites the same-key/CROSSSLOT paragraph. I guess that's just help2man catching up with The fix looks solid to me as it stands. |
a3037ed to
49bd158
Compare
…imit The standalone "Run tests" cells run the whole RLTest suite serially. After the tests added on 2026-10-13/14 the three TLS cells take 1300-1500 s against a 25-minute (1500 s) step limit, so a slow runner cancels the job even when every test passed (PR #634, run 38692596851). Plaintext (~1270 s) and coverage (~1257 s) are close behind. Set PARALLELISM=2 on the four standalone cells, as the cluster cells already do; run_tests.sh passes it to RLTest --parallelism, which gives each worker its own redis env on a distinct port range. Raise the test-ubuntu and coverage step limits to 40 minutes for headroom. The coverage job stays serial. Fixes #679 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…imit The standalone "Run tests" cells run the whole RLTest suite serially. After the tests added on 2026-10-13/14 the three TLS cells take 1300-1500 s against a 25-minute (1500 s) step limit, so a slow runner cancels the job even when every test passed (PR #634, run 38692596851). Plaintext (~1270 s) and coverage (~1257 s) are close behind. Set PARALLELISM=2 on the four standalone cells, as the cluster cells already do; run_tests.sh passes it to RLTest --parallelism, which gives each worker its own redis env on a distinct port range. Raise the test-ubuntu and coverage step limits to 40 minutes for headroom. The coverage job stays serial. Fixes #679 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ps its MULTI With --transaction against a single endpoint, a connection killed after it sent a rotation's MULTI reconnects with the rotation index still on the next command of the block. The rest of the block (SET, EXEC) then went out on the new socket: the SET ran outside any transaction and the EXEC failed with "EXEC without MULTI", while the run still exited 0. client::create_request() (the standalone path) now remembers that this rotation's MULTI was sent. If the connection no longer has the MULTI open, it skips the rest of the block up to and including the EXEC/DISCARD, without sending or counting it. The server already discarded what was queued. This is the same rule #607 adds for cluster mode in cluster_client::create_arbitrary_request(). Fixes #633 Co-Authored-By: Claude Opus 5.5 <[email protected]>
… EXEC Cluster mode falls through to client::create_request() when its key pool is empty, and there the rotation's MULTI may sit on another connection than conn_id, so is_multi_open() on conn_id says nothing about it. Cluster mode keeps its own check in cluster_client::create_arbitrary_request(). Extend test_transaction_lost_multi_is_not_continued with 50 GETs after the EXEC and check the server's GET count against the MULTI count, so a skip that does not end at the EXEC (m_txn_multi_sent left set) fails it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The man page still called --transaction a no-op in standalone mode, and both it and --help only said the interrupted rotation's stats would be inaccurate. Say what happens now: after a reconnect inside a MULTI block, the rest of that block, through EXEC/DISCARD, is skipped and not counted, so per-command counts no longer follow the command ratio. Name the thread/client counts of _run_transaction_with_kills() so the GET bound in test_transaction_lost_multi_is_not_continued follows them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The man page still said standalone needs no pinning and described the old cluster-only wording; regenerate its --transaction entry from usage() (help2man output, entry only). Say that replies already received for a block cut short by a reconnect stay counted, and drop the code comment that called --transaction a standalone no-op. Co-Authored-By: Claude Opus 5.5 <[email protected]>
49bd158 to
5d08ca2
Compare
|
Re the first-pass review's nit: the code comment near the The same commit regenerates the man page's The earlier red check was the 25-minute step timeout (#679), which #683 has now fixed. |
|
On the updated review:
|
Problem
With
--transactionagainst a single endpoint plus--reconnect-on-error, a connection killed after it sent a rotation'sMULTIreconnects with the rotation index still on the next command of the block. The rest of the block then goes out on the new socket: theSETruns outside any transaction, theEXECfails with-ERR EXEC without MULTI, and the run still exits 0. Details are in #633.Root cause
client::create_request()is the standalone path. It sendsm_executed_command_indexwithout checking that the block's MULTI is still open.shard_connectionalready tracks this (m_multi_open, set insend_arbitrary_command_end()and cleared on connect/disconnect), but nothing on the standalone path reads it.cluster_clientoverridescreate_request(), but it can still fall through toclient::create_request()when its key pool is empty. On that path the rotation's MULTI may sit on a different connection thanconn_id, so the new check is guarded with!m_config->cluster_mode. Cluster mode keeps its own check incluster_client::create_arbitrary_request()(#607).Fix
The same rule #607 added for cluster mode, applied to the standalone path:
client::m_txn_multi_sentis set when the rotation's MULTI is sent and cleared when EXEC/DISCARD is sent.client::create_request(), outside cluster mode, if it is set, the current command is not the opener, and the connection no longer hasis_multi_open(), the command is skipped. Skipping continues up to and including the EXEC/DISCARD, and the rotation advances without sending anything. The next rotation starts with a fresh MULTI. Commands after the EXEC (outside the block) are sent as normal.m_reqs_generated.--requestsruns still end on processed replies, the same as for requests dropped on a disconnect.The code change is only in
client.cpp/client.h, plus the standalone test.Docs: the man page's
--transactionentry said that standalone mode needs no pinning, and the code comment called the flag a standalone no-op. Both were out of date. The entry is now regenerated fromusage()(help2man output, that entry only). That also brings in the same-key/CROSSSLOT paragraph--helpalready had. The entry and--helpused to say that an interrupted rotation's stats "will be inaccurate". They now say that after a reconnect inside a MULTI block, the rest of that block, through EXEC/DISCARD, is skipped and not counted, so per-command counts no longer follow the command ratio. They also say that replies already received for that block stay counted.Test evidence
New test:
test_retry_on_error.py::test_transaction_lost_multi_is_not_continued(skipped on cluster, since #607 covers cluster mode). The rotation isMULTI, 50xSET,EXEC, 50xGET, at-t 2 -c 4 --pipeline 7, for 6s withCLIENT KILL TYPE normalevery 0.3s. Long blocks make most kills land inside a block, and a pipeline of 7 does not divide the rotation, so kills don't always land on a block boundary. The test asserts:EXEC without MULTIin stderr, and zeroerrorstat_ERR;50 * MULTI calls - GET callsis at most50 * 8(partial rotations of the 8 connections at the end) plus7 * killed connections(GETs in flight on a killed connection). This catches a skip that doesn't stop at the EXEC: the mutant that never clearsm_txn_multi_sentin the skip path also drops the following GETs.Local runs, RLTest
--env oss, standalone redis (bound = 680 with 40 kills per run):-ERRrepliesEXEC without MULTI)m_txn_multi_sentSame repro outside RLTest, from the first version of this PR: master gives 23
EXEC without MULTIwith exit 0; this PR gives 0.commandstatsshows SET == EXEC with the fix.The whole
test_retry_on_error.pypasses with the fix under--env oss(18/18). After rebasing onto fd7b23c, the new test andtest_transaction_requests_are_not_retriedpass again. I also rantest_transaction_pipeline.py(3/3 pass).Fixes #633
Refs #673: this removes the
EXEC without MULTIpart of the--reconnect-intervalvariant (repro there: 572 errors → 0). Keeping the reconnect on a block boundary and the QUEUED accounting are still open.Affected versions
2.4.0 through 2.5.2 and master. This came in with
--transactionitself (f7f8983, #390). I confirmed it by running master 38fae5d, 2.5.2 and 2.4.0, and the new test fails on master 0298524.🤖 Generated with Claude Code