Skip to content

Leave only loadable objects behind in 05316_named_collection_dictionary_override_access - #124075

Merged
antonio2368 merged 5 commits into
ClickHouse:masterfrom
groeneai:fix-05316-dictionary-override-leftovers
Oct 6, 2026
Merged

antonio2368 merged 5 commits into
ClickHouse:masterfrom
groeneai:fix-05316-dictionary-override-leftovers

Conversation

@groeneai

@groeneai groeneai commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

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

After this test ran, the Stress test could not restart the server: Stress test (amd_msan), Load job 'load table test_1.dict_override' failed: Code: 36 ... Override not allowed for 'table'.

The test locked table of its collection with ALTER NAMED COLLECTION ... NOT OVERRIDABLE while two stored dictionaries overrode it, and never unlocked it. Since #123133 the lock is checked on every load, so those dictionaries could only be dropped. Stress keeps test databases across its restart, ignores DROP DICTIONARY with ignore_drop_queries_probability = 0.2, and its server-side AST fuzzer leaves __fuzz_N clones that the cleanup never drops. The table part has the same window when a client is killed between a lock and its unlock.

The server behaviour is intended and unchanged. Only the test changes, and it keeps every assertion:

  • the dictionary lock check uses a separate collection created NOT OVERRIDABLE, which no stored dictionary overrides;
  • each table is detached PERMANENTLY before its key is locked and attached again only after the key is unlocked, like 04512_remote_missing_named_collection;
  • the client that creates the tables sets ast_fuzzer_any_query = 0.
Validation

On a local server with the Stress settings (ast_fuzzer_runs = 5, ast_fuzzer_any_query = 1, async_load_databases = false), the test was run in a kept database and the server was restarted:

  • every cleanup DROP ignored: before, the restart fails with the CI error on dict_override; after, it starts and the leftover dictionaries load.
  • sweeps of 24-210 runs with ignore_drop_queries_probability = 0.2, killing at most one client per run: before, 3 of 5 restarts fail (on a fuzzer clone dict_alias__fuzz_N, or on table_settings_override when the kill lands in the table part); after, all 3 restarts succeed (264 runs, every client call of the test killed in at least one run).
  • fuzzed variants of the two CREATE TABLE statements: 60 from 12 executions before, 0 from 35 after.

With the normal runner: 50 randomized parallel runs pass, the neighbouring named collection tests pass, and the test fails if either lock is removed.


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

Version info

  • Merged into: 26.10.1.1634-master (included in 26.10 and later)
  • Backported to: 26.9.22.5, 26.8.31.5, 26.7.37.11, 26.3.57.3

…ry_override_access

The test locked `table` of its collection with `ALTER NAMED COLLECTION ...
NOT OVERRIDABLE` while the stored dictionaries `dict_override` and
`dict_alias` override that key, and never unlocked it. The lock is checked
on every dictionary load since ClickHouse#123133, so from that point those
dictionaries can only be dropped. The Stress test keeps test databases
across its final restart, ignores `DROP DICTIONARY` with
`ignore_drop_queries_probability = 0.2`, and its server-side AST fuzzer
clones every successful CREATE to `<name>__fuzz_N`, which the cleanup never
drops. Either way the restart with `async_load_databases = false` refused
the dictionary (Code 36 "Override not allowed for 'table'") and the whole
Stress job was lost. The table part had the same window: a client killed
between a lock and its unlock left a table attached, or detached
non-permanently, with its key locked.

The server behaviour is intended and unchanged; the test now never stores
an object that overrides a locked key:
- the dictionary lock check runs against a separate collection created
  NOT OVERRIDABLE, which no stored dictionary overrides;
- each table is detached PERMANENTLY before its key is locked and attached
  again only after the key is unlocked (startup skips a permanently
  detached table, and the flag survives the rejected ATTACH), as in
  04512_remote_missing_named_collection;
- the client that creates the tables sets `ast_fuzzer_any_query = 0`, so
  the fuzzer makes no clone of them.

