Skip to content

Read the next Parquet file's offset index and first row group ahead when a source reads many files from object storage - #129495

Open
groeneai wants to merge 13 commits into
ClickHouse:masterfrom
groeneai:groeneai/parquet-next-file-read-ahead
Open

groeneai wants to merge 13 commits into
ClickHouse:masterfrom
groeneai:groeneai/parquet-next-file-read-ahead

Conversation

@groeneai

@groeneai groeneai commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Closes: #129392
Related: #128607
Related: #128374

Changelog category (leave one):

  • Performance Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Scans of many Parquet files in object storage (s3, Iceberg, Delta Lake and other data lakes) are faster: while a stream decodes a file, the reader of its next file reads the offset index and starts reading the first row group's column data, within the size of one read task (4 x remote_read_min_bytes_for_seek) and the stream's memory share. A scan of a 100M-row Iceberg table of 101 files takes 34% less time with 20 ms of latency to S3 and 24% less without added latency.

Description

A ClickHouse-written Iceberg data file is one row group (#128471); on switching to it, a stream waited for its offset index, then its column data. #128607 reads only the next file's footer ahead.

From a source's third file on, createReaderAsync also has the next file's format start reading data. ReadManager::init runs with decoding deferred: the offset index is read without the column data next to it, and the first row group's first admission round starts only if its whole chunks fit in one read task and in the stream's free ColumnData share, checked before any page is handed out. A chunk shorter than remote_read_min_bytes_for_seek is read with its neighbours: then the gaps count, and no other range to read may lie near it. Both readers of a source charge one counter (InputFormatStreamMemory), answering the per-stream budget concern that narrowed #128607. Off for local object storage, the page cache, the columns cache, TopN dynamic filtering, max_parsing_threads = 1, remote_filesystem_read_prefetch = 0 and files smaller than remote_read_min_bytes_for_seek. A failed background initialization is reported, naming the file, when the source reaches it.

Release, MinIO at 20 ms RTT, 4 threads, 6 paired rounds, fix/master [95% CI]: Iceberg scan 0.661 [0.648, 0.676], s3() glob 0.659, 16 threads 0.90-0.96, WHERE b = 5 0.992, 1000 small files 1.004; same GETs and bytes (one of 101 files: +1 GET, -2 MB). No added latency: 0.762. Peak query memory +12-14 MiB at 4 threads, up to +40 MiB at 16; server max RSS +140 / +440 MiB (no latency), decaying when idle. LIMIT 12000000: 0.86, 8 more GETs.

05507_parquet_object_storage_next_file_read_ahead covers the read-ahead, both bounds, the shared share, the offset index read alone, every exclusion above, the aggregate_function_input_format wrapper and the error messages; the shared Iceberg read perf suite gains a 4-stream scan. Analysis and original patch: @ snelheidai in #129392.


Workflow [PR]
Sync PR [sync-upstream/pr/129495]

groeneai and others added 2 commits November 5, 2026 13:38
…n object storage sources

A ClickHouse-written Iceberg data file is one row group (ClickHouse#128471), and a source of object storage
reads its files one after another. `createReaderAsync` prepares the next file's reader in the
background, but since ClickHouse#128607 only its footer is read: `ReadManager::init`, which reads the offset
index and then the column data, ran on the file's first `read`, so every file cost a stream two
dependent round trips that overlapped nothing.

From a source's third file on (a query with a small LIMIT often needs only the first file), the
next file's format now runs `ReadManager::init` in the background with decoding deferred: only
offset-index tasks run, and `readAheadFirstRowGroup` starts the first admission round of the first
row group if `Prefetcher::startPrefetchWithinLimit` fits it within the size of one read task
(`4 x remote_read_min_bytes_for_seek`) and in what the stream's ColumnData share leaves free. The
whole column chunks of that round must fit as well, checked before any page is handed out: handing
out the pages of a chunk shorter than `min_bytes_for_seek` starts reading it with the ranges less
than `min_bytes_for_seek` away (`Prefetcher::splitRange`), so when the round has such a chunk, the
gaps between its chunks count too. That read also takes the likely-to-be-used ranges near the
chunk, so with a short chunk only the file's last row group is read ahead, and only if no column
is left for a later PREWHERE step. The deferred offset-index reads coalesce only with page-index
ranges (`Prefetcher::startPrefetch` with `page_indexes_only`), so they take no column data along.
Both readers of a source charge one counter (`InputFormatStreamMemory`), so the next file's reader
does not get a second per-stream budget, which is why ClickHouse#128607 was narrowed to the footer. Bloom
filters, dictionaries, the column index and all decoding wait for the first `read`.

`addColumnDataPrefetches` hands each page of an offset-index chunk out once, so pages of reads that
do not fit are handed back (restoring `data_pages_prefetch_idx`), which is exact only when the row
filter skipped no page; without that, admission decodes through a page that was never started. The
test reaches the hand-back with two long chunks around an unread column: the chunks fit in one read
task, the read task over the gap does not. A failure of the read-ahead is stored before `read` can
schedule the row group. An error of the background initialization (and of the prefetched footer,
which ClickHouse#128607 reported without the file name) is rethrown when the source switches to the file,
with the file's name.

Not used for local object storage, the page cache, TopN dynamic filtering (its threshold may still
tighten), `max_parsing_threads = 1`, `remote_filesystem_read_prefetch = 0`, or files smaller than
`remote_read_min_bytes_for_seek` (decoding the previous file is too short to hide their request).

`AggregateFunctionStatesFromValuesInputFormat` forwards `prefetch`.

Analysis and original patch: @ snelheidai in ClickHouse#129392.

Closes ClickHouse#129392

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Condense the read-ahead comments in ReadManager.cpp, ParquetV3BlockInputFormat.cpp and IInputFormat.h; remove one that restated the code below it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

groeneai commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex) and my own review; 17 findings over 6 rounds (1 full pass, 5 delta rechecks). Bounce cap reached - published as is; residual findings listed below. The last fix round (row 13) was not re-gated.

# Sev Finding Verdict Evidence / action
1 ❌ bool failed; in ReadManager::read fails clang-tidy cppcoreguidelines-init-variables AGREE, fixed initialized
2 ⚠️ The next and the current reader race on the shared ColumnData budget DISAGREE admission rounds of one reader already race under a shared lock and admit the privileged row group over the limit (ReadManager.cpp:798-844); the new path adds at most one read task per file
3 ⚠️ The first-row-group read-ahead can create several read tasks for disjoint columns DISAGREE on impact the bytes stay within one read task; one depth slot per one-row-group run is master's convention (ReadManager.cpp:995-999)
4 ⚠️ The test does not fail without the counter shared by both readers AGREE, fixed cases g_shared_share_refused / h_shared_share_control
5 ⚠️ The test should assert that all 4 eligible files are read ahead DISAGREE best effort by design: a file reached before its background reads finish is not read ahead
6 ⚠️ The page cache, TopN, max_parsing_threads = 1 and small-file exclusions have no failing case AGREE, fixed cases i, j, k and a clickhouse-local page-cache case with a control
7 ⚠️ The only added perf query was in a long test, which PR and master perf runs skip AGREE, fixed moved to the per-commit shared Iceberg read suite
8 ⚠️ AggregateFunctionStatesFromValuesInputFormat does not forward prefetch AGREE, fixed forwarded, case l_aggregate_states
9 ⚠️ While decoding is deferred, the offset-index read coalesced adjacent column data, uncharged AGREE, fixed such reads coalesce only with page-index ranges, cases m / n
10 ⚠️ Handing out a short chunk's pages starts its read (Prefetcher::splitRange) before the limit is checked AGREE, fixed whole chunks are checked before any page is handed out, cases o / p
11 ⚠️ That check summed chunk sizes, while a short chunk's read also spans the gaps to the next chunks AGREE, fixed the merged span is checked, cases q / r
12 ⚠️ No case reached the hand-back of the pages of a refused round AGREE, fixed case s_handed_back
13 ⚠️ A short chunk's read also takes the next row groups' data or a later PREWHERE step's columns, uncharged AGREE, fixed with a short chunk only a file's last row group without PREWHERE is read ahead, cases t, u, v
14 💡 The max_insert_threads = 1 fixture pin had no reason; names in new comments were not in inline code AGREE, fixed none
15 💡 The new perf query shifted the indices of later queries of the shared suite (learned thresholds) AGREE, fixed moved to the end of the fragment
16 💡 The 4-thread scan of the latency twin runs ~1.9 s per run, near the 2 s report gate noted, not blocking none
17 💡 The short-chunk restriction of row 13 also applies to chunks without an offset index, whose reads cannot leave the round noted, not blocking conservative (less read-ahead, never more); every benchmarked file is one row group

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-10:20261105-134100

@groeneai

groeneai commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. 05507_parquet_object_storage_next_file_read_ahead: on master no file is read ahead (ParquetColumnDataReadAheadOfNextFile = 0), with the PR 4 of 6 files (the 3rd to the 6th) in every run.
b Root cause explained? The next file's reader is prepared in the background, but only its footer is read (#128607). On the file's first read() the stream waits for the offset index and then the column data: two dependent round trips that overlap nothing.
c Fix matches root cause? Yes. The prepared reader also reads the offset index and starts the first row group's first admission round, decoding nothing, bounded by startPrefetchWithinLimit (one read task) and by the stream's ColumnData share, which both readers of a source charge (InputFormatStreamMemory).
d Test intent preserved / new tests added? New stateless test: the read-ahead, every bound (one read task, short chunks and the gaps their reads span, later row groups and PREWHERE steps, the stream share charged by both readers), the hand-back of a refused round's pages, the offset index read alone, every exclusion (remote_filesystem_read_prefetch = 0, IcebergLocal, the page cache, TopN, max_parsing_threads = 1, small files), the aggregate_function_input_format wrapper, and the file name in errors. One 4-stream scan added to iceberg_suite_shared_read.xml.inc (per commit). No existing test changed.
e Both directions demonstrated? Master fails the test (a_six_files 0, footer error without the file name); the PR passes, 50/50 with randomized settings under -j 8. Each guard was removed in turn and its case turned red (e.g. without the gaps check the refused span is read: +336755 B vs 28027 B; without the last-row-group check: +192706 B vs -182 B); without handing pages back the server aborts in debug (req->state == HasTask), 3/3.
f Fix is general across code paths? IInputFormat::prefetch has one implementation (Parquet, forwarded by the aggregate_function_input_format wrapper) and one caller (StorageObjectStorageSource: s3, Azure, HDFS, every data lake). All writers of the ColumnData counter go through addMemoryUsage. While decoding is deferred, the only reads besides the bounded first round are offset-index reads, which coalesce only with page-index ranges.
g Fix generalizes across inputs (params/datatypes/wrappers)? Files with and without page index, multiple subgroups (randomized max_block_size), filtered subgroups (not read ahead), LIMIT across file boundaries, KILL, min/max and count() over 3+ files: results equal to master. Off for page cache, TopN, max_parsing_threads = 1, small files and local storage.
h Backward compatible? (maintainer-approved exception only) Yes. No setting, format or protocol change; one new ProfileEvent. Opt-out: remote_filesystem_read_prefetch = 0.
i Invariants and contracts preserved? Each reader's share of the stream counter equals its own ColumnData counter and is returned in the destructor after all tasks are drained. The current file's first unfinished row group is always admitted. A page handed out is either started or handed back, and a failed read-ahead fails the reader before admission (an injected failure: 40/40 clean errors with the file name). TSan: 0 reports.

Session id: cron:clickhouse-impl-slot-7:20261105-130700

@groeneai

groeneai commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

cc @scanhex12 @grantholly-clickhouse, could you review this and add the can be tested label so CI runs? While a stream decodes a Parquet file from object storage, the reader of its next file now also reads the offset index and starts reading the first row group's column data, bounded by one read task and by a ColumnData memory share that both readers of the source charge (the per-stream budget concern that narrowed #128607).

@clickhouse-gh

clickhouse-gh Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [749c67b]

Summary: ✅


AI Review

Summary

PR #129495 overlaps decoding the current Parquet file with bounded reads of the next file's offset index and first row group, sharing the stream's column-data memory allowance. Reviewed head 749c67bed5ba94b5536bf3e68fe8c993c571a1d6, the diff, prior discussion, scheduling and cleanup paths, regression coverage, and reported performance measurements. The three previously reported issues are addressed in the current code. No actionable findings remain.

Missing context / blind spots
  • ⚠️ Latest-head targeted and flaky CI jobs were running or pending when inspected; their completion will close the remaining validation gap. On preceding revision 68db2fb9bc14b7524861528ff24f0f78e62d57e2, 05507_parquet_object_storage_next_file_read_ahead passed the targeted ASan/UBSan job and all 50 TSan flaky-check runs. No local build or tests were run for this review.
Final Verdict

Status: ✅ Approve

With `use_columns_cache = 1`, `Reader::init` (`initColumnsCache`) looks up
and holds the cached columns of every selected row group of the file. Run
for the next file in the background, it held them while the source was
still on the current file, uncharged to the stream's memory share, and the
cache parks such columns on eviction instead of freeing them; a query that
stops early (LIMIT) also looked up a file it never read. Measured on six
warm one-row-group files, `LIMIT` over three of them: `ColumnsCacheHits`
4 before, 3 after. Keep the footer-only prefetch whenever the columns cache
is used.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 749c67bed with master 9bc53cb5f (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

56 object files changed (+57.16 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Processors/Formats/Impl/Parquet/ReadManager.cpp.o 498.87 KiB 517.70 KiB +18.83 KiB (+3.77%)

716 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.

Compile time of recompiled translation units

167 translation units recompiled, 1069 s compile time in total, 167 of them have a recent master baseline.

Job report

groeneai and others added 2 commits November 5, 2026 20:14
The arm read two 625 KB files and then a small one, and expected the third
file to be refused because the second file's chunk filled the shared 300 KB
share. But the second file charges that chunk only on its first `read`, on
the pipeline thread, while the third file decides in its background reader
creation, about 3 ms after the switch here (footer and offset index reads).
When the pipeline thread stalls longer, as on loaded CI runners, the third
file sees an empty share and is read ahead: `g_shared_share_refused` printed
1 in 9 of 150 flaky-check runs (amd_debug, amd_binary, amd_asan_ubsan),
reproduced 3 of 3 with a 20 ms sleep injected after `createReaderAsync`.

Now share/ has two small files, then files of 240 KB and 80 KB without page
index. The third file is read ahead within its reader creation, so its chunk
is charged before the source switches to it, and the fourth file is refused
for as long as the third holds that chunk, which slower rows stretch to
about one second. The arm prints the number of files read ahead: 1 for g,
2 for h (default share). Passes with a 200 ms stall after the switch and with
an 800 ms delay of the fourth file's creation; without the shared counter in
`getColumnDataMemoryUsage` it prints 2.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e near it

With a column chunk shorter than `min_bytes_for_seek`, `readAheadFirstRowGroup`
read only a file's last row group ahead, and only without PREWHERE, because
admission reads such a chunk together with the likely-to-be-used ranges near
it: the next row groups' chunks, a later PREWHERE step's columns. So a file of
several row groups was never read ahead once a queried chunk was short, e.g.
the ClickBench `hits_*.parquet` objects (2 to 5 row groups, no page index).

Refuse instead only when such a range is actually there:
`Prefetcher::hasIncidentalRangesNear` looks in range set 0 for a range that may
be read incidentally, has no read task yet, lies outside the round's chunks and
less than `min_bytes_for_seek` from one of them. A read task grows only across
gaps below `min_bytes_for_seek`, so without one it reads nothing outside the
round. Reading the round ahead with such ranges near it would also split the
single read admission makes, e.g. for files of small adjacent row groups.

New arm `x_far_row_groups`: files of three row groups whose 40 KB chunks are
kept apart by an unread column are read ahead (0 before). Without the new
check, `t_row_groups_refused` and `v_prewhere_refused` print 1 and the `t`
bytes oracle fails. Measured by @ snelheidai on the ClickBench objects (4 vCPU
arm64, 20 ms per request): 100 objects, 4 threads, 1890 ms -> 1456 ms, with
the same GETs and bytes.

Proposed in ClickHouse#129392 (comment).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

groeneai commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - fb710e1

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Performance Comparison (arm_release, master_head, iceberg_local, 1/3) and (arm_release, master_head, iceberg_s3, 1/3) / prewhere_subcolumn_read_steps not from this PR: the one error of each shard is the Iceberg rewrite refusing that test's JSON column (Column j of type JSON(max_dynamic_paths = 0) has no Iceberg equivalent). The test reached master with #124553 today and is not in tests/performance/iceberg_skip_list.txt; the same error failed these shards on 4 other PRs since 22:14 UTC a fix task is created (investigating at full effort, fixing-PR link to follow here)
PR praktika rollup of the row above a fix task is created (the same task as the row above)

Not a failure: the iceberg_s3 shard also marks projection_index_in_read_pools #0-#3 slower, which does not fail it; that verdict appeared on 2 other PRs in the last 10 days.

Session id: cron:our-pr-ci-monitor:20261106-000007

@groeneai

groeneai commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the Iceberg rewrite error of prewhere_subcolumn_read_steps in Performance Comparison (iceberg_local/iceberg_s3, 1/3): #129658

…xt-file-read-ahead

Master switched `src/Processors/Formats` to `-WithMemoryTracking` containers and added the `other_row_groups_are_read_by_other_readers` argument of `ReadManager::init`; the containers of the read-ahead of the next file follow it.
@fm4v
fm4v added this pull request to the merge queue Nov 19, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 19, 2026
groeneai and others added 2 commits November 20, 2026 02:59
Since ClickHouse#132712 randomizes the Parquet reader and writer settings, 05507 failed
the flaky check in the merge queue (78 of 186 runs on 2026-11-19). Each failing
arm traced to one setting that changes a fixture's layout or what the reader
reads, forced alone or in a pair on master + this PR:

- input_format_parquet_use_offset_index = 0 reads no offset index, so the
  oracle of m/n counts no separate offset index request (2 -> 0).
- output_format_parquet_data_page_size below a chunk splits it into pages; with
  reader blocks of 1000 or 8192 rows the first block's pages fit the read task
  and are read ahead, so the hand-back of s is not reached (0 -> 1). That read
  is within the bound: 970102 bytes with prefetch vs 971782 without.
- output_format_parquet_row_group_size_bytes = 65536 with max_block_size below
  25000 rows cuts good/ into several row groups with short chunks, which are
  not read ahead (a, l and the page cache control 1 -> 0).
- compression_method = 'none' with no dictionary makes the small/ files larger
  than remote_read_min_bytes_for_seek, so they are read ahead (j 0 -> 1).

The limits line clamps these five to their defaults. 160 of 160 randomized
runs of the test pass with it, 28 of 50 with the line disabled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`hasIncidentalRangesNear` compared every registered range of the file with
every chunk of the round, so for a file whose columns are all short it took
O(columns^2) per next file. It now sorts the round's chunks once, keeps the
running maximum of their ends (chunks of a malformed file may overlap), and
finds the neighbours of each range by binary search: O(ranges * log(chunks)).
The result is the same as before: 0 differences in 3,000,000 random cases
(overlapping and empty ranges, seek threshold 0) and in 624 calls made by
05507 on master + this PR, where both answers occur.

The check also runs only after the cheaper size bound, which refuses the round
the same way.

Measured on a debug build, `SELECT *` over 12 files of 4000 UInt8 columns
(1000 rows, one row group each), one stream, 10 files read ahead: median
589 / 623 ms before, 524 / 526 ms after; user CPU 903 / 948 ms before,
657 / 661 ms after (two alternating rounds of 7 runs). With 2000 columns one
call took 5.2 ms before and 0.10 ms after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

The merge queue removed this PR because 05507_parquet_object_storage_next_file_read_ahead failed its flaky check once #132712 started randomizing the Parquet reader and writer settings: the page size, the row group byte size, compression without a dictionary and input_format_parquet_use_offset_index = 0 change the layout of its fixtures or what the reader reads. 2d2ebaf clamps those five with a Random settings limits line (160 of 160 randomized runs pass locally, 28 of 50 with the line disabled).

6eef247 also makes hasIncidentalRangesNear binary-search the round's chunks instead of comparing every range with every chunk, which was quadratic in the number of short columns (same results; 12 files of 4000 columns: 589 -> 524 ms median on a debug build). It can go back into the queue once CI is green.

groeneai and others added 2 commits November 20, 2026 06:20
When reading the next file's first row group ahead fails after its pages were
handed out (`addColumnDataPrefetches`) but before their read tasks exist, the
exception is stored and that row group keeps its schedulable bit. The first
`read` checked the exception only after clearing `decoding_deferred`, so an
offset-index batch of another row group finishing in between could schedule
the row group's `ColumnData` tasks, whose decoding then reached
`Prefetcher::getRangeData` for a page without a read task.

`read` now checks the exception under `column_data_prefetch_mutex`, under which
`deferTasks` stores it, and clears the flag only when there is none, so the
reader of a failed read-ahead never schedules anything and the exception is
rethrown.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
05507 failed the flaky checks twice on 6eef247 (amd_tsan and
amd_asan_ubsan, 1 of 50 each): the clickhouse-local control read without the
page cache did not read the next file ahead. It read good/{0,1,2}, where only
the third file is a candidate, and those files have a page index, so the
decision waits for the offset index read in the background and is skipped when
the source switches to the file first, as happens on a loaded sanitizer runner.

The block now reads share/, whose files have no page index: their first row
group is read ahead while the reader is created, which the source waits for
before it switches, so the control does not depend on timing. The page cache
case still prints 0 for those files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
clickhouse-gh[bot]
clickhouse-gh Bot previously approved these changes Nov 20, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 085e7f1

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (arm_asan_ubsan, targeted) / Logical error: Deadlock in Parquet::ReadManager (thread pool). (STID: 2711-2f88) not from this PR: a later row group holds the Dictionary stage's memory while the first incomplete row group waits for it, reachable with a small randomized input_format_parquet_memory_high_watermark. The same signature hit master 4 times and 20 other PRs since 2026-11-19 15:30Z #133083 (external, open)
Stateless tests (arm_asan_ubsan, targeted) / Server liveness check failed the server aborted on the LOGICAL_ERROR in the row above #133083 (external, open)
PR praktika rollup of the rows above #133083 (external, open)

Mergeable Check is red only because of the rows above.

Session id: cron:our-pr-ci-monitor:20261120-110103

@clickhouse-gh
clickhouse-gh Bot dismissed their stale review November 20, 2026 15:33

AI review of a later commit does not approve the PR, see the AI Review comment.

When `readAheadFirstRowGroup` throws in a pool thread (reached from an
offset index batch through `flushMemoryUsageDiff`), `deferTasks` stores
the exception and rethrew the same object. `runBatchOfTasks` then
appends the read stage and the column to it with `addMessage` outside
`delivery_mutex`, while `read`, once the source has switched to this
file, copies the stored exception under `delivery_mutex`. That is a data
race on the exception's message.

Keep the stored exception immutable and rethrow a copy, as
`FormatFilterInfo::initKeyConditionOnce` does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@stresshouse

stresshouse Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 29 queries analysed

No query shows a performance change caused by this PR. The PR adds read-ahead of the next file's offset index and first row group for Parquet files in object storage, and only does this once a source is past its second file. The single flagged query is clickbench Q10, a COUNT(DISTINCT) GROUP BY aggregation that was 20.9% faster (87 ms vs 110 ms). That result was suppressed because 87 ms is inside master's normal range of 83-115 ms, and this query's history is noisy. The suppression is consistent with the code: this query doesn't run the changed Parquet path, so there is no basis to contest it.

clickbench

🟢 No significant changes

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 42ff1450-b273-4122-a07a-8514fc9e75e8
  • MIRAI run: 28a4a8f9-c131-4343-938d-6e07b8584d2b
  • PR check IDs:
    • clickbench_548815_1795209715
    • clickbench_548821_1795209715
    • tpch_adapted_1_official_548835_1795209715
    • tpch_adapted_1_official_548879_1795209715

…xt-file-read-ahead

Resolves the conflict in `Reader::initializePrefetches` with ClickHouse#129430: an offset index kept with the cached
footer is used as is, and the one still read is registered as a page index.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-parquet-reader-v3 Issues related to the native Parquet reader. pr-performance Pull request with some performance improvements

Projects

None yet

2 participants