Repository navigation
Conversation
…he looping task A direct SELECT leaves the looping task running the event loop of the table's connection. StorageRabbitMQ::threadFunc checked isConnected() and called reconnect() at the start of every streaming cycle without stopping that task, unlike read() and streamToViews(). After the broker dropped the connection, the streaming task closed and replaced the AMQP::TcpConnection while the looping task was still processing the loss on it (TSan STID 3628-42d9, La Casa Del Dolor). Since ClickHouse#131355 the loop blocks in the poller, so that reconnect also could not complete until the SELECT ended. restoreConnection() stops the loop, waits for the looping task and then reconnects, as unbindExchange() already does. threadFunc() and read() call it under loop_mutex, so the other one cannot restart the loop in between, and both test the handler's atomic connectionRunning() instead of reading AMQP state while the loop may run. The new integration test drops the connection during a long direct SELECT and requires a reconnect within 10 s. 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; 3 findings; bounded: 1 full pass + 1 fix round + 1 delta recheck).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261123-005000 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-41:20261122-233301 |
|
Workflow [PR], commit [7cdc04c] Summary: ✅
AI ReviewSummaryReviewed #133632 at Missing context / blind spots
Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units8 translation units recompiled, 17 s compile time in total, 8 of them have a recent master baseline. |
Related: #131355
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Description
La Casa Del Dolor (amd_tsan)reportedThreadSanitizer: data race (STID: 3628-42d9): https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=122537&sha=092a5cded0a8ede0c5ab2a798a094f10ceaccc45&name_0=PR&name_1=La%20Casa%20Del%20Dolor%20%28amd_tsan%29The AMQP connection and its libuv loop are single-threaded, and a direct
SELECTleaves the looping task running that loop. At the start of every streaming cycleStorageRabbitMQ::threadFunccalledconnection->isConnected() || connection->reconnect()without stopping the looping task, unlikeread()andstreamToViews(). When the broker dropped the connection during a directSELECT(La Casa does it at random since #131994), the streaming task closed and replaced theAMQP::TcpConnectionwhile the looping task was still processing the loss on it. Since #131355 the loop sleeps in the poller, so on master that reconnect also cannot complete until theSELECTends.The fix adds
restoreConnection(): stop the loop, wait for the looping task to finish, reconnect, asunbindExchange()already does.threadFunc()andread()call it underloop_mutex, so neither can restart the loop in between, and both check the handler's atomicconnectionRunning()instead of reading AMQP state while the loop may run.Not changed: with
rabbitmq_commit_on_select = 1a directSELECTstill sends its ack from the query thread while the loop may run, a separate pre-existing path.No stable release shows a user-visible effect: the delayed reconnect needs #131355, which is in the
26.11branch but in no stable release yet, hence not a bug fix.Validation: the new integration test
test_rabbitmq_reconnect_during_direct_selectdrops the connection through the management API during a 20 s directSELECTand requires a reconnect within 10 s. Without the fix it fails 4/4 on a debug build, and the CI TSan binary reports the same race pair. With the fix it passes 11/11 on debug and 3/3 on TSan without reports;test_system_stop.pyand the other reconnect and direct-select tests pass on both builds.Workflow [PR]
Sync PR [sync-upstream/pr/133632]