Repository navigation
Fix lost progress update in clickhouse-local - #112958
Conversation
`LocalConnection::receivePacket` built the `Progress` packet with `fetchAndResetPiecewiseAtomically`, which already zeroes every counter atomically, and then called `reset` on the same object. The pipeline keeps incrementing those counters from its own threads while the main thread sits between the two statements, so an increment that landed in that window was thrown away instead of being reported. The extra `reset` is a leftover from when the packet was built with `std::move`. The result is that a query run through `clickhouse-local` could under-report `rows_read` (and every other progress counter) in the `statistics` of the `JSON`/`XML` output and in the progress bar, always by a whole multiple of a block. This is what made `04651_parquet_v3_dictionary_filter_expanding_codec_budget` flaky: the test compares the reported `rows_read` of the same query run under two memory budgets, and one of the two runs reported 54591 instead of 120000 - exactly one lost block of the default 65409 rows. https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=42d5246e282b55b1d6340059a5c3794905d92b99&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_tsan%2C%20s3%20storage%2C%20parallel%2C%201%2F3%29&name_1=Stateless%20tests%20%28amd_tsan%2C%20s3%20storage%2C%20parallel%2C%201%2F3%29 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [2d95ee1] Summary: ✅
AI ReviewSummaryThis PR removes the redundant Final Verdict✅ No blocking or major issues found. No new inline review comments were posted. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 4/4 (100.00%) · Uncovered code |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 4/4 (100.00%) · Uncovered code |
alexey-milovidov
left a comment
There was a problem hiding this comment.
Good.
CC @PedroTadim
PedroTadim
left a comment
There was a problem hiding this comment.
LGTM! Let's wait for the CI
|
@alexey-milovidov check the failed test |
Build profile diff (arm_release)Comparing 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. Object file sizes
|
| Object file | Master | PR | Δ |
|---|---|---|---|
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/ext/transport/chttp2/transport/cht… |
960.56 KiB | removed | -960.56 KiB (-100.00%) |
src/Common/ZooKeeper/CMakeFiles/clickhouse_common_zookeeper_no_log.dir/ZooKeeperImpl.cpp.o |
804.97 KiB | removed | -804.97 KiB (-100.00%) |
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/server/server.cc.o |
612.22 KiB | removed | -612.22 KiB (-100.00%) |
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/load_balancing/rls/rls.cc.o |
611.36 KiB | removed | -611.36 KiB (-100.00%) |
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/client_channel/client_channel_filt… |
548.04 KiB | removed | -548.04 KiB (-100.00%) |
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/client_channel/client_channel.cc.o |
525.46 KiB | removed | -525.46 KiB (-100.00%) |
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/client_channel/retry_interceptor.c… |
518.85 KiB | removed | -518.85 KiB (-100.00%) |
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/lib/channel/promise_based_filter.c… |
482.91 KiB | removed | -482.91 KiB (-100.00%) |
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/load_balancing/grpclb/grpclb.cc.o |
434.97 KiB | removed | -434.97 KiB (-100.00%) |
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/call/client_call.cc.o |
433.89 KiB | removed | -433.89 KiB (-100.00%) |
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/call/server_call.cc.o |
391.29 KiB | removed | -391.29 KiB (-100.00%) |
contrib/grpc-cmake/CMakeFiles/grpc++_unsecure.dir/__/grpc/src/cpp/server/server_cc.cc.o |
384.88 KiB | removed | -384.88 KiB (-100.00%) |
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/client_channel/retry_filter_legacy… |
369.55 KiB | removed | -369.55 KiB (-100.00%) |
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/ext/transport/chttp2/transport/wri… |
349.81 KiB | removed | -349.81 KiB (-100.00%) |
contrib/google-cloud-cpp-cmake/CMakeFiles/google_cloud_cpp_grpc_utils.dir/__/google-cloud-cpp/googl… |
346.93 KiB | removed | -346.93 KiB (-100.00%) |
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/ext/transport/inproc/legacy_inproc… |
345.35 KiB | removed | -345.35 KiB (-100.00%) |
contrib/google-cloud-cpp-cmake/CMakeFiles/google_cloud_cpp_longrunning_operations_protos.dir/google… |
339.33 KiB | removed | -339.33 KiB (-100.00%) |
contrib/google-cloud-cpp-cmake/CMakeFiles/google_cloud_cpp_iam_credentials_v1_iamcredentials_protos… |
334.24 KiB | removed | -334.24 KiB (-100.00%) |
contrib/google-protobuf-cmake/CMakeFiles/_libprotobuf-lite.dir/__/google-protobuf/src/google/protob… |
316.58 KiB | removed | -316.58 KiB (-100.00%) |
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/call/call_spine.cc.o |
312.88 KiB | removed | -312.88 KiB (-100.00%) |
Slowest function optimization changes (ThinLTO) ⚠️
Median per-function time ratio to the master baseline is ×1.30 (different machine and build flags); deltas below are relative to that ratio.
| Binary | Function | Master | PR | Δ vs median |
|---|---|---|---|---|
programs/clickhouse-keeper |
DB::SettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.11069338206770680048] |
new | 17.9 s | +17.9 s |
programs/clickhouse-keeper |
DB::SettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.12487241783113815285] |
7.9 s | gone | -10.2 s (-100%) |
programs/clickhouse |
DB::SettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.12487241783113815285] |
7.8 s | gone | -10.1 s (-100%) |
programs/clickhouse |
DB::SettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.11069338206770680048] |
new | 7.8 s | +7.8 s |
programs/clickhouse-keeper |
DB::registerFunctionConversion(DB::FunctionFactory&) |
6.0 s | 15.5 s | +7.6 s (+98%) |
programs/clickhouse-keeper |
_GLOBAL__sub_I_TargetLibraryInfo.cpp |
5.6 s | 12.0 s | +4.7 s (+64%) |
programs/clickhouse |
DB::Parquet::writeColumnChunkBody(DB::Parquet::ColumnChunkWriteState&, DB::Parquet::WriteOptions co… |
5.0 s | 3.6 s | -3.0 s (-45%) |
programs/clickhouse-keeper |
DB::ServerSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.54623650351436… |
new | 2.9 s | +2.9 s |
programs/clickhouse |
DB::getSettingsChangesHistory()::$_0::operator()() const |
4.3 s | 2.9 s | -2.7 s (-48%) |
programs/clickhouse-keeper |
DB::MergeTreeSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.56540966842… |
new | 2.6 s | +2.6 s |
programs/clickhouse |
DB::Aggregator::writeToTemporaryFile(DB::AggregatedDataVariants&, unsigned long) const |
3.4 s | 1.9 s | -2.5 s (-57%) |
programs/clickhouse |
DB::attachSystemTablesServer(std::__1::shared_ptr<DB::Context const>, DB::IDatabase&, bool, bool) |
4.3 s | 3.2 s | -2.4 s (-43%) |
programs/clickhouse-keeper |
_ZN2DB18FunctionArrayIndexINS_16CountEqualActionENS_14NameCountEqualEE15executeIntegralIJDutjmDB8_s… |
1.7 s | 4.5 s | +2.3 s (+104%) |
programs/clickhouse-keeper |
_GLOBAL__sub_I_sqid.cpp |
1.7 s | 4.4 s | +2.3 s (+105%) |
programs/clickhouse |
DB::ServerSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.17566710545920… |
1.7 s | gone | -2.2 s (-100%) |
programs/clickhouse-keeper |
DB::ServerSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.17566710545920… |
1.6 s | gone | -2.1 s (-100%) |
Compile time of recompiled translation units
7 translation units recompiled, 12 s compile time in total, 7 of them have a recent master baseline.
Symbol sizes ⚠️
| Binary | Symbol | Master | PR | Δ |
|---|---|---|---|---|
programs/clickhouse |
DB::SettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.12487241783113815285] |
439.45 KiB | removed | -439.45 KiB (-100.00%) |
programs/clickhouse-keeper |
DB::SettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.12487241783113815285] |
439.45 KiB | removed | -439.45 KiB (-100.00%) |
programs/clickhouse-keeper |
DB::SettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.11069338206770680048] |
new | 439.45 KiB | +439.45 KiB |
programs/clickhouse |
DB::SettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.11069338206770680048] |
new | 439.45 KiB | +439.45 KiB |
programs/clickhouse |
DB::ServerSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.17566710545920… |
114.16 KiB | removed | -114.16 KiB (-100.00%) |
programs/clickhouse |
DB::ServerSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.54623650351436… |
new | 114.16 KiB | +114.16 KiB |
programs/clickhouse-keeper |
DB::ServerSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.17566710545920… |
114.16 KiB | removed | -114.16 KiB (-100.00%) |
programs/clickhouse-keeper |
DB::ServerSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.54623650351436… |
new | 114.16 KiB | +114.16 KiB |
programs/clickhouse |
DB::MergeTreeSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.16712493492… |
102.51 KiB | removed | -102.51 KiB (-100.00%) |
programs/clickhouse |
DB::MergeTreeSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.56540966842… |
new | 102.51 KiB | +102.51 KiB |
programs/clickhouse-keeper |
DB::MergeTreeSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.16712493492… |
102.51 KiB | removed | -102.51 KiB (-100.00%) |
programs/clickhouse-keeper |
DB::MergeTreeSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.56540966842… |
new | 102.51 KiB | +102.51 KiB |
programs/clickhouse |
DB::DatabaseDataLakeSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.9031… |
97.41 KiB | removed | -97.41 KiB (-100.00%) |
programs/clickhouse |
DB::DatabaseDataLakeSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.1111… |
new | 97.41 KiB | +97.41 KiB |
programs/clickhouse |
DB::ObjectStorageQueueSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.14… |
new | 92.15 KiB | +92.15 KiB |
programs/clickhouse |
DB::ObjectStorageQueueSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.10… |
92.15 KiB | removed | -92.15 KiB (-100.00%) |
programs/clickhouse |
DB::KafkaSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.872715978862839… |
new | 89.47 KiB | +89.47 KiB |
programs/clickhouse |
DB::KafkaSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.176316896530569… |
89.47 KiB | removed | -89.47 KiB (-100.00%) |
programs/clickhouse |
DB::DataLakeStorageSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.41967… |
88.38 KiB | removed | -88.38 KiB (-100.00%) |
programs/clickhouse |
DB::DataLakeStorageSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.13841… |
new | 88.38 KiB | +88.38 KiB |
…tic placement The test asserts that the first `ORDER BY k ASC LIMIT 5` run under the TopK plan writes a query condition cache entry (`count() > 0`). An entry is only written when at least one chunk is reduced to zero rows at the `WHERE` filter, which depends on where the smallest `w = 7` rows happen to land: placement was `rand()`, so a run could get a `__topKFilter` threshold trajectory under which every chunk kept at least one row and no entry was written (2 of 300 runs in a local loop on a release build). ClickHouse#111492 made this much more likely by shrinking the table from 1M rows (~123 chunks per scan) to 100k (~12 chunks); the same mode had been seen once with 1M rows on a flaky-check job before that. Place the five smallest `w = 7` rows at the front of the part and scatter every other row with a deterministic hash above the first chunk: the threshold tracker arms at its final value (`k = 4007`) right after the first chunk, and every later chunk deterministically empties at the `WHERE` filter and is recorded (1436 of 1564 marks). Verified locally: 30/30 runs pass, plus 10/10 with the failing run's randomized settings; the reference output is unchanged. Failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112958&sha=ab076f814382fccafac0dd27dbe5e152d7204619&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20sequential%2C%202%2F2%29 PR with the failure: ClickHouse#112958 Co-Authored-By: Claude Fable 5 <[email protected]>
LocalConnection::receivePacketbuilt theProgresspacket withfetchAndResetPiecewiseAtomically, which already zeroes every counter atomically, and then calledreseton the same object. The pipeline keeps incrementing those counters from its own threads while the main thread sits between the two statements, so an increment that landed in that window was thrown away instead of being reported. The extraresetis a leftover from the time when the packet was built withstd::move.The visible effect is that a query run through
clickhouse-localcould under-reportrows_read(and the other progress counters) in thestatisticsof theJSON/XMLoutput and in the progress bar, always losing a whole block at a time.This is what made
04651_parquet_v3_dictionary_filter_expanding_codec_budgetflaky on master. The test compares the reportedrows_readof the same query run under two memory budgets, and one of the two runs reported54591instead of120000- exactly one lost block of the default 65409 rows. Both master failures so far show the same54591.CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=42d5246e282b55b1d6340059a5c3794905d92b99&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_tsan%2C%20s3%20storage%2C%20parallel%2C%201%2F3%29&name_1=Stateless%20tests%20%28amd_tsan%2C%20s3%20storage%2C%20parallel%2C%201%2F3%29
The race window is only a handful of atomic operations wide, so an ordinary query almost never hits it - the test failed twice out of roughly 700 runs. Lowering
interactive_delaymakes the packet be assembled far more often and a smallmax_block_sizemakes every lost increment visible, which turns it into a reliable reproducer:Before:
19999000,19998000,20000000(two of three runs lose one or two blocks). After: 35 out of 35 runs report20000000. The added test04669_local_progress_lost_updateis that reproducer.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
clickhouse-localunder-reportingrows_readand the other progress counters in thestatisticsof theJSON/XMLoutput and in the progress bar: a progress increment that arrived while the progress packet was being assembled was discarded.Documentation entry for user-facing changes