Repository navigation
Fix four bugs found while doing random pointless things - #112767
Conversation
None of these are Windows-specific; they are things the port happened to walk into. `FailPoint.cpp`'s `USE_LIBFIU=0` branch had drifted from the class it implements. It defined `enablePauseFailPoint`, `wait` and `enableFromGlobalConfig`, none of which `FailPointInjection` declares any more, and did not define `notifyPauseAndWaitForResume`, which it does. So a build configured with `-DENABLE_LIBFIU=OFF` failed to compile the file at all - four errors - and would have failed to link even without them. Verified by compiling the file with `USE_LIBFIU 0`: four errors before, clean after. `ReadBufferFromPocoSocketBase::setReceiveTimeout` took a count of microseconds and passed it to `Poco::Timespan(long seconds, long microseconds)`, so it set a timeout a million times longer than asked for. It has no callers, which is why nobody noticed. `KeeperNodeStats` packs three flags into the top bits of a `uint64_t` with `1ul << 63`, `1ul << 62` and `1ul << 61`, and checks the mask against `~(~0ul >> NUM_FLAGS)`. `unsigned long` is 32 bits on any LLP64 target, where all four of those are undefined behaviour and the constants come out wrong. Likewise `BinaryRow`'s `0x80L << 56` and `0x7FL << 56` for `Int64` constants. Same class as the two fixed in #112185; harmless on the platforms we ship, which is exactly why they survive. `ConfigProcessor.cpp` included `<sys/utsname.h>` without using anything from it. No tests: the failpoint fix is a build configuration CI does not exercise, the timeout has no callers to observe it through, and the shift constants have the right values on every platform we build for - they are only wrong where `long` is 32 bits. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [1fd68b1] Summary: ✅
AI ReviewSummaryThis PR fixes a handful of portability and configuration bugs found while cross-compiling for Windows, including the Findings❌ Blockers
Final VerdictChanges requested. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 0/1 (0.00%) · Uncovered code |
The style check flagged `ErrorCodes::SUPPORT_IS_DISABLED` as defined but not used after the removal of the stale `enableFromGlobalConfig` stub. Rather than dropping the error code, use it: the stubs reachable through `SYSTEM ENABLE|DISABLE|WAIT|NOTIFY FAILPOINT` now throw `SUPPORT_IS_DISABLED` instead of silently pretending to succeed, which would leave the caller waiting for a fail point that can never fire. The hooks called from regular code paths (`pauseFailPoint`, `notifyPauseAndWaitForResume`) remain no-ops. Verified that the file compiles both with `USE_LIBFIU=1` and `USE_LIBFIU=0`. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Ooh, I've definitely run into the LIBFIU thing before, thank you for fixing it! |
`disableFailPoint` is called unconditionally on quorum cleanup paths in `StorageReplicatedMergeTree` and `ReplicatedMergeTreeRestartingThread`, so throwing from the `USE_LIBFIU=0` stub would break replicated-table recovery in such builds. The SQL entrypoints in `InterpreterSystemQuery` already throw `SUPPORT_IS_DISABLED` when built without libfiu, so no behavior is lost for `SYSTEM DISABLE FAILPOINT`. Addresses the AI review finding. Co-Authored-By: Claude Fable 5 <[email protected]>
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 0/1 (0.00%) · Uncovered code |
| static constexpr uint64_t CONTAINER = 1ull << 61; | ||
| static constexpr uint64_t FLAGS_MASK = EPHEMERAL | TTL | CONTAINER; | ||
| static_assert(FLAGS_MASK == ~(~0ul >> NUM_FLAGS)); | ||
| static_assert(FLAGS_MASK == ~(~0ull >> NUM_FLAGS)); |
There was a problem hiding this comment.
This KeeperNodeStats mask fix stops at the struct definition. src/Coordination/Storage/Node.cpp:319 still does 0xfful << (64 - 8) in the serializer's static_assert, so on LLP64 the same 32-bit unsigned long shift remains and this portability fix is still incomplete for Keeper node serialization. Please switch that site to a 64-bit mask as well (for example 0xffull << 56 or uint64_t{0xff} << 56) in the same change.
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.12 (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 |
DB::SettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.12487241783113815285] |
8.7 s | gone | -9.7 s (-100%) |
programs/clickhouse-keeper |
DB::SettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.12487241783113815285] |
8.2 s | gone | -9.2 s (-100%) |
programs/clickhouse-keeper |
DB::registerFunctionConversion(DB::FunctionFactory&) |
6.7 s | 13.9 s | +6.4 s (+85%) |
programs/clickhouse |
DB::SettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.11069338206770680048] |
new | 6.1 s | +6.1 s |
programs/clickhouse-keeper |
_GLOBAL__sub_I_TargetLibraryInfo.cpp |
5.8 s | 11.4 s | +4.9 s (+76%) |
programs/clickhouse |
DB::Parquet::writeColumnChunkBody(DB::Parquet::ColumnChunkWriteState&, DB::Parquet::WriteOptions co… |
5.4 s | 3.2 s | -2.9 s (-48%) |
programs/clickhouse-keeper |
DB::ServerSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.54623650351436… |
new | 2.5 s | +2.5 s |
programs/clickhouse |
DB::getSettingsChangesHistory()::$_0::operator()() const |
4.5 s | 2.6 s | -2.5 s (-49%) |
programs/clickhouse-keeper |
DB::MergeTreeSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.56540966842… |
new | 2.3 s | +2.3 s |
programs/clickhouse |
DB::ServerSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.17566710545920… |
2.0 s | gone | -2.3 s (-100%) |
programs/clickhouse |
DB::Aggregator::writeToTemporaryFile(DB::AggregatedDataVariants&, unsigned long) const |
3.6 s | 1.8 s | -2.3 s (-56%) |
programs/clickhouse |
DB::attachSystemTablesServer(std::__1::shared_ptr<DB::Context const>, DB::IDatabase&, bool, bool) |
4.6 s | 3.0 s | -2.2 s (-43%) |
programs/clickhouse-keeper |
DB::registerFunctionVectorFunctions(DB::FunctionFactory&) |
2.2 s | 4.6 s | +2.1 s (+88%) |
programs/clickhouse-keeper |
_GLOBAL__sub_I_sqid.cpp |
1.7 s | 4.1 s | +2.1 s (+109%) |
programs/clickhouse |
DB::DatabaseDataLakeSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.9031… |
1.8 s | gone | -2.1 s (-100%) |
programs/clickhouse-keeper |
_ZN2DB18FunctionArrayIndexINS_16CountEqualActionENS_14NameCountEqualEE15executeIntegralIJDutjmDB8_s… |
2.0 s | 4.3 s | +2.1 s (+92%) |
programs/clickhouse |
DB::MergeTreeSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.16712493492… |
1.8 s | gone | -2.0 s (-100%) |
Compile time of recompiled translation units
78 translation units recompiled, 542 s compile time in total, 69 of them have a recent master baseline.
Translation units without a recent master baseline:
programs/keeper/Keeper.cpp (clickhouse-keeper): 6.2 s
Symbol sizes ⚠️
| Binary | Symbol | Master | PR | Δ |
|---|---|---|---|---|
programs/clickhouse |
DB::SettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.11069338206770680048] |
new | 439.45 KiB | +439.45 KiB |
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.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 |
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::ServerSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.17566710545920… |
114.16 KiB | removed | -114.16 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::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 |
DB::MergeTreeSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.16712493492… |
102.51 KiB | removed | -102.51 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::DatabaseDataLakeSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.9031… |
97.41 KiB | removed | -97.41 KiB (-100.00%) |
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 |
Four unrelated bugs found while cross-compiling ClickHouse for Windows. None of them are Windows-specific — the port just happened to walk into them.
1. Builds with
-DENABLE_LIBFIU=OFFdo not compile. TheUSE_LIBFIU=0branch ofFailPoint.cpphas drifted from the class it implements: it definesenablePauseFailPoint,waitandenableFromGlobalConfig, none of whichFailPointInjectiondeclares any more, and it does not definenotifyPauseAndWaitForResume, which it does. That is four compile errors, and an undefined symbol at link time even without them. Verified by compiling the file withUSE_LIBFIU 0— four errors before, clean after:The stubs only reachable through
SYSTEM ENABLE|WAIT|NOTIFY FAILPOINTnow throwSUPPORT_IS_DISABLEDinstead of silently pretending to succeed, which would leave the caller waiting for a fail point that can never fire. The hooks called from regular code paths (pauseFailPoint,notifyPauseAndWaitForResume, anddisableFailPoint, which runs unconditionally during quorum cleanup inStorageReplicatedMergeTree) remain no-ops;SYSTEM DISABLE FAILPOINTstill throws throughInterpreterSystemQuery, which rejects all failpoint commands when built without libfiu.2.
ReadBufferFromPocoSocketBase::setReceiveTimeoutsets a timeout a million times too long. It takes a count of microseconds and passes it toPoco::Timespan(long seconds, long microseconds), so the value lands in the seconds slot. It has no callers, which is why nobody noticed.3. Two more latent LLP64 bugs.
KeeperNodeStatspacks three flags into the top bits of auint64_twith1ul << 63,1ul << 62and1ul << 61, and checks the mask against~(~0ul >> NUM_FLAGS).unsigned longis 32 bits on any LLP64 target, where all four of those are undefined behaviour and the constants come out wrong. Same forBinaryRow's0x80L << 56and0x7FL << 56, which buildInt64constants. This is the same class as the two fixed in #112185 — harmless on the platforms we ship, which is exactly why they survive.4.
ConfigProcessor.cppincludes<sys/utsname.h>without using anything from it.No tests. The failpoint fix is a build configuration CI does not exercise; the timeout has no callers to observe it through; and the shift constants have the right values on every platform we build for, so a test would pass equally before and after.
Related: #112185
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed
ReadBufferFromPocoSocketBase::setReceiveTimeoutapplying its argument as seconds rather than microseconds, and fixed builds configured with-DENABLE_LIBFIU=OFF, which did not compile. In builds without libfiu,SYSTEM ENABLE FAILPOINTand related commands now throw an exception instead of silently doing nothing.Documentation entry for user-facing changes
🤖 Generated with Claude Code