Skip to content

Add test: alterRefreshParams empty-database dependency resolution untested for temp-table-shadowed DEPENDS ON - #108037

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr107156
Jun 21, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr107156

Conversation

@clickgapai

@clickgapai clickgapai commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

Found via ClickGap automated review. Please close or comment if this is incorrect or needs adjustment.

This is a test-only PR — no source code changes. Please review: test quality, whether the claimed coverage gaps are real, and whether test output makes sense.

Adds test coverage for 1 untested code path(s), found during automated review of PR #107156.
That PR The PR fixes a server abort/crash-loop in refreshable materialized views: a REFRESH ... DEPENDS ON <name> whose unqualified name is shadowed by a temporary table or CTE is left with an empty database by AddDefaultDatabaseVisitor, so StorageID::getFullTableName throws UNKNOWN_DATABASE during

1. alterRefreshParams empty-database dependency resolution untested for temp-table-shadowed DEPENDS ON
src/Storages/MaterializedView/RefreshTask.cpp:402
Risk: InterpreterAlterQuery.cpp:475 runs AddDefaultDatabaseVisitor over MODIFY REFRESH; with t shadowed by a temporary table the dependency stays unqualified and arrives at alterRefreshParams (RefreshTask.cpp:402-403) with empty database. Without resolution against view->getStorageID().database_name, StorageID::getFullTableName throws UNKNOWN_DATABASE on the first scheduling pass, re-raised as LOGICAL_ERROR (server abort in debug/sanitizer builds, persisted bad definition causing …
What's unique vs PR tests: The PR's test 04329 covers only the create call site (CREATE MATERIALIZED VIEW ... DEPENDS ON t plus detach/attach). This test covers the second, independently-wired alterRefreshParams call site (RefreshTask.cpp:402-403) via ALTER ... MODIFY REFRESH ... DEPENDS ON with a temp-table shadow — a distinct mutation guard (the alter call site's default_database argument) that the create test does not protect.

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

Not applicable — test-only change.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.6.1.1083

@clickgapai

Copy link
Copy Markdown
Contributor Author

Pre-PR Validation Gate (per ClickGap pipeline):

a) Deterministic repro? ✅
Test exercises the previously-uncovered branch and passes (correct behaviour).

b) Root cause explained? ✅
src/Storages/MaterializedView/RefreshTask.cpp:402-403: std::vector<StorageID> deps = parseRefreshDependencies(new_strategy, view ? view->getStorageID().database_name : String{}); — the alter call site's empty-database resolution is correct but untested.

c) Fix matches root cause? ✅
N/A for coverage gap — this PR adds a regression test, not a fix. Asserts current correct behaviour at the cited line.

d) Test intent preserved? / New tests added? ✅
New regression test added: 04401_refreshable_mv_alter_depends_on_temp_shadow.sh.

e) Both directions demonstrated? ✅
Test passes (MATCH) on master proving current correctness; would fail if the cited branch regressed. Single-direction is the correct shape for a coverage gap test.

f) Fix is general, not a narrow patch? ✅
Test asserts the invariant at the cited line — covers the branch, not a specific input shape.

@groeneai

Copy link
Copy Markdown
Collaborator

Reviewed by source inspection and comparison against the merged #107156 test 04329_refreshable_mv_depends_on_database_qualification.sh (not run locally; see the branch note below). Verdict: LGTM, useful and non-redundant.

  • Coverage gap is real. alterRefreshParams (RefreshTask.cpp:402-403) is wired independently of create and on master passes view->getStorageID().database_name into parseRefreshDependencies, so it is the second, distinct guard Fix crash on REFRESH ... DEPENDS ON shadowed by a temporary table #107156 added. 04329 only covers the create call site plus the detach/attach (attach-from-metadata) path; it never issues ALTER ... MODIFY REFRESH, so the alter site was untested. Not redundant.
  • The test targets it correctly: the MV is created without DEPENDS ON, then ALTER ... MODIFY REFRESH ... DEPENDS ON t with t shadowed by a session TEMPORARY table is the only path routing a bare temp-shadowed name into alterRefreshParams. Clean isolation.
  • Assertion is meaningful and matches the proven 04329 shape: poll out of Scheduling, then MissingDependencies + empty exception, plus a server-alive check. Without the fix it settles Disabled with a non-empty exception in non-sanitizer builds and aborts in debug/sanitizer, so the assertion catches the regression.
  • Parallel-safe: unique ${CLICKHOUSE_DATABASE}_mv, session-scoped temp table, no no-parallel. Good.

Branch note: qa-bot/coverage-pr107156 is forked from a base predating the #107156 merge (today 16:03 UTC), so it does not contain the fix (parseRefreshDependencies) or 04329. GitHub CI tests the merge with master, so the check will be green there. But on the current branch base the fix is absent and the test fails by design, so any pipeline that runs it directly on the branch tree will report a failure. Rebasing onto current master fixes that and keeps the diff minimal.

On the can be tested label: I cannot apply it. Fork contributors do not have write access to ClickHouse/ClickHouse, so a maintainer needs to add it.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jun 20, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [8f26c23]

Summary: ✅


AI Review

Summary

This test-only PR adds focused stateless coverage for ALTER TABLE ... MODIFY REFRESH ... DEPENDS ON when an unqualified dependency is shadowed by a temporary table. The current version keeps the pre-ALTER view from running before the mutation under test, so it now exercises the intended alterRefreshParams path without the race identified in the prior inline thread.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jun 20, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.30% 85.30% +0.00%
Functions 92.50% 92.50% +0.00%
Branches 77.50% 77.50% +0.00%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 378 line(s), 53 function(s) across 128 file(s) · Details

Top files
  • src/Storages/StorageReplicatedMergeTree.cpp: 24 line(s)
  • src/Processors/Formats/Impl/Parquet/Decoding.cpp: 20 line(s)
  • src/AggregateFunctions/AggregateFunctionIntervalLengthSum.cpp: 18 line(s), 40 function(s)
  • src/IO/S3/copyS3File.cpp: 10 line(s)
  • src/Interpreters/HashJoin/HashJoin.cpp: 10 line(s)

Full report

@alexey-milovidov alexey-milovidov self-assigned this Jun 21, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jun 21, 2026
Merged via the queue into ClickHouse:master with commit b3caf77 Jun 21, 2026
166 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 21, 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 pr-not-for-changelog This PR should not be mentioned in the changelog 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.

4 participants