Skip to content

Move more fields from MergeTreeDataPart into a shared per-table cache - #93694

Closed
nikitamikhaylov wants to merge 14 commits into
masterfrom
fitting-the-part
Closed

nikitamikhaylov wants to merge 14 commits into
masterfrom
fitting-the-part

Conversation

@nikitamikhaylov

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

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

Extending a per-table cache for parts fields, reducing memory usage when tables contain many parts and many columns.

Details

A jemalloc profile report.pdf showed that a big chunk of memory is eaten by IMergeTreeDataPart fields even with an improvement done here #89352 by @azat

image

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@clickhouse-gh

clickhouse-gh Bot commented Jan 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [502e40c]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_tsan, flaky check) FAIL
Start ClickHouse Server FAIL
Stateless tests (amd_debug, parallel) FAIL
03823_optimize_dry_run_projections FAIL cidb
Stateless tests (amd_tsan, parallel, 1/2) FAIL
Start ClickHouse Server FAIL
Stateless tests (amd_tsan, parallel, 2/2) FAIL
Start ClickHouse Server FAIL
Stateless tests (arm_binary, parallel) FAIL
03823_optimize_dry_run_projections FAIL cidb
Fast test (arm_darwin) DROPPED
Build (amd_release) DROPPED
Build (arm_release) DROPPED
Build (amd_darwin) DROPPED
Build (arm_darwin) DROPPED

AI Review

Summary

This PR extends the per-table sharing of MergeTree part metadata and adds count/byte observability for the new caches. The main ownership and eviction fixes from the earlier review look addressed in the current head, but the new byte accounting for columns_descriptions_cache is still incomplete: it does not count the copied NamesAndTypesList key stored in the cache map, so the exposed *_cache_bytes values under-report memory on wide schemas.

Findings

⚠️ Majors

  • [src/Storages/MergeTree/MergeTreeData.cpp:11480] columns_descriptions_cache_bytes is intended to describe the full per-table cache footprint, but cache_bytes only accounts for the shared value objects. columns_descriptions_cache.emplace(columns, cache) also copies columns into the unordered_map key, and that copied NamesAndTypesList allocates its own list nodes via a different allocator. Those bytes are never added on insert or removed on eviction, so the new metric and system.tables column systematically report less memory than the cache actually keeps alive. Suggested fix: after a successful emplace, include it->first.get_allocator().getBytesAllocated() in the byte total and subtract the same amount in decrefColumnsDescriptionForColumns.
Final Verdict

Needs changes before merge: the new byte metric for columns_descriptions_cache does not yet measure the full cache footprint.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Jan 8, 2026
@nikitamikhaylov
nikitamikhaylov marked this pull request as ready for review January 12, 2026 15:17
@nikitamikhaylov
nikitamikhaylov requested a review from azat January 13, 2026 10:53
@nikitamikhaylov

Copy link
Copy Markdown
Member Author

@azat WDYT? 😢

@azat azat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general LGTM, please take a look at the comments

Comment thread src/Storages/MergeTree/MergeTreeData.h Outdated
};

mutable std::mutex parts_metadata_cache_mutex;
mutable std::unordered_set<std::shared_ptr<const NamesAndTypesList>, SharedNamesAndTypesListHash, SharedNamesAndTypesListEqual> columns_list_cache TSA_GUARDED_BY(parts_metadata_cache_mutex);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also expose it via system.tables and write a test, similar to getColumnsDescriptionsCacheSize

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also it make sense to add refcnt as well, to measure how many cache hits we have

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though it looks OK

SELECT
    `table`,
    parts,
    columns_descriptions_cache_size,
    parts / columns_descriptions_cache_size AS q
FROM system.tables
WHERE (q IS NOT NULL) AND (NOT isNaN(q))
ORDER BY q ASC
LIMIT -10

