Repository navigation
Fix flaky test_rabbitmq_reconnect_drops_stale_deliveries: do not wait 300 s for a hung rabbitmqctl call - #126746
Conversation
…_drops_stale_deliveries The drain loop started a new `rabbitmqctl list_queues` (an Erlang CLI VM via `docker exec`) on every iteration, 15-22 times per run on arm, and waited up to the harness default of 300 s for each without a retry. In 3 runs of `Integration tests (arm_binary, 2/4)` on 2026-10-19 one call never returned and printed nothing, while ClickHouse had inserted all 10100 rows and the broker passed its `rabbitmq-diagnostics ping` healthcheck 29/29 times in that window, so the loop's own 180 s deadline was never checked. Ask the broker only once the row count has been stable for 3 s (same exit condition, about one call per run), and abandon a call after 30 s and ask again under the existing deadline. Only a timeout is treated as "not drained yet". `close_all_connections` is unchanged: a retry could force a second reconnect. Validated with an injected never-returning call (unfixed: fails after 300 s with the CI error; fixed: passes 2/2 with one abandoned call), 50/50 normal runs, and the pre-ClickHouse#125105 binary, which still fails on the duplicates bound. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 finding; bounded: 1 full pass + 1 fix round + 1 delta recheck).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261019-162000 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261019-153000 |
|
cc @antaljanosbenjamin, could you review this and add the |
|
Workflow [PR], commit [9c18fa2] Summary: ✅ AI ReviewSummaryThe PR reduces CLI calls in Missing context / blind spots
Final VerdictStatus: ✅ Approve |
…es without rabbitmqctl `rabbitmqctl close_all_connections test` timed out after 300 s in 3 runs of `Integration tests (arm_binary, 2/4)` (master 524a0c2, ClickHouse#127389, ClickHouse#126642). The close never reached the broker: no `Closing connection ... because "test"` line in its log, and ClickHouse's AMQP connection stayed open for 5 minutes until the test dropped the database. The broker passed its `rabbitmq-diagnostics ping` healthcheck 29/29 times in each window, so a new CLI process again never got to its RPC, like the `list_queues` call before. Bounding the call and asking again does not fit here: the drop must happen while most of the backlog is still queued (`view_rows() < messages_num // 2`), which leaves about 9 s after the 500-row trigger at ~490 rows/s, and a timed-out `docker exec` leaves the CLI running in the container, where a late close would force a second reconnect. Close through the management API instead: `DELETE /api/connections/username/root` with `X-Reason: test` reaches the same `rabbit_networking:close_connection(Pid, "test")` for every connection of the broker's only user, synchronously before the 204 reply, and starts no CLI process. Validated: an injected never-returning close fails the unfixed test after 300 s with the CI error; without the DELETE the test fails waiting for the reconnect; the pre-ClickHouse#125105 binary still fails on the duplicates bound (9500, 9400); 50/50 runs pass with `204` (p50 0.1 s) and ClickHouse logs `CONNECTION_FORCED - test` then `Connection restored`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
test_rabbitmq_reconnect_drops_stale_deliveries: do not wait 300 s for one rabbitmqctl list_queues calltest_rabbitmq_reconnect_drops_stale_deliveries: do not wait 300 s for a hung rabbitmqctl call
Internal second-model review: adjudication log,
|
| # | Sev | Finding | Verdict | Evidence / action |
|---|---|---|---|---|
| 1 | 💡 | Related references were short #N on one line, not full URLs one per line |
AGREE | Fixed in the PR description; the second pass did not raise it again. |
| 2 | 💡 | The commit messages do not carry the full CI report URLs | AGREE, not changed | The first commit is already pushed and is not rewritten; the PR description links all five failing jobs and their PRs. |
Severity: ❌ blocker /
Session id: cron:clickhouse-review-slot-8:20261028-152500
Pre-PR validation gate, `close_all_connections` commit (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261028-143600 |
| def queue_drained(): | ||
| out = rabbitmqctl("-q", "list_queues", "name", "messages_ready", "messages_unacknowledged") | ||
| nonlocal abandoned_calls | ||
| # A rabbitmqctl call occasionally never returns, so give up on it and ask again. |
There was a problem hiding this comment.
Why it doesn't return?
There was a problem hiding this comment.
I don't know the root cause. It doesn't reproduce on x86, and the CI artifacts have nothing from inside the stuck process. Here is what the six failed arm_binary runs I looked at show:
- In each run exactly one
rabbitmqctlprocess never exits. The other calls in the same run finish in about 0.5 s. - The broker is fine the whole time. The container healthcheck
rabbitmq-diagnostics -q ping, which is also a fresh CLI process throughdocker exec, passed 29 of 29 times inside each 300 s window.rabbit.logshows nothing unusual, and ClickHouse consumed the whole queue. - The process gets stuck before it does any work. The hung
close_all_connectionsprinted nothing at all, not even itsClosing all connections in vhost /, reason: test...banner. The CLI prints that banner after it starts Erlang distribution and checksrabbit:is_runningon the node, and before the close RPC (rabbitmqctl.ex). The broker never loggedClosing connection ... because "test"either. The hunglist_queuesran for 300 s without an error, so it never reached the 60 s timeout of its listing RPC.
So, at least for the close, the hang is in the CLI's own startup: Erlang VM boot, the distribution start, or the rabbit:is_running check. The artifacts can't tell which one. The broker's own Erlang node in this image has a similar boot hang, almost always on arm_binary, which is why wait_rabbitmq_to_start recreates the container since 27ebf5a.
That's why this PR works around the hang instead of fixing it. If you want the root cause, I can capture the stuck process when a call times out (an in-container ps plus an Erlang crash dump via kill -USR1).
There was a problem hiding this comment.
While we can't answer, we still have no other option. As long as the test is still ok, this is good to merge.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Related: #125105 (added the test)
Related: #126206 (fix requested there)
Related: #126642 (fix requested there)
On arm a new
rabbitmqctlprocess occasionally never returns while the broker stays healthy (29/29 healthchecks), and the test waited 300 s inIntegration tests (arm_binary, 2/4):list_queues(#126206, #126013),close_all_connections(master, #127389, #126642).list_queuesis now asked only once the row count is stable for 3 s (one call per run, not 15-20), abandoned after 30 s and asked again under the 180 s deadline.The close never reached the broker. A retry does not fit (the drop must happen within ~9 s, and an abandoned CLI keeps running in the container), so the close goes through the management API (
DELETE /api/connections/username/root): the samerabbit_networking:close_connection, no CLI process.list_queueskeeps the CLI: it reads live counters, the API 5 s samples.The hang does not reproduce on x86, so I injected
sleep 600: unfixed, the test fails after 300 s with the CI error for either call; fixed, a hunglist_queuesis abandoned after 30 s and it passes. Without theDELETEit fails waiting for the reconnect. 50/50 runs pass; the pre-#125105 binary still fails on duplicates (8300-9500 > 200).Workflow [PR]
Sync PR [sync-upstream/pr/126746]
Version info
26.11.1.963-master(included in26.11and later)