Repository navigation
Read the sanitizer build flavour before the memory-limit tests run in test_max_bytes_ratio_before_external_* - #120751
Conversation
On MSan builds the three tests in test_max_bytes_ratio_before_external_order_group_by_for_server fail at their own skip guard rather than at an assertion. ClickHouseInstance.is_built_with_sanitizer answers by issuing a live query to the running node (SELECT value FROM system.build_options WHERE name = 'CXX_FLAGS'), uncached, on every call. The three tests share one module-scoped cluster and run in declaration order. test_..._sort guards TSan only, so on an MSan build it runs, and its second phase deliberately drives the node to MEMORY_LIMIT_EXCEEDED on a ~12 GiB-peak ORDER BY. Sanitizer builds other than UBSan have no jemalloc (contrib/jemalloc-cmake/CMakeLists.txt:1-10), so no arena purge returns those pages and RSS stays tens of MiB above the cap. MemoryTracker::allocImpl enforces the total limit against RSS rather than tracked bytes (src/Common/MemoryTracker.cpp:348), so while RSS is above the cap the server rejects every allocation, including the tiny one in TCPHandler::receiveHello(), i.e. the connection handshake. The first statement of test_..._distinct is its own skip-guard probe; that probe is refused with Code: 241, and the QueryRuntimeException escapes as a FAIL two lines before the MSan pytest.skip() can run. The guard is unreachable on exactly the builds it exists for. Read the flavour once in the module fixture, immediately after cluster.start(), while both nodes are still at their floor RSS, into a module-level dict the three tests consult. No test has allocated at that point, so the probe can no longer be defeated by state a later test creates. test_keeper_profiler and test_trace_collector_serverwide already probe the build flavour at this same point. Note that cluster.start() only waits for the TCP port (9000 by default) to accept a connection (ClickHouseInstance.wait_until_port_is_ready), so "the port is open" never implied "a query will be answered": Code: 241 is raised in TCPHandler::receiveHello(), after the socket has been accepted. Skip semantics are preserved case for case and message for message: group_by and distinct keep their TSan and MSan skips, sort keeps its TSan-only skip. sort is deliberately not given an MSan skip: it passes 110/110 on MSan and has never failed there, so adding one would delete real coverage to silence a failure that is not its fault. The fix is deliberately not in helpers/cluster.py either: 27 upgrade-test modules swap the binary mid-module (restart_with_latest_version, with_installed_binary), so caching CXX_FLAGS there would need invalidation on every one of them, a harness-wide change across 161 call sites in 69 files to close a defect with exactly one instance in the tree. Of the integration modules that cap server/user memory and probe the build flavour, exactly one has more than one test function, and it is this one, so group_by and sort were latent carriers of the same pattern and are converted too. Measured (CIDB, 30 days, memory-limit failures of this module): 7 failures on 7 distinct PRs, all on 2026-09-17 between 06:06Z and 14:20Z, 0 on master, all in Integration tests (amd_msan, 1/8), hitting both the [server] and [user] arms. Exposure opened when ClickHouse#116569 merged, adding the distinct case after sort in the file. Validated with a fault-injected probe oracle: 6/6 FAIL and 6 test-body probe calls before, 0 test-body probe calls after, across 3 MSan runs plus TSan and -k-filtered arms. On a plain debug build the full file is 6 passed, 0 skipped.
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 gate findings) plus two separate
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-11:20260918-073144 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20260918-064502 |
|
Workflow [PR], commit [b437b56] Summary: ✅ AI ReviewSummaryThis PR moves the sanitizer-flavour probe for Missing context / blind spots
Final Verdict✅ No review findings. |
The PR workflow run on this head aborted inside Config Workflow: praktika's Check CI DB step could not reach the CI database (Code: 202, too many simultaneous queries; three retries, all HTTP 500), the job failed, and every downstream job was set to DROPPED, so not one test ran on this head. The database answers again, so this empty commit re-triggers the workflow. No code change: the tree is identical to the previous commit.
b201776
Resolve the conflict in test_max_bytes_ratio_before_external_order_group_by_for_server/test.py. 26.9 has neither ClickHouse#120751 (the `sanitizer_build` dict) nor ClickHouse#121454 (the `limit_follows_rss` parameter and the ASan skip of the `[server]` case), so only the change of ClickHouse#122494 itself is ported: each case's query moves into its parametrize row, and the `[user]` row runs the 7M x 800-byte query with `max_memory_usage_for_user = '4Gi'`. The 26.9 sanitizer checks and the `[server]` query are kept as they are. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #116569
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed
test_max_bytes_ratio_before_external_*failing instead of skipping on sanitizer builds.Description
On MSan builds these tests fail at their own skip guard, not at an assertion.
is_built_with_sanitizeranswers by querying the running node. The three tests share one module-scoped cluster;test_..._sortguards TSan only, so on MSan it runs and deliberately drives the node toMEMORY_LIMIT_EXCEEDED. MSan builds have no jemalloc, so RSS stays tens of MiB above the cap afterwards, andMemoryTracker::allocImplenforces the total limit against RSS rather than tracked bytes. The next connection handshake is therefore refused, and the guard's probe is that connection, soCode: 241escapes as a FAIL two lines beforepytest.skip(). The guard is unreachable on exactly the builds it exists for.This reads the flavour once in the module fixture, right after
cluster.start(), while both nodes are still at their floor RSS, into a dict the three tests consult. Skip conditions and messages are unchanged.sortkeeps its TSan-only guard deliberately: it passes 110/110 on MSan, so adding an MSan skip would delete real coverage. Not fixed inhelpers/cluster.py: 27 upgrade-test modules swap the binary mid-module, so cachingCXX_FLAGSthere would need invalidation at every one of them, for a defect with one instance in the tree. Not fixed server-side either: the refusal is the total-memory limit working as configured, and a guard that decides whether to skip has no reason to query the server.Measured (CIDB, 30 days,
Code: 241on this module): 7 failures on 7 distinct PRs in one 8-hour window on 2026-09-17, 0 on master, on both the[server]and[user]arms.group_byandsortcarry the pattern latently and are converted too.Validated with a fault-injected probe oracle: 6/6 FAIL before, 0 test-body probes after, across 3 MSan runs plus TSan and
-k-filtered arms; on a plain debug build the file is 6 passed / 0 skipped.CI traceback (PR #119465,
Integration tests (amd_msan, 1/8))Report: https://github.com/ClickHouse/ClickHouse/actions/runs/35189935944/job/105133216579
Workflow [PR]
Sync PR [sync-upstream/pr/120751]
Version info
26.10.1.103(included in26.10and later)