Skip to content

Refuse incremental refresh into an unrecognised data lake target - #120233

Closed
asya-ch wants to merge 1 commit into
masterfrom
asya/refresh
Closed

asya-ch wants to merge 1 commit into
masterfrom
asya/refresh

Conversation

@asya-ch

@asya-ch asya-ch commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

RefreshTask reads the refresh cursor back from the Iceberg snapshot only when the target is a StorageObjectStorage. Under parallel_replicas_for_cluster_engines a data lake catalog table resolves to StorageObjectStorageCluster, which since #119214 can be written to. The sink commits the cursor with the data, but on resume the task does not recognise the target and falls back to the Keeper cursor. For an Atomic database there is none, so after a server restart the next refresh re-reads the source from the beginning and duplicates rows silently.

Fail closed: throw NOT_IMPLEMENTED instead of resuming from the wrong cursor.

Related: #119214

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

`RefreshTask` reads the refresh cursor back from the Iceberg snapshot only
when the target is a `StorageObjectStorage`. Under
`parallel_replicas_for_cluster_engines` a data lake catalog table resolves
to `StorageObjectStorageCluster`, which since
#119214 can be written to. The
sink commits the cursor with the data, but on resume the task does not
recognise the target and falls back to the Keeper cursor. For an Atomic
database there is none, so after a server restart the next refresh re-reads
the source from the beginning and duplicates rows silently.

Fail closed: if the target reports `isDataLake` but is not a storage the
task knows how to read the cursor from, throw `NOT_IMPLEMENTED` instead of
resuming from the wrong cursor.

Related: #119214

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2cb69b8]

Summary: ❌

job_name test_name status info comment
Build profile diff ERROR

AI Review

Summary

The PR tries to fail closed when an incremental refreshable MV resumes against a data-lake target whose cursor is committed with the data but cannot be read back through the current storage interface. That is the right area to harden, but the new guard is too broad: it now rejects supported Keeper-backed data-lake targets as well, and the PR does not add focused regression coverage for the parallel_replicas_for_cluster_engines resume path it is fixing. I would request changes.

Findings

❌ Blockers

  • [src/Storages/MaterializedView/RefreshTask.cpp:1339] The new else if (target_table->isDataLake()) branch does not only catch the unrecognized StorageObjectStorageCluster case from the PR description. It also catches plain StorageObjectStorage targets on non-transactional catalogs, even though StorageObjectStorage::isTransactionalRefreshTarget explicitly returns false there so refresh keeps using the Keeper cursor (src/Storages/ObjectStorage/StorageObjectStorage.cpp:484-488). Because RefreshTask still persists out_cursor to Keeper whenever cursor_persisted_by_target is false (src/Storages/MaterializedView/RefreshTask.cpp:1535-1539), this change turns an existing supported configuration such as an incremental MV targeting a Glue-backed Iceberg table into NOT_IMPLEMENTED on every refresh. Limit the rejection to targets that both persist the cursor with the data and lack a read-back path, instead of all isDataLake() storages.
Tests
  • ⚠️ Add a focused integration test for the exact path this PR is trying to protect: enable parallel_replicas_for_cluster_engines, refresh an incremental MV into a no-catalog Iceberg target, restart ClickHouse, then verify the second refresh does not re-read the source. tests/integration/test_storage_iceberg_no_spark/test_incremental_refreshable_mv_iceberg.py already covers the non-cluster exact-once path and looks like the right place to extend.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions: narrow the new NOT_IMPLEMENTED branch so Keeper-backed data-lake targets continue to work, and add a regression test that exercises the cluster-target resume path under parallel_replicas_for_cluster_engines.

LLVM Coverage Report

Measured on commit 2cb69b8.

Metric Baseline Current Δ
Lines 88.40% 88.40% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 80.50% 80.50% +0.00%

Changed lines: Changed C/C++ lines covered: 5/10 (50.00%) · Uncovered code

Full report · Diff report

@asya-ch
asya-ch requested a review from scanhex12 September 15, 2026 16:34
@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Sep 15, 2026
cursor_persisted_by_target = true;
stream_cursor = object_storage->loadRefreshCursor(refresh_context);
}
else if (target_table->isDataLake())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This isDataLake() branch is broader than the bug you describe. It also fires for the plain StorageObjectStorage path when the catalog is non-transactional: isTransactionalRefreshTarget() returns false there by design because those tables are supposed to keep using the Keeper cursor (src/Storages/ObjectStorage/StorageObjectStorage.cpp:484-488), and RefreshTask still persists out_cursor to Keeper whenever cursor_persisted_by_target stays false (src/Storages/MaterializedView/RefreshTask.cpp:1535-1539). With this change, an existing incremental MV like TO glue_db.tbl now throws NOT_IMPLEMENTED on every refresh instead of following that supported Keeper-backed path, so this is a backward-incompatible regression. The rejection needs to be limited to targets that commit the cursor with the data but cannot load it back (for example the cluster wrapper), not every data-lake target.

@clickhouse-gh clickhouse-gh Bot added the comp-refreshable-materialized-view Refreshable materialized views: scheduled/periodic refresh, refresh state machine, refresh orches... label Sep 15, 2026
@SmitaRKulkarni SmitaRKulkarni self-assigned this Sep 15, 2026
@asya-ch asya-ch closed this Sep 16, 2026
@asya-ch
asya-ch deleted the asya/refresh branch September 28, 2026 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-refreshable-materialized-view Refreshable materialized views: scheduled/periodic refresh, refresh state machine, refresh orches... pr-not-for-changelog This PR should not be mentioned in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants