Repository navigation
Route old-leader reads through Raft in the Keeper compat snapshot test - #113992
Conversation
test_recover_from_snapshot_sent_by_old_leader could hang for the full 900 s pytest-timeout and take its whole integration shard with it. The stall is not in the code under test: it is on compat1 / compat_s3_1, the instances pinned to the released 25.3 and 25.12 images. Those versions park a read that arrives while a write batch is assembling in read_request_queue[<last write's session_id>][<that write's xid>], which can belong to a different session, and finishSession erases the whole session entry without sending any response (addErrorResponses never consults the queue). So when a writer session expires, a co-batched read from another session is dropped silently, and the test's client waits on it forever because KazooClientWithImplicitRetries calls AsyncResult.get() with no timeout. That Keeper bug was fixed on master by 5eb8dd3 ("Keeper: fix race between read requests and session close"), which also added tests/integration/test_keeper_read_during_close. Neither pinned image has it: 25.3 is 890 commits behind that commit, and 25.12's KeeperDispatcher.cpp still erases without responding. There is nothing to fix in src/. In both pinned versions the only read_request_queue insertion is guarded by !quorum_reads, and the branch above it sends the read through the write path instead when that setting is on. Setting quorum_reads on those two instances therefore makes the dropping path unreachable for every read they serve, from every call site, without having to enumerate the call sites. The followers under test (compat3, compat_s3_3) and the two quorum-filler instances keep the default local reads so CI still exercises the default path. No assertion is changed, skipped or weakened. Validated with the 4LW lgif last_log_idx as the oracle, since a quorum read is appended to the Raft log and a local read is not: 40 reads per node advance the index by 40 on both pinned nodes with the fragment and by 0 without it, while a one-write control advances it by 1 on every node in both arms. The "Processing requests batch" log line is not usable for this, being LOG_TRACE in 25.3 but LOG_TEST in 25.12. The merged effective config keeps every generated coordination setting, and the setting is present on exactly those two instances. Not addressed here: helpers/kazoo_client.py still waits without a timeout, so a future lost response would again burn 900 s. That unbounded wait is what lets test_keeper_read_during_close detect a stuck reader, and the helper is shared by 61 test files.
The previous commit made the compat test depend on quorum_reads being enabled on the pinned old leaders, but nothing in the repository asserted that. Three of the four ways the setting can stop being applied are loud (a missing fragment file raises in cluster.py, a non-merging fragment reverts snapshot_distance and fails the snapshot assertion, an unknown setting name stops the server), but the fourth is silent: dropping "configs/quorum_reads.xml" from main_configs leaves both parametrizations passing while the 900 s hang returns. Read the value back from the running servers with the 'conf' four-letter-word command and assert it: true on the pinned old leader, false on the follower under test, which must keep the default local-read path. A future edit that drops the fragment now fails on this assertion instead of silently restoring the flake. Verified in both directions: removing the fragment from compat1 fails with "assert 'false' == 'true'", and adding it to compat3 fails with "assert 'true' == 'false'". Both parametrizations pass with the tree as committed.
Internal second-model review (2 rounds, 0 open blockers)An independent model reviewed this change cold against the diff and the pinned-version sources,
AGREE, fixed. Three of the four ways the setting can stop applying are already loud: a missing DISAGREE, with evidence. An exact-equality log-index delta is not deterministic in this Also checked and found sound, independently of the authoring session: the |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20260808-223300 |
|
cc @antonio2368, could you review this? A Keeper compat integration test can hang for the full 900 s pytest-timeout because its old leader is pinned to a released 25.3 / 25.12 image that predates 5eb8dd3, so an expiring writer session silently drops another session's batched read; this sets quorum_reads on those two pinned instances only, which makes that queue insertion unreachable, and asserts the effective value via the conf four-letter-word command so the fragment cannot be dropped silently. |
|
Workflow [PR], commit [62aa7f3] Summary: ✅ AI ReviewSummaryThis PR makes the compat Keeper snapshot-transfer test avoid a known hang in the pinned Final Verdict✅ No blocking findings. |
The effective-setting assertion was placed after the snapshot transfer, but cleanup_test_tree and fill_test_tree already read from the old leader before that point (zk.exists and ensure_path's exists_async). If a later edit dropped configs/quorum_reads.xml from main_configs, one of those earlier reads could hit the lost-response race in the pinned image and burn the full 900 s pytest timeout before the assertion ran, so the guard did not reject the regression deterministically. Move both assertions ahead of cleanup_test_tree, gated on a 4LW-only readiness wait (wait_complete_readiness=False, as in test_keeper_disks) because the complete-readiness probe issues a kazoo read itself. Measured with the fragment dropped from compat1: the test now fails on the assertion in 57 s having issued zero Keeper requests, where previously it failed in 87 s after 6 Exists and 2 GetData requests against the old leader.
CI finish ledger — 62aa7f3CI is fully finished and green: 0 failing checks ( Session id: cron:our-pr-ci-monitor:20260809-220000 |
|
CI here is green (0 failures on @antonio2368 could you take a look when you have a moment? Test-only change, two files. |
Backport #113992 to 26.7: Route old-leader reads through Raft in the Keeper compat snapshot test
…ft in the Keeper compat snapshot test
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
test_keeper_snapshot_chunked_transfer/test.py::test_recover_from_snapshot_sent_by_old_leadercanhang for the full 900 s pytest-timeout and take its whole integration shard with it.
The stall is not in the code under test. It is on
compat1/compat_s3_1, pinned to the released25.3and25.12images. Those versions park a read that arrives while a write batch is assemblingin
read_request_queue[<last write's session_id>][<that write's xid>], which can belong to adifferent session, and
finishSessionerases that whole session entry without responding. So when awriter session expires, a co-batched read from another session is dropped silently and the client
waits on it forever.
Master fixed that in 5eb8dd3 ("Keeper: fix race between read requests and session close"),
which also added
tests/integration/test_keeper_read_during_close. Neither image has it, so nothingneeds fixing in
src/.In both pinned versions the only
read_request_queueinsertion is guarded by!quorum_reads, and thebranch above it routes the read through the write path when that setting is on. This PR sets it on
those two instances only, making the dropping path unreachable for every read they serve. The
followers under test and the quorum fillers keep the default local reads.
Bumping the images instead does not work: the earliest release carrying that commit is
26.4, whichis also the earliest release shipping
snapshot_transfer_chunk_size, so it stops being a leaderwithout chunking and the test's
n_chunks == 1premise disappears.The test also asserts the effective setting read back from both servers via the 4LW
confcommand, soa later edit that drops the fragment fails there instead of silently restoring the hang. No existing
assertion is weakened.
Not addressed:
helpers/kazoo_client.pycallsAsyncResult.get()with no timeout, so a future lostresponse would still burn 900 s. That unbounded wait is what lets
test_keeper_read_during_closedetect a stuck reader, and 61 files reach it through
get_fake_zk.Validation
Config:
quorum_readspresent on exactlycompat1+compat_s3_1, absent on the other four, andthe merged effective config (4LW
conf) still carriesoperation_timeout_ms,session_timeout_ms,snapshot_distance,stale_log_gap,reserved_log_itemson both, so the fragment adds a settingrather than replacing the generated block.
Mechanism, oracle = 4LW
lgiflast_log_idx(a quorum read is appended to the Raft log, a localread is not). 40 reads per node:
falseA one-write control advances the index by 1 on every node in both arms, so the oracle is not
vacuous. (
Processing requests batchis not usable here:LOG_TRACEin 25.3 butLOG_TESTin25.12.)
Runs: both parametrizations 20/20 over 10 repeats;
test_keeper_read_during_close,test_keeper_snapshot_chunked_transfer/test_concurrent.pyandtest_keeper_snapshot_rotation_race/test.pyall pass unchanged.Cost:
[local_disk]38.4 s -> 39.8 s,[remote_disk]32.2 s -> 36.7 s, module 119.9 s -> 126.5 s.Version info
26.7.14.13