Repository navigation
Cross-compile ClickHouse for Windows - #112824
alexey-milovidov wants to merge 396 commits into
Conversation
|
Workflow [PR], commit [e46add2] Summary: ❌
AI ReviewSummaryAdds a native Windows cross-build, platform implementations for file I/O, sockets and console handling, and Wine smoke coverage. The current code contains two Linux regressions and Windows file-identity, durability and console-lifecycle defects. Three new safety findings require blocking approval. Previously dismissed findings that remain valid are recorded below without renewed inline discussion. Missing context / blind spots
Findings❌ Blockers
💡 Nits
Tests
Final VerdictStatus: ❌ Block Correct the three new safety defects, the absolute-path Iceberg deletion regression and console cleanup, with focused regression evidence. The dismissed findings remain recorded for maintainer disposition; no dismissed thread was replied to or reopened. |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
The job failed to compile libc++'s `filesystem/path.cpp`: Ubuntu 24.04 ships mingw-w64 11, whose headers and `libmsvcrt.a` lack the `_l`-suffixed per-locale CRT functions (`_iswctype_l`, ...) that the libc++ 22 locale support calls. The failure only surfaced now because the job previously built `clickhouse-windows-ported`, which never compiled that translation unit. Install `mingw-w64-common` and `mingw-w64-x86-64-dev` 13.0.0 from Launchpad's permanent per-file archive instead: both are data-only `all`-architecture packages (headers and import libraries, no host binaries) depending only on each other, verified by SHA-256. Compiling the failing translation unit against a sysroot extracted from exactly these two packages was verified locally. Also sync `docs/resources/develop-contribute/build/build-cross-windows.mdx` (the published tree) with the rewritten `docs/en` page, which had gone stale, and document the mingw-w64 version requirement in both. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112824&sha=8e2d398de135f758d71a3c1709aad95a51634042&name_0=PR&name_1=Build%20%28amd_windows%29 PR: #112824 Co-Authored-By: Claude Fable 5 <[email protected]>
Two changes on master do not compile for the Windows target: - The frozen-clone fsync (#111426) passes an `fs::path` to `fsyncFrozenCloneTree`, relying on the implicit `path`/`std::string` conversion that only exists on POSIX. Route it through `pathToGenericString`, like every other disk-path construction site. - The directory-name length check for async distributed INSERT moved from `Cluster.cpp` to `DistributedSink::checkDirectoryNameLengths`, bringing back a bare `NAME_MAX`, which Windows does not define. Reintroduce the `max_path_component_length` constant this branch had used in `Cluster.cpp` (where master removed the check) at the new site. PR: #112824 Co-Authored-By: Claude Fable 5 <[email protected]>
The Windows branch of `setupSignalHandler` assumed the interactive loop installs `InterruptListener`, but the client never does - only `benchmark` and `keeper-bench` use it - so Ctrl+C fell through to the default console behavior and ended the process instead of stopping the query. Install a console control handler mirroring `interruptSignalHandler`: the first Ctrl+C (or Ctrl+Break) requests a stop through `tryStopQuery`, a repeated one exits. `ENABLE_PROCESSED_INPUT` in the keystroke interceptor is deliberately kept on and now documented: it is the counterpart of `ISIG`, which the POSIX raw mode keeps on as well, so Ctrl+C reaches the new console control handler instead of becoming a key event that no registered callback would consume. The embedded client's `0x03` callback is fed by an SSH stream that never passes through a Windows console. PR: #112824 Co-Authored-By: Claude Fable 5 <[email protected]>
Turning the traversal paths from `fs::path` into plain strings for the Windows port also changed the user-visible output of `delete_stale_backups`: streaming an `fs::path` prints it quoted, streaming a `String` does not. `test_keeper_client/test.py::test_delete_stale_backups` pins the quoted form and failed on every integration shard. Restore the quotes explicitly. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112824&sha=8e2d398de135f758d71a3c1709aad95a51634042 PR: #112824 Co-Authored-By: Claude Fable 5 <[email protected]>
|
🕵 Status of this pass (commits
|
|
I read the
One correction on the frame. The So this is plan-time per-child re-analysis inside Two separate defects sit behind that row, and one of them is already yours. Cost. The query has a JOIN, so Interruptibility. #113140 does not add a cancellation point, and On #112203: same class, different site. That issue is per-value function evaluation during constant folding, whereas this is the per-child loop inside Separately, this report lost its server-side |
|
🕵 Status of this pass (commits
|
|
Fixing PR for the I had a fix for this on a local branch, but @alexey-milovidov opened #113415 with the identical |
|
🕵 Status of this pass (commits
|
Build profile diff (arm_release)Comparing Binary sizes
The official master build is compiled with Object file sizes
|
| Object file | Master | PR | Δ |
|---|---|---|---|
src/Dictionaries/CMakeFiles/clickhouse_dictionaries.dir/HashedDictionary.cpp.o |
19.77 MiB | 4.14 MiB | -15.63 MiB (-79.06%) |
src/Dictionaries/CMakeFiles/clickhouse_dictionaries.dir/SparseHashedDictionary.cpp.o |
21.09 MiB | 5.80 MiB | -15.29 MiB (-72.50%) |
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/polygonsSymDifference.cpp.o |
17.39 MiB | 6.62 MiB | -10.77 MiB (-61.93%) |
src/CMakeFiles/dbms.dir/Functions/FunctionsConversion.cpp.o |
24.64 MiB | 14.21 MiB | -10.43 MiB (-42.35%) |
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/FunctionsNumericIndexedVector.cpp.o |
19.51 MiB | 9.31 MiB | -10.21 MiB (-52.31%) |
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/modulo.cpp.o |
17.43 MiB | 9.59 MiB | -7.84 MiB (-45.00%) |
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/polygonsIntersection.cpp.o |
10.80 MiB | 4.08 MiB | -6.72 MiB (-62.25%) |
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/polygonsUnion.cpp.o |
10.73 MiB | 4.06 MiB | -6.66 MiB (-62.12%) |
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/polygonsDistance.cpp.o |
9.25 MiB | 2.80 MiB | -6.46 MiB (-69.75%) |
src/CMakeFiles/dbms.dir/Functions/if.cpp.o |
11.51 MiB | 5.95 MiB | -5.56 MiB (-48.31%) |
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/intDiv.cpp.o |
11.61 MiB | 6.26 MiB | -5.35 MiB (-46.11%) |
src/Functions/array/CMakeFiles/clickhouse_functions_array.dir/arrayElement.cpp.o |
10.20 MiB | 5.08 MiB | -5.12 MiB (-50.19%) |
src/Functions/array/CMakeFiles/clickhouse_functions_array.dir/arrayDistance.cpp.o |
10.11 MiB | 5.25 MiB | -4.87 MiB (-48.13%) |
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/geometryIntersect.cpp.o |
7.04 MiB | 2.23 MiB | -4.81 MiB (-68.31%) |
src/Dictionaries/CMakeFiles/clickhouse_dictionaries.dir/HashedArrayDictionary.cpp.o |
8.08 MiB | 3.35 MiB | -4.73 MiB (-58.51%) |
src/Functions/array/CMakeFiles/clickhouse_functions_array.dir/arraySort.cpp.o |
7.29 MiB | 2.76 MiB | -4.53 MiB (-62.14%) |
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/FunctionsRound.cpp.o |
8.64 MiB | 4.21 MiB | -4.42 MiB (-51.22%) |
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/divide.cpp.o |
9.61 MiB | 5.19 MiB | -4.42 MiB (-45.96%) |
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/plus.cpp.o |
8.74 MiB | 4.57 MiB | -4.17 MiB (-47.70%) |
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/greaterOrEquals.cpp.o |
8.56 MiB | 4.45 MiB | -4.11 MiB (-48.05%) |
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.
Slowest function optimization changes (ThinLTO)
Median per-function time ratio to the master baseline: programs/clickhouse ×0.68, programs/clickhouse-keeper ×0.64 (each binary is linked separately, on a different machine and with different build flags); deltas below are relative to it.
| Binary | Function | Master | PR | Δ vs median |
|---|---|---|---|---|
programs/clickhouse |
DB::SettingsTraits::Accessor::instance()::$_0::operator()() const |
10.5 s | 17.7 s | +10.5 s (+146%) |
Compile time of recompiled translation units
16491 translation units recompiled, 33934 s compile time in total, 15985 of them have a recent master baseline.
| Translation unit | Master | PR | Δ vs median |
|---|---|---|---|
contrib/arrow-cmake/__/arrow/cpp/src/arrow/compute/api_scalar.cc |
6.7 s | 12.5 s | +6.1 s (+94%) |
contrib/arrow-cmake/__/arrow/cpp/src/arrow/compute/kernels/scalar_nested.cc |
9.5 s | 15.1 s | +5.9 s (+64%) |
contrib/arrow-cmake/__/arrow/cpp/src/arrow/compute/kernels/scalar_cast_numeric.cc |
12.2 s | 17.5 s | +5.6 s (+47%) |
contrib/arrow-cmake/__/arrow/cpp/src/arrow/compute/kernels/aggregate_mode.cc |
7.6 s | 12.9 s | +5.5 s (+75%) |
contrib/arrow-cmake/__/arrow/cpp/src/arrow/compute/kernels/vector_run_end_encode.cc |
5.9 s | 11.2 s | +5.5 s (+95%) |
contrib/arrow-cmake/__/arrow/cpp/src/arrow/compute/kernels/scalar_compare.cc |
10.4 s | 15.4 s | +5.3 s (+52%) |
contrib/arrow-cmake/__/arrow/cpp/src/arrow/compute/kernels/hash_aggregate.cc |
11.7 s | 16.5 s | +5.1 s (+45%) |
Translation units without a recent master baseline:
programs/keeper/Keeper.cpp (clickhouse-keeper): 7.9 s
Winsock startup lived only in a static initializer in `Net.cpp`, a translation unit of the static library `_poco_net` that nothing references, so the linker could drop it and the first socket call would fail with `WSANOTINITIALISED`. Call `Poco::Net::initializeNetwork` from `main` on Windows: the reference forces `Net.cpp` into the link (its initializer then runs before `main`) and starts Winsock even if the initializer were compiled out. Addresses the AI review blocker on #112824 Co-Authored-By: Claude Fable 5 <[email protected]>
`history_file_path` is UTF-8, but the history code interpreted it through the active code page on Windows: `open` in the `ReplxxLineReader` constructor, the `std::ifstream` / `std::ofstream` in `convertHistoryFile`, and replxx's own file opens inside `history_load(std::string)` / `history_save(std::string)`. A profile directory containing a character outside the code page silently lost history load and save. Add `platformOpenReadWrite` (`_wopen` on Windows) to `PlatformFileIO`, open the conversion streams by `std::filesystem::path` - wide on Windows - and use replxx's stream overloads on Windows, reproducing the merge-then-write behavior of `history_save(std::string)` under the exclusive lock the reader already holds. Addresses the AI review Major on #112824 Co-Authored-By: Claude Fable 5 <[email protected]>
|
🕵 Status of this pass (commits
|
The parent of a root path such as `X:/` (or `/`) is the root itself, so when the volume is unavailable `getStatVFS` and `enoughSpaceInDirectory` retried the same failing call forever. Stop when the parent equals the current path and surface the error. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # .github/workflows/master.yml # CMakeLists.txt # programs/benchmark/Benchmark.cpp # src/Backups/BackupMetadataFinder.cpp # src/Common/AlignedBuffer.cpp # src/Common/EnvironmentChecks.cpp # src/Common/ZooKeeper/KeeperClientCLI/KeeperClient.cpp # src/Common/memory.h # src/Disks/LocalDirectorySyncGuard.cpp # src/Processors/QueryPlan/Optimizations/RuntimeDataflowStatistics.cpp # src/Storages/MergeTree/MergeTreeData.cpp # src/Storages/MergeTree/MergeTreeMutationEntry.cpp # src/Storages/StorageStripeLog.cpp
The split reading path that came from master computed the file cache version token from a `struct stat`, but this branch builds the token from `PlatformFileVersion` (the CRT `stat` on Windows has whole-second timestamps and a zero `st_ino`). Read the version with `platformFileVersion` and the metadata with `platformStat`, as the other call sites do. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged
The Linux build passes, and a parallel CSV read through |
Conflict resolutions: - `checkStackSize.cpp`: keep the platform-split includes of the branch, add `Common/Silk/FiberScheduler.h` from master. - `ICatalog.cpp`: take the endpoint-path-segment check from master, keep the key-space joins of the branch. - `MetadataStorageFromStaticFilesWebServer.cpp`: keep `makeRemotePath` of the branch. - `MMappedFileDescriptor.cpp`: the new `MADV_DONTNEED` before `munmap` goes into the POSIX branch. - `DataLakes/Common/Common.cpp`: take `listPrefixImpl` / `listPrefixNonRecursive` from master, joining the directory key in key space via a new `keyDirectory` helper instead of `std::filesystem::path`. - `test_disk_over_web_server/test.py`: keep the tests from both sides.
The `fs::path` to `String` conversion does not exist on Windows, where the native string is wide. Convert with `pathToGenericString`, like the other paths in this file. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=112824&sha=fbdebc9a3520e2786d5baa92ebe25a05e82cfb0d&name_0=PR&name_1=Build%20%28amd_windows%29 PR: #112824 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ring` `KeeperClientBase::getAbsolutePath` returns a `String` in this branch, so there is no `.string` to call. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=112824&sha=fbdebc9a3520e2786d5baa92ebe25a05e82cfb0d&name_0=PR&name_1=Build%20%28arm_tidy%2C%202%2F4%29 PR: #112824 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cache On current `master` `SELECT sum(a), count()` from the table is answered without reading any column, so no file segment was cached and the test saw an empty `system.filesystem_cache`. Reproduced with a `master`-based binary; also reading `sum(length(b))` makes the query go through the cache again. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=112824&sha=fbdebc9a3520e2786d5baa92ebe25a05e82cfb0d&name_0=PR&name_1=Fast%20test PR: #112824 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged
The Windows cross build was not verified locally, so the next |
Conflicts resolved: - `contrib/replxx`: point at ClickHouse/replxx 6650850 (merge of #54), which contains both the Windows `Terminal::read_unicode_character` from this branch and the synchronized refresh from master. - `src/Client/ClientBase.cpp`: keep the `use_replxx` structure of this branch and add the `.vim` option from master. - `src/Formats/FormatSchemaInfo.cpp`: keep the `pathFromString` / `pathToGenericString` conversion of this branch. - `src/Interpreters/FileCache/FileCache.cpp`: take master's `fiu_do_on`, which also builds without libfiu. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged
The Linux (aarch64) |
Conflicts: - `ci/workflows/pull_request.py`: master moved part of the special builds to the merge queue (`special_build_pr_jobs`); `SPECIAL_BUILD_JOBS_EXCEPT_WINDOWS` now filters that list. - `programs/local/LocalServer.cpp`: took master's persistent `system` database logic, with `path` kept as `fs::path` and the warning formatted through `pathToString`. - `src/Backups/BackupIO_Default.cpp`: kept both sides' includes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hen stdout is not a console The Windows backend of replxx renders through the console screen buffer of the output handle and does not check that it is one. `ClientBase` already fell back to the basic `LineReader` then, but `DisksApp` and `KeeperClient` built `ReplxxLineReader` unconditionally. The check is now `ReplxxLineReader::canRenderTo`, shared by all three users. Address review: #112824 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged
The changed files build on Linux. The Windows build was not run locally; CI will build it. |
Conflicts in 27 files. Resolutions that are more than taking both sides: - `ReplxxLineReader.cpp`: master replaced `skim` with the built-in `pickFromHistory` and creates the history file in `open` with `O_CREAT`. The file is now opened through `platformOpenFile` with `O_RDWR | O_CREAT`, the unused `platformOpenReadWrite` is removed, and the picker is not bound on Windows, where the console is not a byte stream (as before, when `skim` was not built there). - `DisksApp.cpp`, `KeeperClient.cpp`: took master's removal of the separate history file creation. - `SocketPeerClosed.cpp`: master moved `ScopedNonBlocking` to its own header. - `UTF8Helpers.cpp`, `widechar_width.h`: took master's rewrite; it takes `uint32_t`, so the `char32_t` change of this branch is no longer needed. - `isLocalAddress.cpp`, `MetadataStorageFromStaticFilesWebServer.h`: master only added `[[nodiscard]]` to code that this branch removed. - `IObjectStorage.h`: master's `stripQueryAndFragment` with the string `last_component` of this branch instead of `std::filesystem::path`. - The rest keep master's changes with the path helpers of this branch (`pathToGenericString`, `pathFromString`, `zkutil::joinZooKeeperPath`, `zkutil::zooKeeperNodeName`) and the `OS_WINDOWS` guards. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…erge Master updated `contrib/llvm-project` and made the minimal Thrift library a part of every build: - `locale_win32.cpp` tests a `std::from_chars_result` as a `bool`, which is C++26, so it is compiled with `-std=c++26`, like `text_encoding.cpp`. - `cxa_thread_atexit.cpp` takes the secret for the `thread_local` destructor pointers from `getentropy` everywhere but on Linux. Windows has none, so a force-included header provides it through `RtlGenRandom`. - `_thrift_minimal` is now built with `ENABLE_LIBRARIES=OFF` too, and the generated `thrift/config.h` claimed the POSIX socket headers (`netinet/in.h` and others) on every platform. They are not set on Windows anymore. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…lows `ci/workflows/master.py` took its special builds from `SPECIAL_BUILD_JOBS_EXCEPT_WINDOWS`, which, since the merge queue got some of them, is the list of the pull request workflow only. So the generated `master.yml` lost `Build (amd_darwin)` and the other cross-compiled builds, and `Check Workflows` failed with "workflows are outdated": .github/workflows/master.yml. `MasterCI` now takes every special build except the Windows one, which it starts separately. The previous commit also picked up three workflow files regenerated before this fix. That was a mistake: this commit puts them back as they were, and the regenerated `master.yml` is now the same as the committed one. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=112824&sha=6bcfee47ba2bfd6e0b4497668620f714aa541a3b&name_0=PR&name_1=Config%20Workflow #112824 Co-Authored-By: Claude Fable 5.2 <[email protected]>
New code on master that does not compile for Windows: - `BackupIO_Disk.cpp`, `MergeCheckpoint.cpp`, `MergeTask.cpp`, `MergeTreeDataPartBuilder.cpp`: a `std::filesystem::path` was converted to a `String` implicitly. It goes through `pathToGenericString` now. - `ObjectStorageQueueOrderedFileMetadata.cpp`: ZooKeeper paths were joined as `std::filesystem::path`. They use `zkutil::joinZooKeeperPath` now. - `ParallelSyncFiles.cpp`: `fdatasync` and `open` are replaced with `platformFDataSync` and `platformOpenFile`. - `retryTransientStoreError.cpp`: the Windows CRT has no `EDQUOT`. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
🕵 Merged
Built locally: The five open review threads have no new comments since the last replies. Three of them (backslashes in |
Conflicts: - `.github/workflows/master.yml`: took master's version and regenerated it with `python3 -m ci.praktika yaml`, which adds `Build (amd_windows)` back. - `programs/CMakeLists.txt`: master removed the `install` steps and renamed `clickhouse_program_install` to `clickhouse_program_link`. Kept this branch's `NOT OS_WINDOWS` guards around the symlink aliases and its optional programs. - `DiskLocal.cpp`, `DatabaseCatalog.cpp`: master removed `DiskLocal::chmod` and the cleanup of the `store` directory, so the Windows adaptations of them go away. - `FormatSchemaInfo.cpp`: took master's `fs::rename`, which replaces the `renameExchange` / `renameNoReplace` pair. - `FormatParserSharedResources.cpp`, `Parquet/Reader.cpp`: master's logic with `uz` literals instead of `ul`, because `size_t` is not `unsigned long` on Windows. - `FsSnapshot.cpp`, `MetadataStorageFromPlainRewritableObjectStorage.cpp`: master's changes with `pathToGenericString`; the new `materializeVirtualDirectory` converts its path the same way. - `StorageObjectStorageSource.cpp`: kept the includes from both sides. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The code that came with the merge does not compile for `x86_64-w64-windows-gnu`: - `ReadBufferFromFileDescriptor.cpp`: the failpoint `file_read_corrupt_data_without_direct_io` asks `fcntl` for `O_DIRECT`. It goes through `isOpenedForDirectIO`, which is `false` on Windows. - `ClientBase.cpp`: `getStdinStateNonBlocking` uses `poll` on stdin. On Windows it decides by the kind of the handle: a file has data, a pipe is asked with `PeekNamedPipe`, a console is ambiguous. - `FilesystemIsolationPaths.cpp`: `getpwuid_r` and `pwd.h` are not available on Windows. - `StorageReplicatedMergeTree.cpp`, `checkDataPart.cpp`: `std::filesystem::path` was passed where a `String` is expected. - `StorageObjectStorageQueue.cpp`: the ZooKeeper path is a `String` in this branch, so it is joined with `zkutil::joinZooKeeperPath`. Also remove `platformChmod`: its only user, `DiskLocal::chmod`, was removed in `master`. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…esWebServer.cpp` `Build (arm_tidy)` failed with `modernize-use-nodiscard` on `Socket::isValid`, `Socket::poll` and `Socket::toDescriptor`, and with `performance-string-view-conversions` on a `String` built from a `std::string_view` only to be passed to `escapeForFileName`, which takes a `std::string_view`. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=112824&sha=e6570037466deabae14c1ece001978cb3c4c7688&name_0=PR&name_1=Build%20%28arm_tidy%2C%201%2F4%29 #112824 Co-Authored-By: Claude Fable 5.2 <[email protected]>
- `syncPath` opens the file for writing on Windows, because `FlushFileBuffers` fails on a handle without `GENERIC_WRITE`. Otherwise every `INSERT` with `fsync_after_insert` failed with `CANNOT_FSYNC`. - The registry of the files whose fsync failed identifies a file by `PlatformFileVersion` (the volume serial number and the file index on Windows) instead of the `st_dev` and `st_ino` of `fstat`, which are zero for every file there, so one failed file made all later syncs fail. - The registry releases a file when `platformIsDescriptorUnlinked` reports that it has no names left: `st_nlink == 0` on POSIX, no links or a pending delete on Windows. The Wine step of `Build (amd_windows)` runs two inserts into a persistent `MergeTree` table with `fsync_after_insert`, and `clickhouse-windows-selftest` checks the file identity and the sync through a write-only descriptor. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…sk-uploader` `MetadataStorageFromStaticFilesWebServer::loadFiles` reads the name with `readEscapedString`, so the uploader writes it with `writeEscapedString`. It matters since the uploader descends into projection directories, whose names are not escaped with `escapeForFileName` and can contain a backslash, a tab or a newline. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…of `master` Regenerating the workflows for the merge of `master` rewrote these two files as well, with an incomplete result. This branch does not change them, so take them from `master`. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
🕵 Merged
Checked locally: |
| if (file_version_known) | ||
| current_file_cache_version = computeFileCacheVersionToken(file_version); | ||
| else | ||
| current_file_cache_version.reset(); |
There was a problem hiding this comment.
[Blocker] Check for a missing version before comparing split-file generations
The new failure branch disengages current_file_cache_version, but the split-file path unconditionally dereferences it at line 2210. A parallel Parquet read can successfully run getFileStat at line 2180, then have an external writer remove the file before platformFileVersion performs its second metadata lookup. That takes this reset and then dereferences an empty std::optional<String> instead of reporting FILE_CHANGED_DURING_READ. This affects Linux as well as Windows; previously the token was built from the already successful file_stat.
For a split file, reject an unavailable token before dereferencing it, and cover failure of the second metadata lookup. This trace is source-derived; I could not execute a ClickHouse binary here.
| errno = EIO; | ||
| return -1; | ||
| } | ||
| return info.DeletePending || info.NumberOfLinks == 0; |
There was a problem hiding this comment.
[Blocker] Keep the failed-fsync marker while another hard link remains accessible
DeletePending does not establish that the file has no remaining names. The Windows filesystem algorithm derives that flag from deletion of the particular link used by the open handle, independently of the count of other accessible links.
With hard links A and B, let syncPath(A) fail and retain its descriptor, then delete A while B remains. This returns 1 because A is delete-pending, so FailedFiles::releaseUnlinked closes the descriptor and erases the file's error marker. A later sync through B can now succeed despite the earlier durability failure. Hard-linked part files must retain that failure across removal of just one name.
Only report unlinked when no accessible links remain. Add a Windows check that deleting one of two hard links returns 0, and deleting the last returns 1. This is a source/specification trace, not a Windows runtime result.
| const auto st = disk.stat(dir / file); | ||
| ids.emplace(file.string(), std::pair<UInt64, UInt64>{st.st_dev, st.st_ino}); | ||
| const auto st = disk.stat(pathToString(dir / file)); | ||
| ids.emplace(pathToGenericString(file), std::pair<UInt64, UInt64>{st.st_dev, st.st_ino}); |
There was a problem hiding this comment.
[Blocker] Use real Windows file identities before deleting a supposed duplicate part
DiskLocal::supportsStat remains true on Windows, but DiskLocal::stat delegates to the CRT, whose st_ino is zero and whose st_dev identifies the drive, not the individual file. The PR already handles this distinction in PlatformFileVersion and createHardLink; the CRT field contract also documents it.
Consequently, an unexpected part and an independent detached part on the same drive compare equal whenever their relative filename sets match, even if their contents differ. checkPartsImpl then adds the unexpected part to parts_already_detached and removes it at line 2280 instead of preserving it as detached/ignored_*. This can lose the only copy of those contents. A local attach with external Keeper reaches this check before replica activation checks the interserver address.
Use reliable volume/file identities for this comparison, or skip the destructive duplicate-removal optimization when the disk cannot supply them. Cover distinct files with matching relative names as well as genuine hard links.
| /// would append `\` on Windows, where it is an ordinary character in a key. | ||
| String keyDirectory(const String & path, const String & prefix) | ||
| { | ||
| String key = appendObjectStorageKeySegment(path, prefix); |
There was a problem hiding this comment.
[Major] Preserve the existing absolute-path Iceberg drop behavior
The new concatenation changes the absolute-suffix behavior relied on by IcebergMetadata::drop at IcebergMetadata.cpp:2238: it passes persistent_components.table_path as both path and prefix to listFiles. For an IcebergLocal table at /data/user_files/lake, the old filesystem join produced /data/user_files/lake/, whereas this helper produces /data/user_files/lake//data/user_files/lake/.
LocalObjectStorage::listObjects returns an empty listing for that nonexistent directory, so DROP TABLE succeeds while iceberg_delete_data_on_drop = 1 leaves all the table data behind. This is a Linux regression too; existing stateless Iceberg tests already use absolute table paths.
Update the drop caller to pass an empty prefix, and add a focused assertion that dropping an absolute-path table actually removes its metadata and data files.
| /// on exit. Redirected output has no console code page and receives the bytes as they are. | ||
| static const UINT original_console_output_code_page = GetConsoleOutputCP(); | ||
| if (original_console_output_code_page != 0 && original_console_output_code_page != CP_UTF8 && SetConsoleOutputCP(CP_UTF8)) | ||
| std::atexit([] { SetConsoleOutputCP(original_console_output_code_page); }); |
There was a problem hiding this comment.
[Major] Restore shared console state on controlled immediate exits
These restorations run only through std::atexit, but the Windows console handler calls safeExit on an idle interrupt or repeated cancellation (ClientApplicationBase.cpp:93), and safeExit calls _exit, which skips these callbacks. The client's external-table option error path also calls _exit directly.
The code pages belong to the shared console, so starting from chcp 437, launching clickhouse.exe local, and pressing Ctrl+Break at the idle prompt leaves the parent console at 65001. The input-code-page and output-mode restorations below are skipped as well, affecting subsequent commands after ClickHouse exits.
Restore the saved console state explicitly before controlled immediate exits, while retaining the immediate-exit behavior needed by the cancellation path. Cover the child-process exit with a real-console test when available. This reproduction is source-traced, not executed on Windows.
Draft. Cross-compiles
clickhouse.exeforx86_64-w64-windows-gnu(mingw-w64 + clang + lld → a native PE, no emulation layer and no MSVC licence). The goal isclickhouse-clientandclickhouse-localrunning natively on Windows.State: it links, and CI runs it under Wine —
clickhouse.exe --versionandclickhouse.exe local --query "SELECT 1", which is the whole startup path and one pipeline. Nothing past that has been executed: no client against a real server, noclickhouse-localover actual files, no test suite, and nothing on a real Windows machine rather than on Wine. The Wine run happens on the CI runner because the development host is aarch64 and Wine on ARM ships no x86 emulator.Every import ships with Windows, so the binary is a single self-contained file. Linux builds and links
clickhouseunchanged after every commit in the branch. CI buildsclickhousefor Windows on every pull request and then executes it under Wine, so the port cannot silently regress.What is here
The runtime (libc++/libc++abi/libunwind with SEH, compiler-rt builtins), 117 contribs behind a self-maintaining CI gate, all of Poco — whose Windows layer had been deleted from this fork and is restored from upstream 1.9.3 — every library under
src, andprograms. Roughly 900 of the changed lines are one mechanical class:std::filesystem::pathused where aStringis wanted, which compiles on POSIX through an implicit conversion that does not exist on Windows.Implemented natively rather than stubbed, because a client needs them: terminal size and console encoding, raw console mode and keystroke reading, Ctrl+C and Ctrl+Break, socket liveness,
statvfsviaGetDiskFreeSpaceEx, file mapping,pread, per-thread CPU time,setThreadName,isLocalAddress,readpassphrase, and aWakeupFdbuilt on a loopback socket pair (a Windows pipe cannot be waited on alongside sockets).Compiled out with the reason recorded at each site, all server-side or POSIX-only: the sampling profiler and signal handlers (Windows reports faults through SEH),
ThreadFuzzer, thefork-based watchdog,ShellCommandand everything built on it, the pseudo-terminal features, and thesu/docker-init/installtools.Known gaps
clickhouse-localquery under Wine, as above.-g0on Windows: a PE image cannot exceed 4 GiB and the DWARF alone is several times that, and PE has no.gnu_debuglinkequivalent to carry it separately. A crash symbolizes to module and offset, not file and line.Epollbackend, so nothing that polls sockets through it works yet.libarchiveneeds a hand-written Windowsconfig.h), conditional writes to the local object storage (they needflockon a directory and sub-second modification times), and the web terminal reportNOT_IMPLEMENTED.docs/resources/develop-contribute/build/build-cross-windows.mdxhas the build instructions and a per-subsystem inventory of what remains.Related: #112185
Related: #112767
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added a cross-compilation target for Windows (
x86_64-w64-windows-gnu), producing a nativeclickhouse.exe. The port is not finished: CI runs the binary under Wine over a trivialclickhouse-localquery, and nothing beyond that has been executed.Documentation entry for user-facing changes
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/112824]