The correct, safe broad rebrand: renames "ClickHouse" only as a whole word (boundary on
BOTH sides), so it rewrites display strings/messages/comments but leaves every compound
C++ symbol intact — `ClickHouseDictionarySource`, `getInfoIfClickHouseDictionarySource`,
`mainEntryClickHouseServer`, `ClickHouseRevision`, `ClickHouse_SOURCE_DIR` are untouched
(an earlier one-sided heuristic mangled suffix symbols like `manageClickHouse`; reverted).
1677 occurrences across 482 files. Compile-safe (string/comment content; symbols preserved).
Still NOT renamed (would be a build-coupled symbol rename, needs build-host iteration): the
199 compound identifiers containing ClickHouse, the `DB::` namespace, the `clickhouse_*`
CMake targets/macros, the lowercase `clickhouse` SQL dictionary-source keyword. Needs build
verification.
Add two new `load_balancing` strategies that sort replicas by the length of
the longest common prefix (or suffix) between the initiator hostname and each
replica hostname, preferring the longest match. Ties are broken randomly, the
same as the existing hostname strategies.
These complement `nearest_hostname` and `hostname_levenshtein_distance`, which
both misbehave when the data center identity is encoded as a short prefix or
suffix in hostnames whose numeric segments have variable length: position-wise
character comparison gets thrown off by the length differences, while longest
common prefix/suffix comparison is not.
`getHostNameLongestCommonPrefix` and `getHostNameLongestCommonSuffix` return a
similarity (the common length, where larger means more similar), so unlike the
other hostname strategies, which store a distance and return it verbatim, the
priority function negates the stored value to turn it into a `Priority` (where
a lower value means higher priority). The comparison is case-sensitive, matching
`getHostNamePrefixDistance` (`nearest_hostname`).
Unit tests in `gtest_get_priority_for_load_balancing` cover the length functions
and the resulting replica ordering. Integration tests mirror the existing
`hostname_levenshtein_distance` coverage in `test_distributed_load_balancing` and
`test_zookeeper_config_load_balancing`.
Related: https://github.com/ClickHouse/ClickHouse/pull/54826
Co-Authored-By: Claude Opus 4.8 <[email protected]>