Repository navigation
add tsa annotation to column sizes and indexes around lazy evaluation - #99240
Conversation
…rge tree part data
|
Workflow [PR], commit [4369345] Summary: ❌
|
alesapin
left a comment
There was a problem hiding this comment.
Good change, the only thing -- maybe we can use MultiVersion to avoid copies?
I've tried, but it looks heavy and kinda brings in this "atomic" semantic which is redundant since we have to hold mutex, so you are starting doing unlocks and etc. I think that more natural choice it's just a shared_ptr for columns sizes, since we have to lock the mutex for "lazy calculation" anyway for indexes sizes. This approach is pretty straightforward as well. (less LOC also, but who cares nowadays). |
LLVM Coverage Report
PR changed lines: PR changed-lines coverage: 90.53% (86/95, 2 noise lines excluded) |
The problem that lazy evaluation of indexes sizes might lead to data races and it should be carefully used, so I think it's mandatory to have TSA annotations here to prevent problems with that laziness.
There is one problem still though, even after this PR code relies on the fact that checksums are preloaded before part could be accessed from any thread. AFAIU this is true now, until we have lazy checksum preload.
Another change with this PR which could lead to side-effects that columns sizes are copied now instead of passing by reference - if the map is very big could be performance penalty for copying that.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes
Note
Medium Risk
Touches MergeTree part size caching and locking semantics; incorrect locking or pointer lifetime could affect concurrent reads and size-based heuristics, and the new
MultiVersionindirection may have minor performance implications.Overview
Improves thread-safety around lazy on-disk size calculation for MergeTree parts by adding TSA annotations, switching callers to
UniqueLock, and splitting calculation into a mutex-heldcalculateColumnsAndSecondaryIndicesSizesOnDiskUnlocked()helper.Changes the column-size cache from an in-place map to
MultiVersion<ColumnSizeByName>and updatesgetColumnSizes()to return a shared pointer snapshot, updating read-path users (MergeTreeReadPoolBase,MergeTreeReadTask) to dereference the returned pointer. This avoids exposing mutable references while allowing lock release before iterating sizes.Written by Cursor Bugbot for commit 64f890b. This will update automatically on new commits. Configure here.
Version info
26.4.1.195