Repository navigation
Conversation
A part's skip indices can be bundled into one archive (`skp_idx.packed`, or a virtual file of that name inside `data.packed` on packed part storage), and reading any of them first requires that archive's index. That read is lazy and happens at most once per part storage object, on the first access to a bundled skip index. No counter names it: it only ever showed up mixed into general I/O counters such as `FileOpen` and `ThreadpoolReaderReadBytes`, so an extra object-storage read of a part's index archive could not be attributed from `system.events` or from the `ProfileEvents` map of `system.part_log`. Count it at both sites that perform the read: - `DataPartStorageOnDiskPacked::getSkipIndicesPackedReader`, which resolves the inner index through the outer archive reader - `DataPartStorageOnDiskBase::getSkipIndicesPackedReader`, which opens the standalone archive on `Full` part storage Both increments sit after the `skip_indices_packed_probed` memo check, so a memoized second call counts nothing, and before the read itself, so an attempt that ends in the 404 path is counted. That path deliberately does not cache a miss, so a re-probe after a relocation counts again. The seeding paths (`seedSkipIndicesPackedReader`, `seedSkipIndicesPackedReaderFrom` and the writer) install an index without reading one, and do not count. Measured on a mutation of a packed part carrying two minmax indices: a part whose sizes are computed at load reports 1, a part that keeps them lazy reports 0, and the same fixture on `Full` part storage with index packing disabled reports 0. Co-Authored-By: Claude Opus 5 <[email protected]>
04653_packed_part_size_accounting_no_read_in_commit asserted that the commit does
not read a part's skip-index archive by comparing two incidental I/O aggregates
of the whole mutation between a cold arm and a warm control:
maxIf(ProfileEvents['FileOpen'], cold) < ... warm
maxIf(ProfileEvents['ThreadpoolReaderReadBytes'], cold) < ... warm
The entire margin between the two arms is one `disk->readFile`. Measured: cold
`FileOpen` 12 against warm 13, and cold `ThreadpoolReaderReadBytes` 32825
against warm 33215. Both assertions were therefore of the form
`baseline < baseline + 1`, so any one-unit perturbation of unrelated I/O on
either side flipped both rows together. It did: 7 failures against 20774 passes
since the test was added, always both rows at once.
It is not a randomized-settings draw. The two most recent failures were re-run
124 and 121 times with byte-identical randomized settings and did not reproduce
once, so pinning a setting or clamping its range would close nothing.
Assert the operation actually under test instead, as absolute counts on
`PackedSkipIndicesArchiveIndexLoads`. The cold arm must be 0, because the commit
no longer reads and the sizes stay lazy, so the archive is not resolved at all.
The warm control must be exactly 1, because it computes the cloned part's sizes
at load and a part storage resolves that index at most once. No other row
changes, and the strict comparison is not relaxed: two equalities are stricter
than the inequality they replace.
Absolute counts also make a residual occurrence self-diagnosing, which the
inequality could not be. A non-zero cold count is a real extra read in the
commit; a warm count other than 1 is a fixture that was not armed. The old rows
printed the same `0 0` for both.
This does not claim the failure rate drops to zero. No mechanism able to move
both old counters was identified, and that evidence is obtainable neither
locally, where the rate is 0.1 % and does not reproduce under identical
settings, nor from CI, where the test printed only booleans. The claim is that
the oracle no longer depends on quantities the rest of the mutation moves.
Validation: the rewritten test fails on a build with the two
`areColumnAndSecondaryIndexSizesCalculated` guards removed, where the cold count
becomes 1 and only that row moves, and passes with them present; a warm arm
switched to lazy sizes reports 0, so the control can still fail; 220 randomized
runs at 8-way concurrency are green.
Co-Authored-By: Claude Opus 5 <[email protected]>
`PackedSkipIndicesArchiveIndexLoads` is incremented at two sites, but the test reached only one of them: both of its tables pin `min_bytes_for_full_part_storage` to 1 GB and the `packed` row asserts `Packed` part storage, so every count went through the packed override and deleting the increment from `DataPartStorageOnDiskBase::getSkipIndicesPackedReader` left the whole test green. Two arms on `Full` part storage close that. Measured on the fixture: with the skip indices bundled (`packed_skip_index_max_bytes = '1M'`) the part is `Full` with 17 files and the mutation's clone opens the standalone archive index exactly once; with packing disabled the same two minmax indices are written standalone (103 index bytes either way, 20 files) and the count is 0. The 0 therefore means "no archive to load", not "no indices" and not "the part was never probed", and the mutation is asserted to have taken the untouched-part shortcut on both arms so that neither `= 0` row can pass on an empty set. Deleting the base-class increment now reddens `full_one_archive_load`, and only that row. The event description promised the read happens "at most once" per part storage. It does not: the packed override releases `skip_indices_packed_mutex` after its memo check and reacquires it only after the read, so concurrent first accesses can each read, which is the window `04401_packed_skip_indices_concurrent_read_long.sh` engineers across 50 unprobed parts, and a probe that finds the archive relocated is deliberately not memoized. The description now says attempted reads and keeps no bound the code does not hold, and the test derives its exact 1 from its own single-threaded fixture instead of from that bound. The file header also records why the object-storage policy is kept, since the counter itself is disk-independent. Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review (1 fix round; 4 findings agreed and fixed, re-review clean)Two independent passes over this diff, my own cold read and a second-model gate, then one fix round ❌ The test did not protect the second instrumented site. Both original arms pin
💡 Also addressed: the Session id: cron:clickhouse-review-slot-8:20260905-085900 |
|
Workflow [PR], commit [4868397] Summary: ❌
AI ReviewSummaryPR #118234 adds Final Verdict✅ Approve. No required changes. |
|
cc @Algunenano @tiandiwonder, could you review this? |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units9 translation units recompiled, 27 s compile time in total, 9 of them have a recent master baseline. |
A synchronous mutation is reported done as soon as its result part becomes visible: getIncompleteMutationsStatus derives is_done from the visible parts' data versions, which needs only a shared parts lock, and the commit that publishes the part runs before MutatePlainMergeTreeTask writes its MutatePart row. mutations_sync therefore does not imply that row is queued, so a SYSTEM FLUSH LOGS issued straight after the ALTER can miss it. Measured, not argued: with a 5 s delay injected between the commit and the part log write, the test reproduced the amd_debug flaky-check failure byte for byte. full_rows and full_untouched flip to 0 while every counter row stays green, because maxIf over the empty group lets full_no_archive_zero_load pass on a missing row. The row itself was correct, only late: written 5.01 s after its MutatePartStart, after the test had already flushed and read the log. The four tables are therefore dropped before the part log is read. Dropping a table waits for that table's background tasks, so afterwards every MutatePart row is queued and one flush observes all of them. On the same delay-injected build the restructured test is green and byte identical over three runs, and both mutation arms still redden exactly one row each. Also assert the size-accounting precondition per table rather than as an aggregate over both packed tables. Reading system.data_skipping_indices calls getSecondaryIndexSizes for every table it lists, so both tables are armed either way; the aggregate assertion, however, cannot distinguish one armed table from two. On a fixture where one of the two reports zero index bytes the old form prints 1 and the per-table form prints 0.
|
The test now reads the part log after dropping the tables, which waits for those tables' background tasks. On the same delay-injected build it is green and byte identical over three runs; both mutation arms still redden exactly one row each, and 200/200 randomized runs pass. |
CI finish ledger - 06a7c5eEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose
Praktika tree on this head: 172 nodes, 147 OK / 22 SKIPPED / 0 DROPPED, so the skips are digest
Session id: cron:our-pr-ci-monitor:20260906-000110 |
…e-index-load-profile-event # Conflicts: # src/Storages/MergeTree/DataPartStorageOnDiskPacked.cpp
CI finish ledger - 4868397Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20261022-193007 |
Algunenano
left a comment
There was a problem hiding this comment.
@groeneai Please avoid adding profile events for tests unless they are really necessary. New profile events add extra memory to be set and used in each and every query. Prefer simplifying the tests or, if they don't provide anything useful, drop them
|
Agreed, the event is not needed. The flakiness it was meant to remove is already fixed on master by #129938, which pins |
Related: #112691
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added the
PackedSkipIndicesArchiveIndexLoadsProfileEvent, which counts attempted reads of the index of a part's packed skip-indices archive.Description
04653_packed_part_size_accounting_no_read_in_commit(added by #112691) reddens unrelated PRs and master: 37 failures in 60 days, on 24 PRs and 3 master runs.Both rows compared incidental I/O aggregates whose whole margin between the arms is one
disk->readFile: the warm control resolves the archive index once while computing the cloned part's sizes at load, and the cold arm keeps them lazy, so the oracle wasbaseline < baseline + 1and any one-unit perturbation flipped it. Since mid-September every failure is theFileOpenrow alone, with the random MergeTree settinguse_primary_key_cache = 1: in those jobs' part logs the cold arm loads the primary index (one moreFileOpen) while the warm arm hits the cache. Pinning that setting hides this perturbation, not the next.This adds
PackedSkipIndicesArchiveIndexLoads, incremented once per attempted archive-index load at both sites performing one (DataPartStorageOnDiskPacked::getSkipIndicesPackedReaderand theDataPartStorageOnDiskBaseone used onFullstorage), and rewrites the two rows as absolute counts: 0 cold, exactly 1 for the control. Two further arms cover the second site: one load with the archive bundled, zero without. Seeding paths install an index without reading it and do not count, which makes 0 meaningful.The part log is read only after the tables are dropped, because
mutations_syncdoes not imply theMutatePartrow is queued: a mutation is reported done once its result part is visible, while dropping a table waits for its background tasks. The size precondition is asserted per table.Validation: counts 0/1 and 1/0, identical 3/3; reverting the #112691 guards reddens the cold row alone; deleting the base-class increment reddens the
Fullrow alone; a lazy warm arm reads 0, so the control can fail; 200/200 randomized runs green.A residual occurrence now names its side:
cold != 0is a real extra read,warm != 1an unarmed fixture.Workflow [PR]
Sync PR [sync-upstream/pr/118234]