Repository navigation
Make the queue-removal check in test_rabbitmq_drop_table_properly precise - #114269
Conversation
The final existence check used a bare time.sleep(30) plus a one-shot passive declare, while the data check ~15 lines earlier already polls with DEFAULT_TIMEOUT_SEC. Replace it with the same bounded-poll idiom. pika closes the channel when a passive declare fails, so the channel is reopened on every attempt; otherwise the second attempt would raise for the wrong reason and the assertion would pass vacuously. Only a 404 counts as "queue gone" - any other channel close now fails the test loudly. This is a robustness/runtime change, not a fix for the underlying leak: the broker's answer to queue.delete arrives inside the DROP (cleanupRabbitMQ blocks up to BLOCKING_LOOP_TIMEOUT_MS), so it is already settled before the old sleep began, and the poll cannot mask it. The passing case drops from a fixed 30s to under a second.
Follow-up to the previous commit, which polled to DEFAULT_TIMEOUT_SEC (60s). DROP TABLE is synchronous down to the broker: InterpreterDropQuery calls flushAndShutdown(true), and cleanupRabbitMQ() blocks on startBlockingLoopWithTimeout(BLOCKING_LOOP_TIMEOUT_MS = 30000). The broker's answer to queue.delete is therefore already settled before any post-DROP wait begins, so the wait is slack either way and 60s only widens what the assertion accepts. It must not be narrowed to a single immediate declare either: on the loop-timeout path removeQueue has already sent the QueueDeleteFrame and only our callbacks are abandoned, so the broker may still delete the queue slightly later, and the original test accepted that. 30s reproduces the original acceptance window exactly. The substantive change is in the previous commit's 404 requirement, not in the waiting: the old form treated any exception as "queue gone", so a dead connection or a non-404 channel close passed vacuously. Correcting the earlier commit message: the poll cannot mask the permanent leak paths, but a wider window would have masked a late broker-side delete. One pika channel is now reused across attempts. A successful passive declare leaves the channel usable, and the 404 path breaks out immediately, so the channel is never used after the broker closes it.
Internal second-model review (click to expand)Two independent reviews of this change plus one adversarial gate pass. Findings below, with
Not raised as follow-up work: Session id: cron:clickhouse-review-slot-10:20260811-042400 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20260811-040800 |
|
cc @kssenii, could you review this? It is a test-only change: the queue-removal check in test_rabbitmq_drop_table_properly wrapped its passive declare in |
|
cc @pamarcos |
|
Workflow [PR], commit [fbc2433] Summary: ✅ AI ReviewSummaryThis PR tightens Final Verdict✅ No blocking issues found. |
The deadline was tested only after a successful passive declare, and the loop then always slept a full 0.5 s, so the last declare could land up to one sleep interval past the 30 s deadline. Whether it did depended on where the deadline fell relative to the declare grid: with the deadline exactly on a multiple of the interval the window was exact, and anywhere else it was widened by up to 0.5 s. A queue deleted in that tail was accepted, which the fixed sleep(30) it replaced would have failed. Sleeping only up to the remaining budget puts the last declare at the deadline, so the accepted window is exactly queue_removal_timeout_sec. Computing `remaining` once and reusing it for both the deadline test and the sleep means the sleep argument cannot go negative, so no clamp at zero is needed. Measured against the loop extracted verbatim from the test, sweeping the deadline across a whole sleep interval: worst-case overshoot 0.45 s before, 0.0002 s after. On a real broker with rabbitmqctl as independent ground truth, a delete 0.1 s past a 3.05 s budget is now rejected at 3.051 s, while a delete inside the budget and a still-present queue keep their previous verdicts. Identical on pika 1.3.2, which CI pins, and on 1.4.2.
|
The finding is correct, and it is fixed in fbc2433. The deadline was tested only after a successful passive declare and the loop then always slept a I took the second of the two suggested shapes, computing the remaining budget once and reusing it This reaches the sleep only when Verified on a real broker with |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units63 translation units recompiled, 226 s compile time in total, 63 of them have a recent master baseline. |
CI finish ledger - fbc2433e2fca7c7ba0b04b57adc4c5c4b1b39e9dCI is fully finished on this head and there are no failing checks. Praktika report: 176 leaves, 0 dropped jobs, 15 OK / 161 skipped, top-level
Session id: cron:our-pr-ci-monitor:20260812-053000 |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
test_rabbitmq_drop_table_properlyasserts the broker queue is gone afterDROP TABLE, andintermittently fails (7 hits / 4 PRs in 180 days for this assertion, 0 on master, all on slow
configurations). This PR makes the assertion precise. It does not fix the leak behind those
failures, and it does not hide it either.
The assertion wrapped the passive declare in
except Exception: exists = False, reading anyfailure as "queue gone", so a dead connection or a non-404 channel close passed while the queue
was still there. It now requires
reply_code == 404, andtime.sleep(30)becomes a bounded pollwith the same 30 s budget, so a passing run finishes in milliseconds. The budget is deliberately
not widened, which would accept a real leak, and not cut to one immediate check, which would
reject the legitimately late delete the original accepted.
The failures are a real engine defect, visible in the server logs of two of those runs: the
broker refuses the delete with
PRECONDITION_FAILED - queue '...' in use, 1 ms into a 1.5 msDROP.closeConnections()issueschannel->close()without awaitingclose-ok(
RabbitMQConsumer.cpp:50-54, fromStorageRabbitMQ.cpp:1012);cleanupRabbitMQ()then issuesremoveQueue(queue, AMQP::ifunused)on a different channel (:1086). AMQP 0-9-1 orders methodcompletion per channel, not across channels, so the table's own consumer can still be attached.
The queue is
AMQP::durablewith autodelete deliberately disallowed (:772-774), so it leakspermanently. Awaiting
close-okfixes this path but stalls everyDROPof a table that hasnacked, because
basic.nackis misclassified as synchronous incontrib/AMQP-CPPand the closeframe is then never sent. That is the prerequisite, so the leak stands and this test keeps
catching it.
Also pre-existing: with
rabbitmq_num_queues > 1the delete loop stops after the firstdelete-ok(StorageRabbitMQ.cpp:1092), leaving deletes 2..N unconfirmed.Version info
26.8.1.1228(included in26.8and later)