Query id: 50963446-7d1e-4c2e-9263-9a6648822418

    ┌─table────────────────────────────────────────────┬─parts─┬─columns_descriptions_cache_size─┬─────────────────q─┐
 1. │ processors_profile_log_7590787529836127017       │   817 │                               3 │ 272.3333333333333 │
 2. │ aggregated_zookeeper_log_14962686554716995193    │   584 │                               2 │               292 │
 3. │ asynchronous_insert_log_12366379321827847140     │   302 │                               1 │               302 │
 4. │ transactions_info_log_2864128213711090115        │   927 │                               3 │               309 │
 5. │ query_views_log_17494275091474536648             │   943 │                               3 │ 314.3333333333333 │
 6. │ background_schedule_pool_log_8901488774449704592 │   957 │                               3 │               319 │
 7. │ text_log_8722955205913565286                     │  1046 │                               3 │ 348.6666666666667 │
 8. │ text_log_15470189561651757858                    │  1227 │                               3 │               409 │
 9. │ asynchronous_insert_log_4169292021092689014      │  1551 │                               3 │               517 │
10. │ asynchronous_insert_log_7963218501266431824      │  2261 │                               3 │ 753.6666666666666 │
    └──────────────────────────────────────────────────┴───────┴─────────────────────────────────┴───────────────────┘

nikitamikhaylov and others added 3 commits January 19, 2026 16:46
Co-authored-by: Azat Khuzhin <[email protected]>
…tainers

(cherry picked from commit a2ef2fc24be848cba56a852d502aaefa02aa3a8d)
@nikitamikhaylov

nikitamikhaylov commented Jan 27, 2026 •

Copy link
Copy Markdown
Member Author

@azat I've added a special allocator that can help counting memory for these shared caches. Look what it can do :)

SELECT
    name,
    formatReadableSize(names_and_types_cache_bytes) AS names,
    formatReadableSize(columns_descriptions_cache_bytes) AS columns
FROM system.tables
WHERE engine = 'MergeTree'

Query id: ec806966-0d11-4257-899b-1bba61672cbb

    ┌─name─────────────────────────┬─names──────┬─columns────┐
 1. │ aggregated_zookeeper_log     │ 1.62 KiB   │ 7.29 KiB   │
 2. │ asynchronous_metric_log      │ 952.00 B   │ 4.66 KiB   │
 3. │ background_schedule_pool_log │ 2.13 KiB   │ 8.24 KiB   │
 4. │ error_log                    │ 1.96 KiB   │ 7.99 KiB   │
 5. │ metric_log                   │ 273.52 KiB │ 723.32 KiB │
 6. │ metric_log_0                 │ 273.01 KiB │ 721.96 KiB │
 7. │ part_log                     │ 5.05 KiB   │ 18.99 KiB  │
 8. │ processors_profile_log       │ 3.85 KiB   │ 13.79 KiB  │
 9. │ query_log                    │ 14.16 KiB  │ 48.29 KiB  │
10. │ session_log                  │ 3.85 KiB   │ 15.01 KiB  │
11. │ text_log                     │ 4.20 KiB   │ 15.71 KiB  │
12. │ trace_log                    │ 4.37 KiB   │ 15.96 KiB  │
13. │ trace_log_0                  │ 4.37 KiB   │ 15.96 KiB  │
14. │ trace_log_1                  │ 4.37 KiB   │ 15.96 KiB  │
15. │ trace_log_2                  │ 4.37 KiB   │ 15.96 KiB  │
16. │ trace_log_3                  │ 4.37 KiB   │ 15.96 KiB  │
17. │ trace_log_4                  │ 4.37 KiB   │ 15.96 KiB  │
18. │ trace_log_5                  │ 4.37 KiB   │ 15.96 KiB  │
19. │ trace_log_6                  │ 4.37 KiB   │ 15.96 KiB  │
20. │ zookeeper_connection_log     │ 2.48 KiB   │ 9.55 KiB   │
    └──────────────────────────────┴────────────┴────────────┘

