Repository navigation
Resolve the 26.8 cherry-pick conflicts of #116723 - #120455
alexey-milovidov merged 29 commits into
Conversation
Reading an Iceberg snapshot's data files walked the data manifests one at a time in the producer thread: the one-ahead prefetch overlapped the next manifest's fetch with the current parse, but the decode itself - the Avro parse plus per-entry partition and min-max pruning - stayed serial. On tables with many manifest files this dominates the time before all data files are known. Follow up ClickHouse#112679, which introduced a bounded sliding window of decode tasks on the IO pool for delete manifests, by decoding data manifests through the same pattern: each task owns the full pipeline for one manifest (fetch, deserialize, prune), futures are consumed in manifest list order, and entries stream into the existing bounded queue, whose blocking `push` bounds read-ahead. The per-manifest decode body is shared between the delete and data paths (`decodeManifest`), and `SingleThreadIcebergKeysIterator` with its one-manifest prefetch is removed: a window of size 2 gives the closest equivalent of the previous overlap, and 1 decodes the manifests one at a time. The new setting `iceberg_data_manifest_decode_concurrency` (default 4) bounds the window, mirroring `iceberg_delete_manifest_decode_concurrency`.
Concurrent index analyses can share one `FutureSetFromSubquery` through cloned filter DAGs: `ActionsDAG::clone` keeps the underlying sets shared, and the delete- and data-manifest decode tasks in `IcebergIterator` evaluate such clones simultaneously. Nothing synchronized `buildOrderedSetInplace`: two builders raced on `set_and_key->set`, and one could reset `source` while the other's speculative pipeline still relied on the resources the source plan keeps alive. Guard the build with a per-set mutex: the winner builds, later callers take the created-set fast path under the lock. A mutex rather than `callOnce` (the `FutureSetFromTuple` fix) because a build that stopped without creating the set may legitimately be retried while `source` is preserved. Also cover `IN (SELECT ...)` under parallel manifest decode in the integration test; literal tuple `IN` goes through the already-guarded `FutureSetFromTuple` and was covered before.
With `iceberg_data_manifest_decode_concurrency = 1` decode the manifests on the producer thread and push each entry as it is produced, instead of materializing a whole manifest's batch first. The bounded queue's backpressure then applies within a manifest, keeping the previous serial iterator's memory profile: at most the queue capacity plus one entry (and one decoded manifest) are held, however many entries a manifest has. The windowed path keeps whole-manifest tasks. Also cover a single manifest with three times the queue capacity in entries in the integration test.
A data-manifest decode task drained its whole manifest even after the query was cancelled or delete decoding failed, so teardown waited for up to `iceberg_data_manifest_decode_concurrency` full manifest decodes. The drain loop now checks `blocking_queue.isFinished()` every 256 entries and returns early; the check takes the queue's mutex, so it stays off the per-entry path, bounding the wait at a few milliseconds of decoding per task. Delete-manifest decodes deliberately keep draining: the data producer finishes the queue once everything is pushed while the query is still consuming, and the lazy delete decode may run only after that, so a finished queue does not mean the delete entries are unneeded.
`ManifestFileIterator::next` skips pruned rows internally, so the teardown check between yielded entries never fired while a manifest was being fully pruned - and fully pruned manifests are the shape this setting exists for. `ManifestFileIterator` now takes an optional stop condition, checked every 256 claimed rows inside the loop, and returns nullptr as on EOF once it fires. The data-manifest paths pass the queue's finished state; delete decodes still pass nothing and always drain fully. Also cover a fully pruned large manifest in the integration test.
A decode task queued behind its siblings can begin after the queue is already finished; it still fetched its manifest before the row-loop stop check could fire. Check the stop condition once before the fetch, so only fetches already in flight are waited for on teardown.
Co-Authored-By: Claude Fable 5 <[email protected]>
Each decode task now pushes entries into the bounded queue as they are produced instead of materializing a whole manifest's batch first, so the queue's backpressure applies within a manifest at every concurrency and peak memory is the in-flight manifests' decoded contents plus the queue - a task blocked on `push` holds its pool slot only while the query is not consuming. The dedicated serial branch for a concurrency of `1` is gone: a window of one streaming task now has the same memory profile. Entries from concurrently decoded manifests interleave in the queue; nothing consumes their relative order. Delete manifests keep the batch helper - they are collected, not streamed. Also add the review-requested comment at the stop check in `ManifestFileIterator::next`.
One setting, `iceberg_manifest_decode_concurrency`, now bounds both the delete- and data-manifest decode windows. `iceberg_delete_manifest_decode_concurrency` (released in 26.8) is kept as an alias, so existing configurations keep working and `compatibility` below 26.8 still restores its old default through the 26.8 history entry.
…st-decode-concurrency # Conflicts: # src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergIterator.cpp
On format-version 3 tables the manifest iterator's constructor materializes every entry's inherited `first_row_id` before `next` is ever entered, so the walk must honor the stop condition itself; `next` then stops on its first row and the incomplete ids are never read. Also cover a format-version 3 table in the integration test: the `_row_id` column and the result must not depend on the concurrency.
…urrency' into iceberg-data-manifest-decode-concurrency
…st-decode-concurrency
The bounded queue, the producer thread, the decode window and the per-manifest streaming now live in one class; `IcebergIterator` keeps the delete machinery and delegates. The producer also iterates the snapshot's manifest list by index instead of copying the DATA entries into a separate vector.
A streaming decode task can block until the query consumes the entries it has produced, while `ensureDeletesReady` waits for the delete decode tasks it schedules on the IO pool before any entry is consumed. With both kinds of tasks on the IO pool, enough queries could park their data tasks there to leave no thread for the delete tasks whose completion would unblock them. The new pool is sized by `max_iceberg_manifest_decode_thread_pool_size` (default 100), with the usual free-size and queue-size companions.
The queue between the data manifest decode tasks and the query had a hardcoded capacity of 100 entries; it is now `iceberg_file_entries_queue_size`, keeping 100 as the default. The decode tasks pause once it is full, so it also bounds the read-ahead.
`compatibility` applies `previous_value` only from rows strictly newer than the pinned version, so with `4` a query pinned to 26.8 kept the new 4-way data decode - a memory and concurrency envelope that did not exist in 26.8 - with no escape hatch. `2` approximates the old data path (one manifest decoded, the next one's fetch in flight); the delete decode under such pins drops from its released 4 to 2, which is the lesser harm.
The pool now follows `SYSTEM RELOAD CONFIG` like the other shared thread pools, and its three settings report live values and changeability in `system.server_settings`.
A decode task pruning with an `IN (SELECT ...)` predicate built the subquery set synchronously on its pool thread; when the subquery read another Iceberg table, the nested read scheduled its own decode tasks on the same pool and the outer task could wait forever behind itself once the pool was saturated. The producer now builds all of the filter DAG's sets before scheduling any task, so nested reads run on the producer thread instead. Also give the delete decode tasks their own thread name.
The instance pins `max_iceberg_manifest_decode_thread_pool_size` to 1, so before the prewarm a pruning subquery reading another Iceberg table deadlocked the pool; now the query completes.
Every creation and destruction of a pooled serialization took the pool's single write lock, so any parallel path building serializations - such as the concurrent Iceberg manifest decode tasks - serialized on it. The pool is now split into 256 cache line aligned shards indexed by the key's low bits; the allocated-bytes metric is maintained through a shared atomic instead of one map's capacity.
…st-decode-concurrency # Conflicts: # src/DataTypes/Serializations/SerializationObjectPool.cpp
`DataFileEntriesStream::run` default-constructed `InFlightManifest`, which made the implicit default constructor of `ManifestFileCacheKey` defined and tripped `cppcoreguidelines-pro-type-member-init`: five of its fields have no initializer. Construct the key instead of assigning it afterwards, so it never exists in an uninitialized state and `content_type` does not get a meaningless `DATA` default. Co-Authored-By: Claude Opus 5 <[email protected]>
…fest-decode-concurrency Parallelize Iceberg data manifest decoding
Merge backport/26.8/116723 into cherrypick/26.8/116723 to finish the robot cherry-pick of ClickHouse#116723 "Parallelize Iceberg data manifest decoding", which GitHub reports as CONFLICTING. Five of the nineteen paths needed a decision; the other fourteen land as the merge produced them. src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergIterator.cpp: the rewrite consolidated both manifest-iterator call sites into createManifestIterator, so the resolved file is master's file plus two argument-level edits. 26.8's Iceberg::getManifestFile still takes the bytes_size parameter that master dropped in ClickHouse#116564, so manifest_list_entry.manifest_file_byte_size is passed; 26.8's ManifestFileIterator::create has no row-lineage parameter, so manifest_list_entry.first_row_id is not passed. src/Storages/ObjectStorage/DataLakes/Iceberg/ManifestFileIterator.cpp: the incoming constructor body materializes per-entry first_row_id values for format-version 3 manifests. Iceberg row lineage does not exist on 26.8, so the 26.8 (empty) side is taken. The cancellation check the PR adds between rows in next() sits outside the conflict and is kept, so the new stop flag still reaches the decode loop rather than being dropped with the walk. src/Interpreters/PreparedSets.h: include union only. 26.8 keeps its own include block plus <mutex> for the mutex member the PR adds. src/Core/SettingsChangesHistory.cpp: a plain merge resolves this file by importing master's whole "26.9" section, which names settings that do not exist on 26.8, so applyCompatibilitySetting() throws UNKNOWN_SETTING for every SET compatibility and a server with compatibility in a profile exits with code 115 at startup. That was fixed once already on this branch, by 0debf7d. The imported section is therefore dropped and the two new entries are appended to the branch's own "26.8" block, without master's "pre-26.9" and "compatibility at or below 26.8" clauses, which are false here. The branch's existing iceberg_delete_manifest_decode_concurrency entry is unchanged, so compatibility at or below 26.7 yields 2 for both the data and the delete path, and an unpinned server yields 4 for both. Leaving the entries out entirely is not an option: 03999_stateless_settings_history requires every setting absent from the frozen baseline to be recorded, and neither new setting is in the baseline. tests/integration/test_storage_iceberg_with_spark/test_data_manifest_decode_concurrency.py: test_data_manifest_decode_concurrency_row_lineage writes a format-version 3 table and selects _row_id, a virtual column 26.8 does not have. It is excised and the other five tests are unchanged. Nothing on 26.8 loses coverage, because the behavior it pins, per-entry first_row_id materialization under concurrency, has no implementation on this branch. Related: ClickHouse#116723 Related: ClickHouse#120406
Internal second-model review (click to expand)An independent model reviewed the resolved tree cold (base
💡 Also noted, and deliberately not raised as work: findings 1 to 3 together read as a coherent question about the Own cold review, separately: the file set is identical to the parent's own change set, 9 of 19 files are Gate B on the resolved tree: 7 findings, engine codex. Session id: cron:clickhouse-review-slot-11:20260916-181900 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20260916-170600 |
Related: #116723
Related: #120406
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Decode Iceberg data manifest files concurrently while the list of data files for a query is produced. The setting
iceberg_manifest_decode_concurrency(default4) bounds how many manifests, delete and data alike, are decoded at a time; it replacesiceberg_delete_manifest_decode_concurrency, which is kept as an alias.Description
@ scanhex12 asked me to resolve the conflicts in robot cherry-pick #120406 of @ aaron276h's merged
#116723. This is that cherry-pick finished by hand:
cherrypick/26.8/116723merged withbackport/26.8/116723, so the diff against this PR's base is exactly the parent's 19 files.Five files needed a decision (
PreparedSets.honly an include union); the other 14 landas the merge produced them.
IcebergIterator.cpp: master's file plus two argument edits. 26.8'sgetManifestFilestill takesthe
bytes_sizeparameter master dropped in Fix a crash on an Iceberg manifest list with a huge manifest_length #116564, somanifest_file_byte_sizeis passed;26.8's
ManifestFileIterator::createhas no row-lineage parameter, sofirst_row_idis not.Reverting either edit fails to compile.
ManifestFileIterator.cpp: the incoming constructor body is the format-version-3first_row_idwalk, absent on 26.8, so the empty branch side is taken. The cancellation check the parent adds
between rows in
next()sits outside the conflict and is kept.SettingsChangesHistory.cpp: a plain merge imports master's whole"26.9"section, after which a26.8 server with
compatibilityin a profile exits with code 115 at startup (measured; fixed oncealready on this branch by
0debf7d4d0299). The two new entries go into the branch's own"26.8"block instead, so
compatibilityat or below 26.7 gives 2 and unpinned gives 4, for the settingand its alias alike, leaving the released delete-path default untouched.
test_data_manifest_decode_concurrency_row_lineage, which selects_row_id, a virtual column 26.8 does not have (measured:UNKNOWN_IDENTIFIER). The other fivetests are byte-identical.
Validated on a clang-22 Debug build of the resolved tree:
03999_stateless_settings_historypassesand fails without the entries, the 5 + 2 new integration tests pass, and the pre-existing
test_delete_manifest_decode_concurrencystill passes.I cannot push to
cherrypick/26.8/116723myself. Fast-forwarding it to this head makes #120406non-conflicting, which lets the automation finish the chain on its own.