Repository navigation
Initialize parquet reader a bit earlier - #128607
Conversation
|
Workflow [PR], commit [6804acf] Summary: ✅
AI ReviewSummaryThe PR prefetches the next object-storage file's PR Metadata
Findings❌ Blockers
Tests
Final Verdict❌ Block. Keep whole-file inputs lazy, preserve filenames on prefetch exceptions, and add focused regression coverage. Both code findings already have open inline threads; no duplicate comments were posted. |
…f a source Address the review of the previous commit: - `ObjectStorageQueueSource` also calls `StorageObjectStorageSource::createReader`, before it registers the file. Initializing the format there moved a footer error out of its per-file error handling. Now `createReader` initializes the format in advance only when asked, and only `createReaderAsync` of `StorageObjectStorageSource` asks, so the queue and the first file of a source stay lazy. - Initializing the reader in advance also started reading and decoding the column chunks, so a source had two readers, each entitled to the whole memory allowance of a stream. Now `prefetch` only reads the footer (`readFileFooterIfNeeded`), and the reader is initialized on the first `read`. #128607 Co-Authored-By: Claude Opus 5.5 <[email protected]>
| }); | ||
|
|
||
| auto new_reader = std::make_unique<Parquet::ReadManager>(); | ||
| new_reader->reader.prefetcher.init(in, read_options, parser_shared_resources); |
There was a problem hiding this comment.
[P1] Keep whole-file buffering out of footer prefetch
readFileFooterIfNeeded is not limited to metadata I/O: Prefetcher::init calls determineReadModeAndFileSize, which copies the entire input into entire_file when input_format_allow_seeks = 0 or the input cannot seek (including externally compressed .parquet.gz files). This happens before the metadata-cache lookup, even on a cache hit.
StorageObjectStorageSource starts this work for reader_future while its current reader is still alive. A single source reading two large files can therefore retain both complete files simultaneously, in addition to the current decoder's memory. Previously only the active file was buffered this way, so queries that fit max_memory_usage can now fail; the Parquet decoding watermarks do not bound entire_file.
Please keep these inputs lazy by checking that footer initialization can use bounded range reads before calling Prefetcher::init. Cover a two-file read with max_threads = 1, input_format_allow_seeks = 0, and a memory limit that permits one buffered file but not two.
| input_format->needOnlyCount(); | ||
|
|
||
| if (prefetch_input_format) | ||
| input_format->prefetch(); |
There was a problem hiding this comment.
[P2] Preserve the offending filename on prefetched footer errors
Previously footer parsing ran through IInputFormat::generate, whose exception handler adds (in file/uri ...). This call runs outside that handler, and the background scheduler passes the exception unchanged to reader_future.get.
For example, with a valid 0.parquet followed by a corrupt 1.parquet, the footer now raises Not a Parquet file (wrong magic bytes at the end of file) without identifying the bad object. A glob containing many files consequently gives users no filename to repair or exclude. The new malformed-file test only checks INCORRECT_DATA, so it misses this regression.
Please annotate and rethrow prefetch exceptions with the input filename, as IInputFormat::generate does, and extend the malformed-file assertion to require that filename.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units161 translation units recompiled, 1324 s compile time in total, 161 of them have a recent master baseline. |
…icas With parallel replicas `s3` is rewritten to `s3Cluster`, and the Parquet metadata cache hits are counted by secondary queries, which run in the `default` database. Sum `ParquetMetadataCacheHits` over `initial_query_id`. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=128607&sha=ecd7c592358da0b17407b87655b03e625da673d9&name_0=PR PR: #128607 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cherry pick #128607 to 26.10: Initialize parquet reader a bit earlier
Cherry pick #128607 to 26.9: Initialize parquet reader a bit earlier
Cherry pick #128607 to 26.8: Initialize parquet reader a bit earlier
Cherry pick #128607 to 26.3: Initialize parquet reader a bit earlier
Backport #128607 to 26.8: Initialize parquet reader a bit earlier
Backport #128607 to 26.10: Initialize parquet reader a bit earlier
Backport #128607 to 26.9: Initialize parquet reader a bit earlier
Backport #128607 to 26.3: Initialize parquet reader a bit earlier
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Initialize parquet reader a bit earlier
Workflow [PR]
Sync PR [sync-upstream/pr/128607]
Version info
26.11.1.1146-master(included in26.11and later)