Skip to content

Fix flaky test 05137_lazy_load_tables_replace_proxy_after_load - #131220

Merged
murphy-4o merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-flaky-05137-lazy-load-replace-proxy
Nov 13, 2026
Merged

murphy-4o merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-flaky-05137-lazy-load-replace-proxy

Conversation

@groeneai

@groeneai groeneai commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #118699
Related: #131099

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

Not required.

Description

05137_lazy_load_tables_replace_proxy_after_load fails in parallel jobs with total_bytes_uncompressed 0 instead of 1 (master: amd_debug, amd_tsan; 12 of ~3800 runs since #118699 merged, always this one diff).

#118699 replaces a loaded StorageTableProxy with the table only if nobody else holds the proxy (DatabaseCatalog::replaceUnusedTableInUUIDMapping needs use_count() == 2), and retries on the next lookup otherwise. The proxy does not forward totalBytesUncompressed, so this line asserts that the replacement has already happened. A concurrent system.columns scan holds every table until it finishes (00941_system_columns_race_condition and 00938_fix_rwlock_segfault_long were running in the two master failures), so the replacement is deferred and the proxy answers NULL.

This PR removes that one assertion. No other line of the test depends on the replacement, and 05616_lazy_load_tables_replace_proxy_held already checks the replacement itself, waiting for the holders to go away. Reverting #118699 would also stop the failure, but the server behaves as that PR documents; only this assertion assumed otherwise.

Validation (debug build, 8 concurrent system.columns loops like 00941): the old test fails 13/50 with exactly this diff, the new one passes 50/50; without the load 50/50, and 50/50 with -j 8.


Workflow [PR]
Sync PR [sync-upstream/pr/131220]

Version info

  • Merged into: 26.11.1.2189-master (included in 26.11 and later)

ClickHouse#118699 replaces a loaded `StorageTableProxy` with the loaded storage only
when nobody else holds the proxy (`replaceUnusedTableInUUIDMapping` requires
`use_count() == 2`); otherwise the next lookup tries again. The proxy does
not forward `totalBytesUncompressed`, so `total_bytes_uncompressed IS NOT NULL`
was a witness that the replacement had already happened. A concurrent
catalog-wide `system.columns` scan holds a `StoragePtr` to every table for its
whole lifetime, so when one covers the lookups after the load (00941 and 00938
on master f538dd0 / c19b253) the replacement is deferred and the column is
NULL. Every other line passes either way. Remove the assertion;
05616_lazy_load_tables_replace_proxy_held checks the replacement with a wait.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review of the same head (0 blocker, 0 major).

# Sev Finding Verdict Evidence / action
1 💡 After the deletion, 05137 no longer checks that the proxy is replaced; its remaining lines pass with either the proxy or the loaded table AGREE, noted, not blocking The replacement stays covered by 05616_lazy_load_tables_replace_proxy_held, which waits up to 60 s for the holders to go away. CIDB since #118699: all 12 failures of 05137 show only the removed line in the diff.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-8:20261113-081800

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. A sleeping system.columns query over the test database (started after ATTACH DATABASE) holds the proxy; after SELECT count() loads the table, system.tables returns engine MergeTree, total_bytes_uncompressed IS NOT NULL = 0 while it runs and 1 after KILL QUERY, 5/5. The "Replaced the proxy" log line appears only after the kill.
b Root cause explained? #118699 replaces the loaded proxy only when use_count() == 2 (DatabaseCatalog::replaceUnusedTableInUUIDMapping); the proxy does not forward totalBytesUncompressed, so the line asserts that the replacement already happened. A concurrent catalog-wide system.columns scan (00941, 00938 on master) holds every table, so the replacement is deferred and the column is NULL.
c Fix matches root cause? Yes. The assertion encodes a guarantee the server does not give (the replacement is best-effort); it is removed, nothing else changes. No tag, bound or setting pin.
d Test intent preserved / new tests added? Yes. Every other line still checks the same thing through the proxy or the loaded table; the replacement itself stays covered by 05616_lazy_load_tables_replace_proxy_held, which waits for holders. Test-only change, no new test.
e Both directions demonstrated? Yes. With 8 concurrent system.columns loops: old test 13/50 FAIL (always this one diff), new test 50/50 OK.
f Fix is general across code paths? N/A (test-only). The only other test using this witness is 05616, which already waits.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only). Randomized settings ON for all runs; also 50/50 without load and 50/50 with -j 8.
h Backward compatible? (maintainer-approved exception only) Yes. No setting, format or source change.
i Invariants and contracts preserved? Yes. No product code touched; the test's statement and reference order are unchanged apart from the removed line.

Session id: cron:clickhouse-impl-slot-7:20261113-075500

@clickhouse-gh

clickhouse-gh Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9ec8506]

Summary: ✅


AI Review

Summary

Reviewed #131220 at 9ec850624fc74f40358c095fc261463f2ca4a260, including all prior discussion. The change removes an invalid immediate-replacement assertion from 05137_lazy_load_tables_replace_proxy_after_load: concurrent system.columns scans can retain the loaded StorageTableProxy, deferring replacement and leaving total_bytes_uncompressed null. The linked master failure matches this assertion. Eventual replacement remains covered by 05616_lazy_load_tables_replace_proxy_held, which checks the held and released states. The author's reported concurrent-scan reproduction supplies before/after evidence; no local tests were run.

Final Verdict

✅ Approve. No actionable findings; no inline comments posted.

@clickhouse-gh clickhouse-gh Bot added pr-ci can be tested Allows running workflows for external contributors comp-testing Test content only (no production code). labels Nov 13, 2026
@murphy-4o
murphy-4o enabled auto-merge November 13, 2026 09:39
@murphy-4o
murphy-4o added this pull request to the merge queue Nov 13, 2026
Merged via the queue into ClickHouse:master with commit 73d8c69 Nov 13, 2026
606 of 608 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 13, 2026
@clickhouse-gh clickhouse-gh Bot added comp-database-engines Database engine implementations (e.g., Atomic/Replicated) and database-level behavior. and removed comp-testing Test content only (no production code). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-database-engines Database engine implementations (e.g., Atomic/Replicated) and database-level behavior. pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants