Repository navigation
Conversation
…ialization
Reading an Object/JSON column from a Wide part fans per-dynamic-path prefix
deserialization out into a thread pool. The reader's callbacks were not thread
safe, so SerializationObject wrapped all of them under one stack-local mutex.
That mutex only needs to serialize mutations of the reader's stream containers,
but it was held across settings.getter(), which resolves a stream and calls
MergeTreeReaderStream::init() -> estimateMarkRangeBytes() -> loadMarks() ->
future.get(): a blocking wait on marks I/O.
The result is a convoy rather than a deadlock. Every pool task queues behind the
one holder, so marks loads that should overlap run strictly one after another,
and the tasks the holder is waiting for are themselves queued behind it. In the
CI report below 100 of 152 dumped threads were waiting on that mutex and
WaitMarksLoadMicroseconds accounted for 96% of a query's elapsed time, which
crossed the 1000 s hung-check threshold.
Make the reader's callbacks genuinely thread safe with a streams_mutex that
covers only container mutation, and set the existing
prefix_deserialization_callbacks_are_thread_safe flag so the serialization layer
stops wrapping them. No lock is then held across marks loading anywhere:
- getStream() resolves or creates the stream under the mutex and does
adjustRightMark()/seekToStart()/seekToMark()/getDataBuffer() outside it.
- getOrAddStream() constructs the stream and calls startAsyncLoad() outside the
mutex, because scheduling blocks when the marks pool queue is full.
- release_stream_callback extracts the map node under the mutex and destroys it
outside, because ~MergeTreeMarksLoader waits for an in-flight load.
- has_uniform_marks_callback looks the stream up under the mutex and calls
hasAtMostNDistinctMarks() outside.
- The prefetch callback resolves its per-column SubstreamsCache on the serial
thread instead of indexing the shared `caches` map from pool tasks, where
operator[] could insert, rehash and invalidate references held elsewhere.
Per-stream exclusivity outside the lock was already load-bearing: each parallel
task owns a disjoint batch of dynamic paths, the stream name embeds the path, and
the read from the returned ReadBuffer already happened with the lock released.
SerializationObject.cpp and ISerialization.h are unchanged. The safe_* wrappers
there are now unused by the only in-tree producer of the pool, but remain the
correct fallback for a caller that supplies non-thread-safe callbacks.
Adds a failpoint that sleeps in MergeTreeMarksLoader::loadMarksSync and a test
asserting WaitMarksLoadMicroseconds exceeds the query's wall-clock time, which is
only possible if several marks loads waited concurrently. On master the ratio is
exactly 1.00; with this change it is 1.47 on the test's shape.
Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=114063&sha=7f28dc544f58b8bbfa775a4da6d4bbc167a8482c&name_0=PR&name_1=Stress%20test%20%28arm_asan_ubsan%2C%20s3%29
Related: ClickHouse#114136
Run the test under clickhouse-local instead of the shared server. It enables a process-global, persistent failpoint and asserts a timing ratio, so a concurrent copy clearing the failpoint after the prefix phase would leave the precondition satisfied (the serial data-phase loads still slept) while the ratio fell to about 0.98 - the test would then report a regression on a correctly fixed build. Each clickhouse-local invocation owns its own failpoint state, so that window does not exist, and no no-parallel tag is needed. A trap removes the temp directory on every exit path. The memory limit is set in the generated config rather than on the command line: sized from the enclosing cgroup it becomes whatever unrelated processes have left. Add a second arm with load_marks_asynchronously = 1 so the carriers that only exist while a marks load is in flight are executed, asserted through BackgroundLoadingMarksTasks, and make the JSON column carry a typed LowCardinality path so the uniform-marks check runs too. Measured coverage: reverting the getter split flips the ratio from 1.47 to 1.00, while scheduling the asynchronous load back under the mutex does not change the result, because 244 loads never saturate the 10000-entry queue. That leg stays justified by inspection, and the uniform-marks check is reachable only from the serial typed-path pass. Lower the wait precondition from ten seconds to one. It was sized for the synchronous arm; the asynchronous arm waits about four seconds, so it reported "failpoint did not fire" when the background-task counter proved otherwise. The same query without the failpoint waits under 15 ms. Also drop the issue reference and the duplicated exclusivity argument from two comments, leaving the invariant each one states.
…cy test Two arms are added to 04864 so the reader callbacks the fix touches are actually executed by the test rather than only justified by reading the code. A second clickhouse-local instance constrains the marks-pool queue below the number of loads, so scheduling a marks load has to wait for a running one to finish. That wait used to happen while the reader held its container mutex. Note that ThreadPool raises queue_size to max_threads, so only the queue is constrained: shrinking the pool instead caps the achievable concurrency and inverts the ratio oracle, making the arm pass on an unfixed build and fail on a fixed one. The third arm enables local_filesystem_read_prefetch, which is off by default, so the prefix prefetch callback runs at all. It asserts one prefetch per dynamic path from system.filesystem_read_prefetches_log; without the setting that count is zero. Both new arms redden on an unfixed build with a diagnostic ratio. The queue arm proves the blocking schedule call executes (240 loads against a queue of 50, and an instrumented build counted 135-150 schedule calls that had to wait) but it does not discriminate a mutation that puts scheduling back under the mutex: WaitMarksLoadMicroseconds is incremented only inside loadMarks(), so scheduling delay never enters the numerator, and serializing it moves the ratio away from the failure threshold. That carrier remains justified by inspection. Also corrects two comments that stated mechanisms which do not hold: the prefetch callback's own cache lookup cannot insert, and the runner's compression codec pin never reaches a clickhouse-local test. Co-Authored-By: Claude Fable 5 <[email protected]>
SYSTEM DROP MARK CACHE affects server-wide shared state, so the style check requires a no-parallel tag on any test that contains it. The tag would be wrong here: the test runs under clickhouse-local because the failpoint it needs is process-global, so there is no shared server to protect, and the tag is discouraged where it can be avoided. Setting mark_cache_size to zero in the generated config has the same effect on the arms below. A zero size still constructs the cache object, so the asynchronous loading path that dereferences it unconditionally keeps working, but every entry is evicted on insert, so every lookup misses and every arm loads marks cold. Removing the statements does not warm any arm: all four assertions still redden on an unfixed build with their diagnostic ratios, and stripping the config line makes the asynchronous arms report their vacuity preconditions instead of passing quietly. The queries against system.parts and system.query_log now filter on currentDatabase(), which the style check also requires. Not only cosmetic: the queue arm's instance reuses the same log_comment namespace. Also states the true local invariant at the prefix prefetch callback: sibling prefix tasks resolving the same key would modify the cache map concurrently, which is why it is resolved on the serial thread. Co-Authored-By: Claude Fable 5 <[email protected]>
Internal second-model review (4 rounds, adjudicated)An independent reviewer read the resulting code cold, then a second model re-reviewed each round.
Independently re-derived rather than taken on report: the invariant-carrier list (six callbacks, |
Pre-PR validation gate
Regression check on both arms with identical server configuration: no test fails with the fix that does not already fail without it ( |
|
cc @Avogar @KochetovNicolai, could you review this? The Wide reader's prefix callbacks were not thread safe, so |
|
Workflow [PR], commit [e7a48e1] Summary: ❌
AI ReviewSummaryThis PR removes the serialization-side fallback mutex and moves stream synchronization into Tests
Final Verdict
LLVM Coverage ReportMeasured on commit e7a48e1.
Changed lines: Changed C/C++ lines covered: 147/153 (96.08%) · Uncovered code |
Build profile diff (arm_release)Comparing commit See the job log for details. |
CI finish ledger - a09644cEvery failure below has an owner: a fixing PR (ours or external), or a full-effort fix task CI is fully finished on this head and there are no failures to own: the praktika report for
Session id: cron:our-pr-ci-monitor:20260811-073000 |
|
📊 Cloud Performance Report ✅ AI verdict: Release-transition baseline: compared against the last 26.8 master because no 26.9 master baseline exists at or before the trusted base-commit anchor. This PR is a concurrency fix that only affects how marks are loaded during parallel JSON/dynamic-subcolumn prefix deserialization in wide parts. Neither ClickBench nor TPC-H reads JSON columns, so none of the flagged deltas — including the large TPC-H Q4 (x19.7 faster) and Q7 (x6.7 faster) speedups — can be attributed to this change. Every directional flag was measured against a thin baseline of only 2 base instances, so the shifts are run-to-run/baseline variance and are downgraded to not sure. The one envelope-suppressed no_change (ClickBench Q13) is correctly classified. clickbenchFlagged queries (11 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_officialFlagged queries (4 of 22)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. Debug info
|
Master adds `merge_tree_sequential_source_sleep_before_read` and `replicated_sends_sleep_before_file_send` where this branch adds `merge_tree_marks_load_sync_sleep`. Kept all three. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
CI finish ledger -
|
| Check / test | Reason | Owner / fixing PR |
|---|---|---|
Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/6) / test_s3_plain_rewritable/test.py::test[s3_plain_rewritable_with_metadata_cache-data_with_cache/] |
node death, not this diff: the test's ALTER TABLE test MODIFY SETTING gets Code: 210. DB::NetException: Connection refused (172.16.5.9:9000) because the shard's server process was killed |
a fix task is created (investigating at full effort - fixing-PR link to follow on this PR) |
Attribution measured in CIDB over 7 days for that exact test and check: 19 rows across 17 distinct
PRs, including 2 true-master runs, first seen 2026-08-29 15:13:22. Two sibling cases
(test_projections[s3_plain_rewritable] and [cache_s3_plain_rewritable]) appeared in the same
window after passing continuously since 2026-07-31. Counts are given rather than PR links so this
does not cross-reference unrelated PRs.
The diagnostics prerequisite for this family, #117104, merged earlier today, but it is explicitly not
the fix: it preserves the kernel's memory-kill record so the breaching cgroup can be named, and its
merge commit is not an ancestor of this head. The mechanism half is what the new fix task owns.
Session id: cron:our-pr-ci-monitor:20260830-180000
|
Fixing PR for the The node was not crashing. On a hung |
…ndows The previous commits guarded `streams` and `prefetched_streams` with a `streams_mutex` taken and released at six call sites, each carrying a comment about which blocking call had to stay outside the critical section. That mutex protected the containers but not the elements: `getOrAddStream` handed back a raw `MergeTreeReaderStream *` that callers used with the lock released, while `release_stream_callback` could destroy the same node concurrently, so the "parallel tasks own disjoint stream names" invariant became load-bearing for memory safety rather than just for correctness. Move all of it into a `FileStreams` holder owning both containers and the mutex. `getOrCreate` runs the stream factory with the mutex released, because creating a stream schedules a marks load that blocks when the pool queue is full. `release` drops the stream outside the lock, because `~MergeTreeMarksLoader` waits for an in-flight load. Values are `shared_ptr`, so a stale erase can no longer free a stream another task is reading. Folding `prefetched_streams` into the same holder removes the last unguarded container access, and every call site is one line again with no locking commentary. With the reader's callbacks genuinely thread safe, the serialization layer needs no fallback: drop `callbacks_mutex`, the six `safe_*` wrappers and the `wrap_callbacks` branch from `SerializationObject`, and the `prefix_deserialization_callbacks_are_thread_safe` flag from `ISerialization`. `MergeTreeReaderWide` is the only in-tree producer of `prefixes_deserialization_thread_pool`, so with the flag always set that code was unreachable and untested. The contract is now stated once on the pool field itself. This also removes the TSAN lock-order-inversion between nested stack-local mutexes, which existed only because of the coarse mutex. `seek_stream_to_mark_callback` used a non-const `operator[]` that would insert a null `unique_ptr` and dereference it if the stream were missing; it now throws `LOGICAL_ERROR`. 04864 passes unchanged, with the sync arm at ratio 1.46 against its 1.15 threshold (1.00 when marks loading is serialized). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
@groeneai I reworked the fix |
|
Checked Mutation arm, so that pass is not vacuous on the new structure: holding one mutex across I also re-checked the riskiest deletion: I updated the PR description to match your implementation; it still described the flag plus narrowed-mutex version. |
…s invariant Review pointed out that the `shared_ptr` in `FileStreams` did not buy the lifetime guarantee it was supposed to. `getStream` drops its own reference on return and hands the caller a bare `ReadBuffer *`, so a concurrent `release` would still destroy the stream under an in-flight read. The guarantee held for the short uses that keep the pointer for their whole duration and lapsed for the longest one, which is worse than not claiming it: the safety of element access rests on parallel tasks owning disjoint stream names, and that is the only thing worth writing down. So go back to `unique_ptr` in the map and return `MergeTreeReaderStream *`, which also keeps this reader consistent with `IMergeTreeReader::FileStreams` and `MergeTreeReaderCompact`, and drops an atomic refcount pair from every lookup in the read path. `release` still moves the stream into a local declared before the lock guard, so it is destroyed after the mutex is released, because `~MergeTreeMarksLoader` waits for an in-flight marks load. The invariant comment now states its full scope: a stream, and any `ReadBuffer` taken from it, stays valid until the owning task calls `release`. That is the window the review flagged, and it is unchanged from `master`, where the coarse mutex did not cover the buffer read either. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Re-measured on 04864 passes, 13/13 lines. Mutation arm on the new structure, so that is not a vacuous pass: one process-wide mutex held across On the lifetime window, the claim that it is unchanged from master holds. On master I refreshed the PR description to match this head. |
…two builds The arm ran a second clickhouse-local instance with load_marks_threadpool_queue_size = 50 and asserted WaitMarksLoadMicroseconds / query_duration_ms > 1.15. That ratio is a one-sided witness only. When marks-load waits never overlap their sum cannot exceed the query duration, so a build that holds one mutex across MergeTreeReaderWide::getStream is pinned at ratio <= 1 (measured 0.99 with such a mutex added on top of this head). The converse does not hold: with a queue shorter than the number of loads, ThreadPool::scheduleImpl blocks the scheduling thread on job_finished, that block is not accounted as marks-load wait, and it also delays the consumer past the completion of its own load, so the accounted wait shrinks while the duration grows. On a correct build the ratio then lands in the same region: CI measured 0.45 to 1.15 for this arm on this head across 26 flaky-check runs, 11 of them below the 0.99 that the serialized build produces, while the same arm reports 5.2 to 5.9 on an idle 384-core box. No threshold separates the two builds, so the arm was reporting a serialization regression on a build that has none. The three arms of the first instance keep the coverage. They redden on the same serialized build (sync 1.00, async 0.98, prefetch 0.99), and their numerators are dominated by the injected sleeps rather than by machine speed: 8 copies pinned to 4 CPUs give sync 1.46 (duration 16459 to 16468 ms), async 13.8 to 15.1 and prefetch 9.2 to 9.9 against the same 1.15 threshold. 50 runs of the trimmed test at 10-way self-parallelism pass, 12 copies pinned to 4 CPUs pass, and the serialized build still fails on all three arms. The removed configuration also needs a non-default load_marks_threadpool_queue_size: the default is 10000, raised to at least max_threads, so a query would need more than 10000 pending marks loads to reach the blocking path the arm aimed at.
|
Pushed It was the only failing line in all 26 flaky-check failures at
I could not reproduce those values locally: 82 runs here, up to 40 copies pinned to a single CPU, kept the arm between 2.14 and 7.39. Its margin is a property of the machine, not of the code under test, which is what makes it unusable rather than merely noisy. The three remaining arms are not machine-speed sensitive, because their numerator is the injected sleep and not the elapsed work: 8 copies pinned to 4 CPUs give The removed configuration also needed a non-default |
|
04357 drives the nested prefix pass without prefetching and 04864's JSON is flat, so prefixes_prefetch_callback has only ever run from the outer level's pass, on the reader thread. It is the one caller of the reader's callbacks that no test invokes from a prefix pool task, which is where it has to be thread safe now that SerializationObject does not wrap the callbacks under a mutex of its own. The added read prefetches prefixes over two array-of-object paths. Measured at this head: 29 prefetch submissions, 13 of them from 8 PrefixReader threads, two for substreams that exist only below a nested object. Clearing settings_copy.prefixes_prefetch_callback in the pool task, so the nested level stops invoking it, turns the new assertion red and leaves the rest of the test green. The arm gets its own table, reads it exactly once, and pins the part layout: a column the earlier queries already read is served from the uncompressed cache and is then never prefetched at all, while packed part storage, long file name hashing and a remote disk each change what the prefetches log records for a substream.
|
Added the nested prefix-prefetch coverage in The gap was real. One correction to the premise, because it moves where the safety argument sits: The arm asserts that a substream below the nested object was prefetched, and deliberately not which thread did it: Verification: 50/50 with randomization under self-parallel load; clearing Session id: cron:clickhouse-maint-slot-13:20260912-044000 |
The `async` arm of 04864_json_prefix_deserialization_marks_load_not_serialized turned red in `Stateless tests (amd_asan_ubsan, flaky check)` at 82b4f74, 1 run of 50, on its wait precondition. That line had never flipped before: -async: marks-load wait is measurable +async: UNEXPECTED: no marks-load wait, failpoint did not fire The precondition asserted an absolute floor, WaitMarksLoadMicroseconds > 1 s, on all three arms, but only the synchronous arm can make that statement. There the marks are loaded on the thread that waits for them, so the measured window contains the injected 100 ms sleep itself. An asynchronous arm waits on a background load, so the same counter measures only what is left of that load once its consumer reaches it, which a co-scheduled machine drives towards zero with the failpoint firing exactly as before. Measured on the test's own fixture (240 marks loads, so 24.0 s of injected sleep): perturbation sync async prefetch at rest 24.06 s 12.36 s 9.44 s marks pool 50 -> 400 24.06 s 7.86 s 4.66 s 12 copies, 4 CPUs 24.05 - 24.22 s 12.35 - 13.86 s 7.74 - 10.01 s The synchronous arm observes 100% of the injected sleep under every perturbation, to within 0.7%. The two asynchronous arms observe 32-51% of it and move whenever the schedule moves. The CI run that failed observed under 4%. So the floor stays on the arm that owns it, which is enough for the other two: the failpoint is process-global and stays enabled across all three arms. The asynchronous arms keep the BackgroundLoadingMarksTasks check, which is what proves they loaded marks at all, and the retry's copy of the wait floor becomes that same check, so a starved re-measurement no longer abandons the remaining budget. The floor still catches a failpoint that stopped firing: without it the synchronous arm waits 9.7 ms against the 1 s floor, and deleting the SYSTEM ENABLE FAILPOINT statement reddens the test on the sync line.
|
Moved The precondition asserted
The asynchronous arms keep the Verification: the serialized mutation still fails on the Local starvation still does not reproduce the sub-second draw itself: the minimum Session id: cron:clickhouse-maint-slot-13:20260912-080900 |
CI finish ledger - aa076ebEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The failing tree predates the fix, measured rather than inferred: the needle Session id: cron:our-pr-ci-monitor:20260912-143024 |
|
@groeneai fix the conflicts |
…-deserialization One conflict, in src/Storages/MergeTree/MergeTreeReaderWide.cpp: master's 56f22cc ("Don't load marks and don't prefetch data of streams with an empty data file") edits the stream-construction body that this branch moved into the factory passed to `FileStreams::getOrCreate`, so both of its parts are applied inside that factory: the `data_file_size` hoist, and the `data_file_size != 0` guard around `marks_loader->startAsyncLoad()`. Construction stays outside the streams mutex, which is what this branch fixes. Its other two changes (the empty-file early return in `prefetchForColumn`, and `partially_read_columns_are_refilled` in `readData`) merged into this branch's rewritten bodies without conflict and are kept as master has them. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Conflicts resolved by merging master One conflict, in Checks on the result: it differs from the previous head by exactly those three edits, and from master by exactly this PR's ten files. Debug build is clean, and |
CI finish ledger - 56c5e7eEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Nothing on this head is attributable to this PR's diff. Session id: cron:our-pr-ci-monitor:20260915-003145 |
…tex-across-marks-load-in-json-prefix-deserialization
The arm enables local_filesystem_read_prefetch and then asserts one prefetch per dynamic path in system.filesystem_read_prefetches_log, but it left local_filesystem_read_method at its default. That default is only conditionally 'pread_threadpool': applySettingsQuirks switches it to 'pread' when preadv2(RWF_NOWAIT) is unavailable - an old kernel, a filesystem answering EOPNOTSUPP, or a container runtime whose seccomp profile rejects the system call - and clears the changed flag, so the substitution reads as the default. A synchronous method then builds ReadBufferFromFilePReadWithDescriptorsCache, which is not given the prefetches log and whose prefetch() is the ReadBuffer no-op, so the log stays empty and the assertion reports a count of zero for a property of the host rather than a regression. Measured on this head with the method forced to the value the quirk picks: 'UNEXPECTED prefix prefetch count: 0', every other line unchanged. Pinning is safe where the quirk would have fired, because ThreadPoolReader::submit gates only its page-cache fast path on the probe and otherwise hands the read to the pool. On a host where the default already holds, the arm is unchanged: 10/10 both before and after. Same pin, for the same reason, as 04357_json_nested_prefixes_deserialization_pool.
|
Pushed Why it is not cosmetic. That arm asserts one prefetch per dynamic path in One thing I did not change, and it is your call. The arm labelled |
| -- carries the overlap verdict at the end of this query; the other two run for the code paths they | ||
| -- reach and for the deterministic checks below. | ||
| SELECT count() FROM (SELECT j FROM t LIMIT 1) | ||
| SETTINGS merge_tree_use_prefixes_deserialization_thread_pool = 1, log_comment = 'sync' |
There was a problem hiding this comment.
load_marks_asynchronously defaults to true (src/Core/Settings.cpp), so this arm is still running with background marks loads enabled. That means 04864 no longer exercises the pure synchronous loadMarksSync path it claims to cover, and the "only sync can attest the injected sleep" argument below is no longer true for the query that is actually executed here.
If a later change reintroduced the convoy only for load_marks_asynchronously = 0, this test would stay green. Please pin load_marks_asynchronously = 0 in the sync arm and keep the nearby comments / reference output aligned with the actual mode under test.
There was a problem hiding this comment.
Premise confirmed, and quantified. In query_log for that arm, unpinned: LoadedMarksFiles = 160, BackgroundLoadingMarksTasks = 160, WaitMarksLoadMicroseconds = 10.43 s, so 65.2 ms per load. With load_marks_asynchronously = 0: same 160 files, BackgroundLoadingMarksTasks = 0, wait 16.04 s, so 100.3 ms per load, which is the injected sleep itself to within 0.3%. The failpoint sleeps at the top of loadMarksSync, and loadMarksAsync's pool task calls that same function, so the sleep fires either way and only the place it is counted changes. Unpinned, the arm measures 65% of a sleep that is already running on a pool thread, which is what the comment further down says an asynchronous arm measures.
The comment was accurate when it was written. load_marks_asynchronously became true in 26.9, and it reached this branch through my own master merge 4eb4dfc0, a month after the arm and that comment were written in aa076ebf. It is also invisible in query_log: Settings['load_marks_asynchronously'] is empty for the arm, because the value is the default rather than a set one.
What I could not confirm is the consequence. The reason to treat this as urgent would be a fragile floor, so I tried to break it: restricted to a single core, three runs hold at 10.68 s, 10.77 s and 10.68 s against the 1 s floor, the same margin as unrestricted. taskset starves the loaders and the consumers equally, and a consumer here calls loadMarks immediately after startAsyncLoad, so there is no window in which the background loads finish first. No red is latent. The real content is your coverage point: nothing in this test exercises inline loadMarksSync, and a regression confined to load_marks_asynchronously = 0 would stay green, which is the mode that was the default up to 26.8.
The pin costs more than it looks, which is why I am not just taking it. The 160 injected sleeps stop overlapping across the 50-thread marks pool and run inline, so the arm goes from 614 ms to 8.45 s and the whole test from 3.6 s to 11.3 s, a factor of 3.1. The change is written and verified anyway: 10/10 with the pin, and the oracle stays live, since with the failpoint off the pinned arm waits 8 ms and the floor still reddens. It needs no edit to the comment below, because the pin makes that comment true as written.
A 3x test-cost change on an approved PR is the reviewer's call and not mine to spend, and the same question has been open on this PR since earlier today, now with the number attached. I will push it as soon as it is wanted.
CI finish ledger - e7a48e1Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose
Session id: cron:our-pr-ci-monitor:20260915-213215 |
fda9f2f
Conflicts, all context-only: - SerializationVariant.cpp, SerializationVariantElement.cpp: 26.8 has `clone()` without the clone context (ClickHouse#126298 is not in 26.8); keep it and add only the copies of the new `variant(s)_absent_in_storage` flags. - MergeTreeReaderWide.cpp: 26.8 has `addStream`, not `FileStreams::getOrCreate` (ClickHouse#114252 is not in 26.8); add only the new `isReadWithTypeInPart` before it. Semantic fix: `IMergeTreeReader::hasSubcolumnInPart` (ClickHouse#120632) is not in 26.8, so `isReadWithTypeInPart` uses `type->hasSubcolumn`, as the 26.8 readers already do. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts, all context-only: - SerializationVariant.cpp, SerializationVariantElement.cpp: 26.9 has `clone()` without the clone context (ClickHouse#126298 is not in 26.9); keep it and add only the copies of the new `variant(s)_absent_in_storage` flags. - MergeTreeReaderWide.cpp: 26.9 has `addStream`, not `FileStreams::getOrCreate` (ClickHouse#114252 is not in 26.9); add only the new `isReadWithTypeInPart` before it. Semantic fix: `IMergeTreeReader::hasSubcolumnInPart` (ClickHouse#120632) is not in 26.9, so `isReadWithTypeInPart` uses `type->hasSubcolumn`, as the 26.9 readers already do. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes: #114136
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a latency pathology when reading an
Object/JSONcolumn from a Wide part: the per-dynamic-path prefix deserialization tasks all queued behind a single mutex that was held across marks loading, so marks were loaded one after another instead of in parallel. Closes #114136.Description
Found while investigating a
Stress test (arm_asan_ubsan, s3)hung check (CI report).Root cause.
SerializationObject::deserializeBinaryBulkStatePrefixfans per-path prefix deserialization into a thread pool. The Wide reader's callbacks were not thread safe, so all ran under onecallbacks_mutex, held acrosssettings.getter(), which reachesMergeTreeReaderStream::init()->loadMarks(): a blocking wait on marks I/O. Every task then queues behind the holder. A convoy, not a deadlock: 100 of 152 threads waited on it, andWaitMarksLoadMicrosecondswas 96% of elapsed time.The change.
MergeTreeReaderWideowns aFileStreamsholder encapsulating the stream map, the prefetched set and their mutex. Only the containers are guarded, so both blocking operations stay outside the lock; element access needs none because parallel tasks own disjoint stream names, now stated as an invariant. With the callbacks thread safe the serialization layer needs no fallback, socallbacks_mutex, the sixsafe_*wrappers and theprefix_deserialization_callbacks_are_thread_safeflag are gone;MergeTreeReaderWideis their only in-tree producer. It also removes the TSAN lock-order inversion between the nested mutexes.Validation. A failpoint sleeps in
loadMarksSync; the test assertsWaitMarksLoadMicrosecondsexceeds wall-clock time, which requires concurrent waits. Only the asynchronous arm asserts that ratio, because its wait is a wait on background loads, so a co-scheduled runner inflates both of its terms together; it reddens (0.98 against the 1.15 threshold) once the getter is re-serialized behind one mutex. The two other arms run for their code paths and keep deterministic checks: their duration also carries data-stream reads, which made their ratios false-red in the flaky check.Workflow [PR]
Sync PR [sync-upstream/pr/114252]
Version info
26.10.1.23(included in26.10and later)