Every assertion and the reference are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding labels Oct 5, 2026
@groeneai

groeneai commented Oct 5, 2026

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 a separate cold review of the diff (0 blocking findings).

# Sev Finding Verdict Evidence / action
1 💡 The dictionary lock check now gets its lock from CREATE NAMED COLLECTION ... NOT OVERRIDABLE instead of ALTER noted, no change Both set the same per-key lock (NamedCollectionsHelpers.cpp, checkOverrideLockAndFindStoredKey). The table part still asserts locks added by ALTER, and 05317 uses the same pre-locked collection pattern.

Severity: ❌ blocker / ⚠️ major / 💡 nit.

Session id: cron:clickhouse-review-slot-9:20261005-175500

@groeneai

groeneai commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. On a server with the Stress settings, run the test in a kept database with every DROP ignored, then restart: the restart fails on dict_override with the CI error (Code: 36 Override not allowed for 'table'). Both table windows (attached or non-permanently detached table with its key locked) also fail the restart every time.
b Root cause explained? The test locked a key that two stored dictionaries override and never unlocked it. The lock is checked on every load, and Stress keeps the database, ignores DROP DICTIONARY with probability 0.2 and leaves fuzzer clones, so the restart meets an object it must refuse. Killed clients leave the same state in the table part.
c Fix matches root cause? Yes. The test no longer stores an object that overrides a locked key: a separate pre-locked collection for the dictionary check, and tables permanently detached while their key is locked. No tag, no muting, server unchanged.
d Test intent preserved / new tests added? Yes. Every assertion and the .reference are unchanged; removing either lock makes the test fail.
e Both directions demonstrated? Yes. Ignored drops: restart fails before, starts after. Kill sweeps: 3 of 5 restarts fail before, 3 of 3 start after (264 runs, every client call killed at least once). Fuzzer clones of the table CREATEs: 60 before, 0 after.
f Fix is general across code paths? Yes. Every object the test creates was checked; the dict_load detach window and the sibling tests that lock keys store nothing that overrides a locked key.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only fix). Both table engines and both dictionary override forms stay covered.
h Backward compatible? (maintainer-approved exception only) N/A: test-only, no settings or formats.
i Invariants and contracts preserved? Yes. At every point of the test, every object it or the fuzzer leaves is loadable or permanently detached.

Session id: cron:clickhouse-impl-slot-41:20261005-163100

@clickhouse-gh

clickhouse-gh Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ee3e336]

Summary: ✅


AI Review

Summary

This PR hardens tests/queries/0_stateless/05316_named_collection_dictionary_override_access.sh so the test no longer leaves restart-unloadable named-collection users behind under the Stress profile: the negative dictionary case now uses a separate pre-locked collection, the table attach check keeps tables DETACHed PERMANENTLY only while the key is locked, and cleanup now restores any leftover detached tables before dropping objects with both ast_fuzzer_any_query = 0 and ignore_drop_queries_probability = 0. I do not see any remaining correctness issues in the current diff.

Missing context / blind spots
  • ⚠️ I did not rerun the stateless test locally because this checkout has no usable local build* directory or clickhouse test binary; validation here is static plus the current PR discussion/code. The broader CI matrix was still pending on 2026-10-06.
Final Verdict

✅ No new findings. The current version addresses the previously reported cleanup nondeterminism and unloadable-leftover states.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 5, 2026
@groeneai
groeneai requested a review from antonio2368 October 5, 2026 18:43
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 5, 2026
Each attach_is_rejected() call opens fresh client sessions, so the
SET ast_fuzzer_any_query = 0 of the table-creation block did not reach
its DETACH ... PERMANENTLY, the rejected ATTACH or the final unlock and
ATTACH, and under the Stress profile those statements were still fuzzed.
Pin the setting in all three invocations, as the table-creation block
and 04318/04320/04626 do, so that the test's guarantee (no stored table
is attached while its key is locked) does not depend on which mutations
the fuzzer applies to table DDL.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@antonio2368 antonio2368 self-assigned this Oct 5, 2026
…ping it

