Skip to content

Remove duplicate MergeTree settings from system.completions - #102015

Merged
alexey-milovidov merged 5 commits into
ClickHouse:masterfrom
groeneai:fix/system-completions-duplicate-mergetree-settings
May 19, 2026
Merged

alexey-milovidov merged 5 commits into
ClickHouse:masterfrom
groeneai:fix/system-completions-duplicate-mergetree-settings

Conversation

@groeneai

@groeneai groeneai commented Apr 8, 2026 •

Copy link
Copy Markdown
Collaborator

fillDataWithMergeTreeSettings() in StorageSystemCompletions.cpp was calling
dumpToSystemCompletionsColumns() for both getMergeTreeSettings() and
getReplicatedMergeTreeSettings(). Both return the same MergeTreeSettings
type with identical setting names — they only differ in values (replicated
adds overrides from the replicated_merge_tree config section). Since
completions only need the names for autocomplete, this produced 329 duplicate
rows.

The fix removes the redundant getReplicatedMergeTreeSettings() call and adds
a regression test that asserts no MergeTree setting appears more than once.

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry:

Fixed duplicate rows in system.completions for MergeTree settings — each
setting name appeared twice because both getMergeTreeSettings() and
getReplicatedMergeTreeSettings() were dumped despite having identical
setting names. Closes #102013.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.5.1.796

fillDataWithMergeTreeSettings() was calling dumpToSystemCompletionsColumns()
for both getMergeTreeSettings() and getReplicatedMergeTreeSettings(). Both
return the same MergeTreeSettings type with identical setting names (they
only differ in values), so this produced 329 duplicate rows. Remove the
redundant getReplicatedMergeTreeSettings() call since completions only
need the names.

Closes ClickHouse#102013
@groeneai

groeneai commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator Author

Pre-PR Validation (session cron:clickhouse-ci-task-worker:20260408-024500)

(a) Deterministic repro? Yes — clickhouse-local -q "SELECT word, count() AS cnt FROM system.completions WHERE context = 'merge tree setting' GROUP BY word HAVING cnt > 1" returns 329 rows on unpatched binary, 0 on patched.

(b) Root cause explained? fillDataWithMergeTreeSettings() calls dumpToSystemCompletionsColumns() on both context->getMergeTreeSettings() and context->getReplicatedMergeTreeSettings(). Both return MergeTreeSettings (same type) with identical setting names — they differ only in values (replicated additionally loads from the replicated_merge_tree section). Since completions only dump names, every setting is emitted twice.

(c) Fix matches root cause? Yes — removed the getReplicatedMergeTreeSettings() call entirely, since it contributes no new names.

(d) Test intent preserved / New test added? New test 04084_system_completions_no_duplicates asserts no MergeTree setting appears more than once in system.completions.

(e) Both directions demonstrated? Unpatched binary: 329 duplicates. Patched binary: 0 duplicates. Test passes 5/5 runs.

(f) Fix is general? This is the only call site that dumps MergeTree settings into completions. No other system table has this pattern.

@groeneai

groeneai commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator Author

cc @alexey-milovidov @azat — could you review this? It removes the duplicate MergeTree settings from system.completions by dropping the redundant getReplicatedMergeTreeSettings() dump (same type, same names as getMergeTreeSettings()).

-- Previously, both getMergeTreeSettings() and getReplicatedMergeTreeSettings()
-- were dumped, producing identical rows since they share the same setting names.

SELECT word, count() AS cnt

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, check that at least one ReplicatedMergeTree-specific setting is present.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Apr 8, 2026
@alexey-milovidov alexey-milovidov self-assigned this Apr 8, 2026
@clickhouse-gh

clickhouse-gh Bot commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f279d90]

Summary: ✅


AI Review

Summary

This PR removes a duplicate insertion path in fillDataWithMergeTreeSettings so system.completions no longer emits each MergeTreeSettings name twice, and adds a focused regression test that checks both “no duplicates” and presence of replicated_-prefixed settings. The current patch matches the stated bug and includes sufficient regression coverage for the changed behavior.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Apr 8, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

The flaky test failures in this PR (01605_drop_settings_profile_while_assigned, 01418_custom_settings, 02015_async_inserts_4) are caused by non-unique access entity names and will be resolved by #102131.

fm4v added a commit that referenced this pull request Apr 14, 2026
Split flaky check and targeted check into separate roles:

Flaky check — runs only new/modified tests from the PR with thread
fuzzer enabled. Tests run in parallel with themselves (shared queue)
to ensure new tests are parallel-safe under randomized thread ordering.

Targeted check — runs previously failed and coverage-relevant tests
with per-worker partitioning (--no-self-parallel) so the same test
never runs concurrently on multiple workers, avoiding conflicts on
shared resources (hardcoded users, roles, settings profiles, etc.).
Both use --test-runs 50.

Changes:
- Add --no-self-parallel flag to clickhouse-test: partitions tests
  by name hash so all copies go to the same worker
- Flaky check: only changed tests, thread fuzzer, shared queue
- Targeted check: relevant tests, no thread fuzzer, per-worker queues,
  50 runs, single clickhouse-test invocation
- Restore original thread fuzzer parameters (reverts reductions from
  06c945a and 9790435)
- Add amd_binary to flaky check, use AMD_LARGE for targeted debug
- Targeted check uses --flaky-check --no-self-parallel

