Skip to content

Fix 04105_system_pause_view and 04319_system_stop_all_background with the database disk on object storage - #128859

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-04105-04319-wait-first-row-db-disk
Nov 3, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-04105-04319-wait-first-row-db-disk

Conversation

@groeneai

@groeneai groeneai commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #92472
Related: #127917

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):

Fix failures of the tests 04105_system_pause_view and 04319_system_stop_all_background when the database metadata is on object storage, where the check that the refresh is running landed before the refresh had read its first row.

Description

Failing job: Stateless tests (amd_asan_ubsan, db disk, distributed plan, targeted), <3a: refresh running before stop: 0> instead of 1 (reported in #92472 (comment), not caused by that PR).

interrupt_running_refresh runs SYSTEM REFRESH VIEW and then, one client start-up later, checks status = 'Running' and read_rows between 1 and 8. The refresh is already Running while it creates its target table, and with the database disk on object storage that takes seconds, so the check sees read_rows = 0. In the failing job's query_log the check ran 0.4-0.6 s after SYSTEM REFRESH VIEW and the refresh INSERT started 0.6-2.6 s after it, so 26 of 28 attempts saw read_rows = 0. Re-creating the view repeats the same timing, so all 10 attempts miss.

The helper now waits until the refresh has read its first row (or failed) before the one-call check. A new view's read_rows keeps its value after the refresh, so the wait cannot miss it, and clickhouse_test_time_left bounds it. The one-call check and the retry for the upper bound stay as they are. .reference files are unchanged.

Validation, on master 4944813cca46 CI binaries:

  • Database disk on MinIO with 10 ms injected latency each way, -j 7 --test-runs 7: before 14/14 FAIL (release) and 14/14 FAIL (asan_ubsan), 10 attempts per call; after 56/56 (release) and 42/42 (asan_ubsan) OK, 1 attempt per call.
  • Failpoint refresh_mv_pause_after_executor_published holding the refresh before it reads: before FAIL on all four label lines, after OK.
  • 50/50 OK per test with random settings, on a local disk and on the database disk.
  • PAUSE instead of STOP: fails 10 0; a forced 9 s delay before the check: fails on the label line.

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

Version info

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

… the database disk on object storage

`interrupt_running_refresh` checks `status = 'Running' and read_rows between 1 and 8` one client
start-up after `SYSTEM REFRESH VIEW`. The refresh is already `Running` while it creates its target
table, and with the database disk on object storage that takes seconds, so the check saw
`read_rows = 0` and printed 0. Re-creating the view repeated the same timing, so all 10 attempts
missed: `<3a: refresh running before stop: 0>` in `Stateless tests (amd_asan_ubsan, db disk,
distributed plan, targeted)` (reported on ClickHouse#92472; there the check ran 0.4-0.6 s after the refresh
started and the refresh INSERT 0.6-2.6 s after it).

Wait until the refresh has read its first row, or failed, before the one-call check. A new view's
`read_rows` keeps its value after the refresh, so the wait cannot miss it (no hang like the one
ClickHouse#125034 fixed), and `clickhouse_test_time_left` bounds it. The `read_rows <= 8` check, the one-call
statements and the retry from ClickHouse#127917 are unchanged, so a STOP that lands after the refresh is
still retried and an all-miss is still a labelled mismatch.

Validated on master 4944813 CI builds: with the database disk on MinIO and 10 ms injected
latency each way, before 14/14 FAIL (release and asan_ubsan), after 56/56 and 42/42 OK, one attempt
per helper call; a failpoint that holds the refresh before it reads fails before and passes after;
50/50 OK per test with random settings on a local disk and on the database disk.

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

groeneai commented Nov 3, 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 my own cold review of the same diff (0 findings).

No findings to adjudicate.

Session id: cron:clickhouse-review-slot-8:20261103-005500

@groeneai

groeneai commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Failpoint refresh_mv_pause_after_executor_published holding the refresh before it reads fails all four refresh running before ... lines on demand. Database disk on MinIO with 10 ms latency each way, -j 7 --test-runs 7: 14/14 FAIL on the master 4944813cca46 release and asan_ubsan builds.
b Root cause explained? The check runs one client start-up after SYSTEM REFRESH VIEW, while the refresh is Running but still creating its target table on the object-storage database disk, so read_rows = 0. Re-creating the view repeats the timing, so all 10 attempts miss.
c Fix matches root cause? Yes. The helper waits for the first row (or a refresh error) before the check. No bound widened, no tag; the read_rows between 1 and 8 check and the retry are unchanged.
d Test intent preserved / new tests added? Yes. No assertion or .reference change. PAUSE instead of STOP still fails 10 0; a forced 9 s delay still fails on the label line.
e Both directions demonstrated? Yes, same binaries and servers: failpoint arm FAIL/OK; latency db disk 14/14 FAIL vs 56/56 OK (release), 14/14 FAIL vs 42/42 OK (asan_ubsan).
f Fix is general across code paths? Both copies of the helper (04105, 04319) are fixed; no other test uses it. The Test 1 PAUSE loops are unaffected (1 attempt in every run).
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only). 50/50 OK per test with random settings on a local disk and on the database disk.
h Backward compatible? (maintainer-approved exception only) N/A (test-only).
i Invariants and contracts preserved? A new view's read_rows only grows and keeps its value after the refresh, so the wait cannot miss it; clickhouse_test_time_left bounds it at the test deadline.

Session id: cron:clickhouse-impl-slot-6:20261102-230500

@groeneai

groeneai commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

cc @tuanpach, could you review this and add the can be tested label so CI runs? With the database disk on object storage the refresh stays Running with read_rows = 0 for seconds while it creates its target table, so interrupt_running_refresh in 04105 and 04319 now waits for the first row (or a refresh error) before its one-call check.

@clickhouse-gh

clickhouse-gh Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [bf87d7a]

Summary: ✅


AI Review

Summary

PR #128859 makes 04105_system_pause_view and 04319_system_stop_all_background wait for the first row or a refresh exception before attempting cancellation. This addresses slow target-table creation on object storage while preserving the existing running-state checks, retries, and cancellation assertions. Reviewed head bf87d7a5d9a1e3f33aafa9d604d3befc06b9f63d; no actionable findings.

Missing context / blind spots
  • ⚠️ The affected targeted CI jobs have no per-test results available yet, and no local ClickHouse binary is available for an independent rerun. Runtime evidence comes from the author's documented before/after runs, failpoint reproduction, and negative controls. Completed CI results for both tests would independently confirm that evidence.
Final Verdict

Status: ✅ Approve

@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 3, 2026
@alexey-milovidov alexey-milovidov self-assigned this Nov 3, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 3, 2026
Merged via the queue into ClickHouse:master with commit e497200 Nov 3, 2026
529 of 531 checks passed
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 3, 2026
@clickhouse-gh clickhouse-gh Bot added comp-refreshable-materialized-view Refreshable materialized views: scheduled/periodic refresh, refresh state machine, refresh orches... 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-refreshable-materialized-view Refreshable materialized views: scheduled/periodic refresh, refresh state machine, refresh orches... 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