@azat azat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not looked at MergeTreeData yet, will look after serialization changes.

/// This allocator allows to track memory usage of containers of arbitrary types.
/// The usage is simple: container.get_allocator().getBytesAllocated()
template <typename T>
struct BytesAwareAllocatorWithMemoryTracking

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe AllocatorWithMemoryAndUsageTracking will be a better name?
Or something similar

/// During the container copy, the copied allocator should receive
/// the previously defined amount of bytes allocated and then live its own life.
BytesAwareAllocatorWithMemoryTracking<T> allocator;
allocator.bytes_allocated = bytes_allocated;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be allocator.bytes_allocated = std::make_shared<size_t>(*bytes_allocated) ?

return bytes_allocated == other.bytes_allocated;
}

std::shared_ptr<size_t> bytes_allocated = std::make_shared<size_t>(0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment why it is shared_ptr? Apparently for rebind

BytesAwareAllocatorWithMemoryTracking(BytesAwareAllocatorWithMemoryTracking && other) noexcept
: bytes_allocated(std::move(other.bytes_allocated))
{
other.bytes_allocated = std::make_shared<size_t>(0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we move, should be allocate other.bytes_allocated? If not, maybe std::exchange is enough? (same goes for operator=(&&)

@azat

azat commented Jan 27, 2026

Copy link
Copy Markdown
Member

I've added a special allocator that can help counting memory for these shared caches. Looks what is can do :)

This is top-notch!

@alexey-milovidov alexey-milovidov added memory When memory usage is higher than expected and removed memory-footprint-reduction labels Jan 29, 2026

/// Pool for constant serialization objects.
/// Used to create them only once and share them between different columns.
class SerializationObjectPool

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see there is already a DataTypesCache class. Maybe I can unify it

@amosbird

Copy link
Copy Markdown
Collaborator

Great work! Have you considered extending this more aggressively to a global cache across tables?

I've discussed this with @azat in TG. In my fork, I've implemented a global ColumnsDescription cache using a flyweight design pattern — the shared_ptr custom deleter auto-evicts entries when refcount drops to zero, so we don't need to modify the destructors of parts intrusively.

This global cache helps significantly in scenarios where there are many similar tables — for example, when some systems split tables by day (treating each table as a partition for flexible management). In such setups, the per-table cache still results in duplicated metadata across tables with identical schemas.

The code looks like this:

std::shared_ptr<ColumnsDescription> getColumnsDescription(const NamesAndTypesList & columns)
{
   static std::shared_mutex columns_description_pool_mutex;
   static absl::flat_hash_map<std::string_view, std::weak_ptr<ColumnsDescription>> columns_description_pool;

   auto key = std::make_unique<String>(columns.toString());

   {
       std::shared_lock<std::shared_mutex> read_lock(columns_description_pool_mutex);
       auto it = columns_description_pool.find(*key);
       if (it != columns_description_pool.end())
       {
           if (auto res = it->second.lock())
               return res;
       }
   }

   std::unique_lock<std::shared_mutex> write_lock(columns_description_pool_mutex);
   auto [it, inserted] = columns_description_pool.emplace(*key, std::weak_ptr<ColumnsDescription>());
   if (!inserted)
   {
       if (auto res = it->second.lock())
           return res;
   }

   CurrentMetrics::add(CurrentMetrics::PartsColumnsDescriptions);
   CurrentMetrics::set(CurrentMetrics::PartsColumnsDescriptionsCapacity, columns_description_pool.capacity());

   std::shared_ptr<ColumnsDescription> ret{
       new ColumnsDescription(columns),
       [k = std::move(key)](ColumnsDescription * ptr)
       {
           {
               std::unique_lock<std::shared_mutex> lock(columns_description_pool_mutex);
               columns_description_pool.erase(*k);
               CurrentMetrics::sub(CurrentMetrics::PartsColumnsDescriptions);
               CurrentMetrics::set(CurrentMetrics::PartsColumnsDescriptionsCapacity, columns_description_pool.capacity());
           }
           delete ptr;
       }};

   it->second = ret;
   return ret;
}

I'd love to hear your thoughts on whether a global approach could be integrated here. Also noticed that the serialization object pool you split out in #96563 is already a global pool — so it seems natural to take the same approach for other fields as well, making it consistent across the board.

@nikitamikhaylov

Copy link
Copy Markdown
Member Author

Hi @amosbird
I think having the global pool would be better. My end goal is to stick to the least error-prone approach that would require minimum boilerplate code. He I just integrated it with what we already had in the codebase.

@amosbird

Copy link
Copy Markdown
Collaborator

Thanks for the clarification. Hope to see some future improvements on the global cache path 🙂

@nikitamikhaylov

Copy link
Copy Markdown
Member Author

@amosbird Maybe you can help review this PR? 🥹 #96563

@alexey-milovidov alexey-milovidov added the close in a month if not active This will be closed in case of no information label Mar 24, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

@nikitamikhaylov, SerializationObjectPool was reviewed and merged ages ago.

@nikitamikhaylov nikitamikhaylov removed the close in a month if not active This will be closed in case of no information label Mar 27, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Dear @azat, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

@clickhouse-gh clickhouse-gh Bot assigned azat and unassigned azat Jun 1, 2026
alexey-milovidov and others added 3 commits June 29, 2026 07:24
Reconcile the per-table shared-cache changes with master's independent
memory work for `IMergeTreeDataPart` metadata, and address review feedback.

Conflicts and reconciliation:
* `NamesAndTypesList` now derives from a `std::list` using
  `BytesAwareAllocatorWithMemoryTracking` (keeping master's
  `VectorWithMemoryTracking` for `NamesAndTypes`); the bytes-aware allocator
  still delegates allocation to `AllocatorWithMemoryTracking`, so master's
  memory-tracking guarantees are preserved while `getBytesAllocated` becomes
  available for the caches.
* `getColumnsDescriptionForColumns` combines master's nullable
  `with_collected_nested` / `share_nested_offsets` with this branch's shared
  `column_name_to_position` and byte accounting.
* `setColumns` keeps master's `ScopedJemallocThreadArena` and the nullable
  `with_collected_nested` fallback together with the shared caches.
* `MergeTreeDataPartWide`/`checkDataPart` adopt master's substreams-based
  consistency checks, dereferencing the now-shared `columns` member.

Review fixes folded in:
* `BytesAwareAllocatorWithMemoryTracking::allocate` increments the byte
  counter only after a successful allocation (no drift on a throwing alloc).
* `select_on_container_copy_construction` returns a fresh (zero) counter so a
  copied container tracks only its own bytes instead of double-counting into
  the source's counter; move ctor/assignment use `std::exchange`.
* Restore metric semantics: `ColumnsDescriptionsCacheSize` stays a count
  (+/-1) and the byte totals go to a separate `ColumnsDescriptionsCacheBytes`
  handle; wire `NamesAndTypesCacheSize`/`NamesAndTypesCacheBytes` handles too.
* Compute `cache_bytes` after deduplication so a discarded
  `with_collected_nested` (null when equal to `original`) is not over-counted.
* Fix the off-by-one eviction check in `decrefNamesAndTypesListInSharedCache`
  (the part's `columns` is not reset before the call, so the count is 2).
* Fix the `projeciton` typo in `checkDataPart`.

Fix the `Build (arm_tidy)` failure
(https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=93694&sha=fd89fafb5b4e00fceae8177c3d1673f51cea6d48&name_0=PR&name_1=Build%20%28arm_tidy%29):
the allocator's required non-explicit rebind constructor is marked
`NOLINT(google-explicit-constructor)` and `NameToPositionMap` uses the
transparent `std::equal_to<>`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* `gtest_bytes_aware_allocator` covers exception-safe byte accounting in
  `allocate`, container tracking, the copy path (fresh per-copy counter, no
  double-counting into the source), and the move path.
* `04417_names_and_types_cache_in_system_tables` checks that parts with the
  same structure share a single cache entry and that the `*_cache_size`
  columns stay count-based while `*_cache_bytes` report byte sizes.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh clickhouse-gh Bot added the submodule changed At least one submodule changed in this PR. label Jul 2, 2026
Fix submodule pointer regression that broke CMake configuration in
`Fast test` and `Build (arm_tidy)`.

Every merge of master into this long-lived branch was silently keeping
the branch's stale submodule commits for `contrib/xz`, `contrib/usearch`,
`contrib/wasmedge`, and `contrib/wasmtime` instead of master's. The stale
`contrib/xz` pointed at a pre-5.8.3 commit missing
`contrib/xz/src/liblzma/check/crc32_arm64.h`, so CMake failed with
"Cannot find source file" / "No SOURCES given to target: _liblzma".

This PR does not touch these contribs, so reset all four gitlinks to
master's values.

CI report: #93694
… signature

`master` changed `IStorage::getInMemoryMetadataPtr` to take
`(ContextPtr query_context, bool bypass_metadata_cache)` and to return a
lifetime-safe `StorageMetadataHandle` whose rvalue `operator->` is deleted
(to catch dangling references into a temporary snapshot). The new call site
added by this branch in `checkDataPart.cpp` still used the old no-argument
form and bound a reference directly into the returned temporary, which both
failed to compile and would have dangled.

Store the snapshot in a local so `projections_description` stays valid for
the whole loop, and pass `(nullptr, /*bypass_metadata_cache=*/true)` since
no query context is available on the data-part check path.

Verified locally by compiling `checkDataPart.cpp` (ARM debug build).
cache_bytes += cache.with_collected_nested->getBytesAllocated();
cache_bytes += cache.column_name_to_position->get_allocator().getBytesAllocated();

auto [_, inserted] = columns_descriptions_cache.emplace(columns, cache);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

columns_descriptions_cache_bytes is still missing one whole allocation class here: columns_descriptions_cache.emplace(columns, cache) copies columns into the unordered_map key, and that copied NamesAndTypesList allocates its own list nodes through the key's allocator. cache_bytes only sums the shared value objects, so wide schemas will under-report both system.tables.columns_descriptions_cache_bytes and CurrentMetrics::ColumnsDescriptionsCacheBytes.

Please include the stored key's get_allocator().getBytesAllocated() in the inserted/evicted byte total (for example via the iterator returned by emplace).

@clickhouse-gh

clickhouse-gh Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Dear @azat, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

@clickhouse-gh clickhouse-gh Bot unassigned azat Jul 8, 2026
@Algunenano Algunenano self-assigned this Jul 13, 2026
@Algunenano

Copy link
Copy Markdown
Member

Closing in favor of #109816


What #93694 is

Nikita's PR (Jan 2026, approved by azat but now CONFLICTING and stalled since ~February) extends azat's original columns_descriptions_cache (#89352 — the cache our branch generalized) with exactly two more shared members plus observability:

1. Shares columns via a second, separate cache (columns_list_cache, an unordered_set<shared_ptr<const NamesAndTypesList>> deduplicated by content), released from the part destructor with a hand-computed use_count() == 2 threshold.
2. Shares column_name_to_position by adding it into the existing ColumnsDescriptionCache entry.
3. Explicitly stops there — the diff carries a TODO: "Make the serialization and serialization_infos also shared across parts… difficult, because of the non-obvious way how to hash or compare these objects." That's precisely the problem our recursive-kind-encoding keys solved.
4. Byte-level observability: a BytesAwareAllocatorWithMemoryTracking (shared-counter allocator) threaded into NamesAndTypesList (changes its base type), ColumnsDescription's containers, and the cache maps; new metrics and three new system.tables columns (columns_descriptions_cache_bytes, names_and_types_cache_size/bytes), a gtest, and a stateless test.
5. A checkDataPart.cpp fix: for potentially-broken projection parts, take the column list from the table metadata snapshot instead of projection->getColumns() (a broken projection part never loads its columns).

Superseded — yes, the core is fully covered and ours goes further

- Both of its shared members live in our SharedPartColumns bundle, with one handle, one release path, and the holder-enforced accounting — versus its two caches, two mutexes, and two distinct hand-computed use_count thresholds (==1 and ==2), which is more of exactly the #105376 bug-class surface the issue told us to avoid.
- Everything it declared too difficult is done on our branch: serializations and substreams shared (whole-object + per-column granularity, surviving sparsity fragmentation), default-info normalization, arena routing, probe-first builds.
- Its nullable-columns + chassert getters are strictly worse than our empty-sentinel design (their own diff had to patch checkDataPart because broken parts made the members null).
- One design discussion there is worth noting: amosbird pushed for a global cross-table cache; Nikita chose per-table as least error-prone — same call we made, and our issue comment already records the per-table→per-bundle hoist as the future lever. Related: master already has a global SerializationObjectPool (#96563, merged March) deduplicating individual ISerialization objects by content hash — so our ColumnGroups compose already-pooled leaf objects; the two mechanisms are complementary, not redundant.

Not superseded — two things worth taking

1. Byte-level cache metrics. We expose entry counts only; their *_cache_bytes view is genuinely useful for production observability of the incident workload. I would adopt the idea but not the mechanism: the allocator plumbing changes NamesAndTypesList's base type across the codebase, whereas all our interned objects are immutable — we can compute each entry's byte size once at intern time and keep running totals per bundle, no allocator changes at all. That also composes with the system.tables columns they added.
2. The checkDataPart projection fix. Not in master today, independent of both PRs, and fixes a real latent issue (checking a broken projection against its unloaded — for us: empty-sentinel — column list instead of the metadata's). Small, self-contained, arguably belongs in its own PR with proper attribution to #93694.

About missing / differences:

  • Byte level metrics. Not needed anymore, we have a MergeTree Arena just for metadata, which gives us metrics for free.
  • checkDataPart: Good fix, but I'll move it to a different branch/PR
  • Global vs per table cache: Same idea as this PR. Right now Share schema-derived per-part metadata across MergeTree data parts #109816 also implements a per table cache. Maybe in the future we could decide to move a global cache, but for now I think starting the simplest option is the best.

@Algunenano Algunenano closed this Jul 13, 2026
diegomestre2 pushed a commit to diegomestre2/ClickHouse that referenced this pull request Jul 14, 2026
…d to load

A projection part that fails to load before its columns are set (for example
because of a corrupted serialization.json) has an empty column list. CHECK TABLE
compared the projection's on-disk columns.txt against that empty list and
reported a misleading "Columns doesn't match ... Expected: 0 columns" error,
hiding the real corruption. Take the expected columns from the projection
metadata when the part's own columns are unavailable, so the check proceeds and
reports the actual broken file. Extracted from ClickHouse#93694.

Co-Authored-By: Claude Fable 5 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…d to load

A projection part that fails to load before its columns are set (for example
because of a corrupted serialization.json) has an empty column list. CHECK TABLE
compared the projection's on-disk columns.txt against that empty list and
reported a misleading "Columns doesn't match ... Expected: 0 columns" error,
hiding the real corruption. Take the expected columns from the projection
metadata when the part's own columns are unavailable, so the check proceeds and
reports the actual broken file. Extracted from ClickHouse#93694.

Co-Authored-By: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

memory When memory usage is higher than expected pr-improvement Pull request with some product improvements submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants