Find bad usage of storage in-memory metadata#106200
Conversation
|
Workflow [PR], commit [8cae653] Summary: ❌
AI ReviewSummaryThis PR changes Findings
Performance & SafetyThe lifetime wrapper now blocks direct temporary Final VerdictStatus: Minimum required action: remove the unconditional metadata clone in |
|
The text index drops metadata when a reference to it is used. |
| }(); | ||
|
|
||
| return cache->emplace(this, IStorage::getInMemoryMetadataPtr(query_context, bypass_metadata_cache)).first->second; | ||
| return std::make_shared<StorageInMemoryMetadata>(*base); |
There was a problem hiding this comment.
This still deep-copies StorageInMemoryMetadata on every MergeTree metadata lookup, including cache hits. StorageInMemoryMetadata copy clones projections, key/index expressions, and ASTs, so analyzer/planner/read paths now pay that cost repeatedly and the query metadata cache no longer shares the object returned by getInMemoryMetadataPtr. If the goal is only lifetime ownership, return the cached/base StorageMetadataPtr inside the handle and clone only in the text-index mutation path; otherwise this needs focused before/after evidence that the extra copies are negligible.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 577/690 (83.62%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 37 line(s) · Uncovered code |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
There is no guarantee that metadata will outlive the query if the pointer is dropped early. Let's find all the places here.