PRs affected by tests running in parallel with themselves:
#102015 #101093 #99653 #101503 #101108 #101884 #100746
#101447 #100941 #101099 #100203 #96130

#102038
fm4v added a commit that referenced this pull request Apr 14, 2026
Split flaky check and targeted check into separate roles:

Flaky check — runs only new/modified tests from the PR with thread
fuzzer enabled. Tests can run in parallel with themselves (shared
queue) to ensure new tests are parallel-safe.

Targeted check — runs previously failed and coverage-relevant tests
with per-worker partitioning (--no-self-parallel) so the same test
never runs concurrently on multiple workers, avoiding conflicts on
shared resources (hardcoded users, roles, settings profiles, etc.).
Both use --test-runs 50.

Changes:
- Add --no-self-parallel flag to clickhouse-test: partitions tests
  by name hash so all copies go to the same worker
- Flaky check: only changed tests, thread fuzzer, shared queue
- Targeted check: relevant tests, no thread fuzzer, per-worker
  partitioning, 50 runs, single clickhouse-test invocation
- Restore original thread fuzzer parameters
- Change targeted check to arm_asan_ubsan on ARM_LARGE

PRs affected by tests running in parallel with themselves:
#102015 #101093 #99653 #101503 #101108 #101884 #100746
#101447 #100941 #101099 #100203 #96130
@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai, please continue on this PR.

Address inline review by @alexey-milovidov on PR ClickHouse#102015: extend the
04084_system_completions_no_duplicates test with a sanity check that
at least one ReplicatedMergeTree-specific setting (e.g.
`replicated_can_become_leader`, `replicated_deduplication_window`)
is present in `system.completions` after the fix. These settings
live inside the `MergeTreeSettings` struct itself, so dropping the
redundant `getReplicatedMergeTreeSettings()` dump must NOT have
removed them. The new query guards against accidentally losing
replicated-specific names if the dump logic changes.

Verified locally: with the patched binary the test passes 5/5,
producing 0 duplicate rows for `merge tree setting` and a single
`1` for the replicated-presence check (17 unique `replicated_*`
settings remain after the fix).
@groeneai

Copy link
Copy Markdown
Collaborator Author

@alexey-milovidov done — pushed 6b0a849 extending 04084_system_completions_no_duplicates with the ReplicatedMergeTree-specific setting assertion you requested.

What the new check does:

SELECT count() > 0
FROM system.completions
WHERE context = 'merge tree setting'
  AND startsWith(word, 'replicated_');

This guards against accidentally losing replicated-specific names if the dump logic changes. The settings (e.g. replicated_can_become_leader, replicated_deduplication_window) live inside the MergeTreeSettings struct itself, so removing the redundant getReplicatedMergeTreeSettings() dump correctly preserves them.

Local verification (Debug build, clang-21, master + this PR's source change applied):

  • Before fix: system.completions has 662 merge tree setting rows (329 duplicates) and 34 replicated_* rows (each appearing twice).
  • After fix: 331 unique merge tree setting rows, 17 unique replicated_* rows. No duplicates. The replicated-presence check returns 1.
  • Test runs 5/5 OK via tests/clickhouse-test 04084_system_completions_no_duplicates --test-runs 5.

Session: cron:clickhouse-ci-task-worker:20260426-151500

@alexey-milovidov

Copy link
Copy Markdown
Member

This was fixed by #105146. Let's update the branch.

@clickhouse-gh

clickhouse-gh Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.10% +0.00%
Functions 91.40% 91.40% +0.00%
Branches 76.60% 76.60% +0.00%

Changed lines: 100.00% (2/2) · Uncovered code

Full report · Diff report

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue May 19, 2026
Merged via the queue into ClickHouse:master with commit e1df207 May 19, 2026
165 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label May 19, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
Split flaky check and targeted check into separate roles:

Flaky check — runs only new/modified tests from the PR with thread
fuzzer enabled. Tests run in parallel with themselves (shared queue)
to ensure new tests are parallel-safe under randomized thread ordering.

Targeted check — runs previously failed and coverage-relevant tests
with per-worker partitioning (--no-self-parallel) so the same test
never runs concurrently on multiple workers, avoiding conflicts on
shared resources (hardcoded users, roles, settings profiles, etc.).
Both use --test-runs 50.

Changes:
- Add --no-self-parallel flag to clickhouse-test: partitions tests
  by name hash so all copies go to the same worker
- Flaky check: only changed tests, thread fuzzer, shared queue
- Targeted check: relevant tests, no thread fuzzer, per-worker queues,
  50 runs, single clickhouse-test invocation
- Restore original thread fuzzer parameters (reverts reductions from
  06c945a and 9790435)
- Add amd_binary to flaky check, use AMD_LARGE for targeted debug
- Targeted check uses --flaky-check --no-self-parallel

PRs affected by tests running in parallel with themselves:
ClickHouse#102015 ClickHouse#101093 ClickHouse#99653 ClickHouse#101503 ClickHouse#101108 ClickHouse#101884 ClickHouse#100746
ClickHouse#101447 ClickHouse#100941 ClickHouse#101099 ClickHouse#100203 ClickHouse#96130

ClickHouse#102038
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 pr-bugfix Pull request with bugfix, not backported by default 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.

fillDataWithMergeTreeSettings produces duplicate rows by dumping both MergeTree and ReplicatedMergeTree settings

3 participants