A client killed between `DETACH TABLE ... PERMANENTLY` and the re-`ATTACH` in
`attach_is_rejected` left the table detached permanently. `DROP TABLE IF EXISTS`
does not see such a table and the name stays reserved, so every later run of the
test in the same database (as in the stress test) failed at `CREATE TABLE` with
`TABLE_ALREADY_EXISTS (detached permanently)`. The cleanup also dropped the named
collection, after which the table could not be attached at all.

The cleanup now makes the keys overridable again and attaches such a table before
the drops, with the AST fuzzer off for those statements.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Under the Stress profile an ignored DROP TABLE of the URL table succeeds
without dropping it, and the fuzzer then replays it as a non-permanent
DETACH. A detached table registers no named-collection dependency, so the
following DROP NAMED COLLECTION succeeds, and the next restart cannot load
the table (NAMED_COLLECTION_DOESNT_EXIST).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The stress runner sets `ignore_drop_queries_probability = 0.2`. In the cleanup it ignores
`DROP DICTIONARY` and the `DROP TABLE` of the URL table, so the named collection drops after
them fail with `NAMED_COLLECTION_IS_USED`, and it rewrites the `DROP TABLE` of the MySQL table
into a `TRUNCATE` that `StorageMySQL` does not implement. Pin it to 0 in the cleanup's drop
session, as 04920, 04401 and 05054 do.

Measured on a server with the Stress settings, 30 runs per arm: before, 5 ignored drops, 10
rewrites to `TRUNCATE` (2 failed with `NOT_IMPLEMENTED`) and 6 `NAMED_COLLECTION_IS_USED`;
after, none, and all 822 cleanup drops ran with the probability at 0. The restart is READY on
both arms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@antonio2368
antonio2368 added this pull request to the merge queue Oct 6, 2026
Merged via the queue into ClickHouse:master with commit cf63c91 Oct 6, 2026
149 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 6, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Could this PR get pr-must-backport, like #123133? The backports of #123133 (#125983, #125982, #125986 merged, #125981 still open) brought 05316_named_collection_dictionary_override_access to 26.9, 26.8 and 26.3 in its pre-fix form, which still locks the key that dict_override overrides, so a leftover copy of that dictionary blocks the server restart. On 26.9 this already happened: Stress test (arm_asan_ubsan), Code: 36 ... Override not allowed for 'table': Cannot attach table test_7.dict_override__fuzz_4.

The test file on 26.9, 26.8 and 26.3 is identical to master's version right before this PR (blob 2039d59f), so the cherry-picks should be clean. 26.10 already has the fix; on 26.7 it applies once #125981 merges.

@robot-clickhouse robot-clickhouse added pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR labels Oct 19, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 19, 2026
Backport #124075 to 26.8: Leave only loadable objects behind in `05316_named_collection_dictionary_override_access`
clickhouse-gh Bot added a commit that referenced this pull request Oct 19, 2026
Backport #124075 to 26.9: Leave only loadable objects behind in `05316_named_collection_dictionary_override_access`
PedroTadim added a commit that referenced this pull request Oct 19, 2026
Backport #124075 to 26.3: Leave only loadable objects behind in `05316_named_collection_dictionary_override_access`
strtgbb pushed a commit to Altinity/ClickHouse that referenced this pull request Oct 21, 2026
…d in `05316_named_collection_dictionary_override_access`
antonio2368 added a commit that referenced this pull request Oct 22, 2026
Backport #124075 to 26.7: Leave only loadable objects behind in `05316_named_collection_dictionary_override_access`
@clickhouse-gh clickhouse-gh Bot added comp-config Server configuration infrastructure: XML/YAML config parsing, preprocessor (includes, substitutio... 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-config Server configuration infrastructure: XML/YAML config parsing, preprocessor (includes, substitutio... groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-ci pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.3-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants