Skip to content

fix(0071): apply corrected rollup MV DDL to ch-prod-01 + runbook/docs#64

Merged
karczuRF merged 6 commits into
developfrom
feat/0071_reapply-rollup-ddl-runbook
Jun 29, 2026
Merged

fix(0071): apply corrected rollup MV DDL to ch-prod-01 + runbook/docs#64
karczuRF merged 6 commits into
developfrom
feat/0071_reapply-rollup-ddl-runbook

Conversation

@karczuRF

@karczuRF karczuRF commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Re-applies the corrected refreshable-MV rollup chain to live ch-prod-01 (the buggy DDL had been live since 0051) and closes task 0071. The OHLC bug: the bucket key AS timestamp shadows the source timestamp, so argMin(open)/argMax(close)/argMax(close_usd) tie-break to an arbitrary row instead of the true first/last by time — fixed by source-qualifying t.timestamp.

  • Prod fix applied & verified (CH 26.3.10.60, Route A, empty-DB path): six prices.mv_ohlcv_* dropped + re-created from corrected rollups.sql. SHOW CREATE mv_ohlcv_1m_to_15m confirms FROM price_ohlcv_1m AS t FINAL with argMin/argMax(…, t.timestamp) (no bare timestamp); system.view_refreshes healthy. No restart, no data residue, prices.*-scoped — BE default.* untouched. Recompute step N/A (no data → no mis-rolled buckets).
  • Operator runbook added (notes/G-prod-reapply-runbook.md) with empty-DB fast path; hardened from the live run — three footguns fixed: re-streaming without the DROP is a no-op (IF NOT EXISTS), the verify query needs AS r FINAL (alias before FINAL), and the live smoke test must use in-window timestamps (now() - INTERVAL 2 HOUR filter).
  • Schema comments in rollups.sql/preroll.sql now document why the bucket alias can't be renamed: a TO-table MV routes results to the target by column name (so the bucket must be timestamp), which is separately what shadows the source — so t.-qualification is the only fix. A ts_bucket rename was tried and rejected with Code: 8 THERE_IS_NO_COLUMN, reproduced live via prices-clickhouse/tests/rollup_chain_it.rs. Comment-only — no DDL behaviour change; rollup integration tests green.
  • Task 0071 completed + archived (active/ → archive/), all ACs checked, provenance recorded.

Notes

  • No schema DDL behaviour change in this PR — the corrected DDL itself shipped under 0059; this applies it to the running cluster and documents the constraints.
  • Prod apply was operator-executed (prepare-not-deploy); CI runs cargo check/test --workspace (rollup integration tests are #[ignore]d — no CH on the runner).

karczuRF added 6 commits June 29, 2026 11:16
Investigated renaming the shadowing rollup bucket alias `AS timestamp`
to `ts_bucket` as a permanent hardening. Rejected: a TO-table MV maps
its SELECT output to the target columns BY NAME, so `ts_bucket` is
refused (Code: 8 THERE_IS_NO_COLUMN), reproduced live on CH 26.3.10.60
via prices-clickhouse/tests/rollup_chain_it.rs. The bucket key is
structurally forced to `AS timestamp`; qualifying the source as
`t.timestamp` is the only fix, exactly as 0059 shipped.

Bank the finding as comments in rollups.sql / preroll.sql so the
dead-end isn't re-attempted (comment-only; both rollup integration
tests stay green). Convert 0071 to a directory task and add the
operator runbook (notes/G-prod-reapply-runbook.md) with an empty-DB
fast path. No schema behaviour change; no prod deploy.
…oof step

The §6 verify query had 'price_ohlcv_15m FINAL AS r' — CH requires the alias
before FINAL ('AS r FINAL'), else Code: 62 parse error (hit live). Also add a
SHOW CREATE definition check after re-create: on an empty DB, listing 6 MV
names does not prove the DROP took (buggy set is also 6), so confirm the live
definition reads 'AS t FINAL' + 't.timestamp'.
…an up

The live MV filters WHERE t.timestamp >= now() - INTERVAL 2 HOUR, so a smoke
fixture with an epoch timestamp (1700000000) is excluded by the refresh and
_15m stays empty (reads as 'stuck'/blank). Replace with now()-relative
timestamps, flag the window, and make smoke-row cleanup an explicit always-run
step.
…d-01

Empty-DB path verified live (CH 26.3.10.60): six prices.mv_ohlcv_* dropped and
re-created from corrected rollups.sql; SHOW CREATE confirms qualified
t.timestamp; refresh healthy; no residue, no restart. All ACs met (recompute
N/A on empty DB). Provenance in notes/G-prod-reapply-runbook.md.
@karczuRF karczuRF changed the title docs(0071): rollup MV alias rationale + prod re-apply runbook fix(0071): apply corrected rollup MV DDL to ch-prod-01 + runbook/docs Jun 29, 2026
@karczuRF karczuRF merged commit 106a7d8 into develop Jun 29, 2026
3 checks passed
@karczuRF karczuRF deleted the feat/0071_reapply-rollup-ddl-runbook branch June 29, 2026 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant