Skip to content

Use a fixed insert time in the storage memory check scenarios - #128485

Merged
qoega merged 1 commit into
ClickHouse:masterfrom
groeneai:storage-memory-check-fixed-insert-time
Nov 4, 2026
Merged

qoega merged 1 commit into
ClickHouse:masterfrom
groeneai:storage-memory-check-fixed-insert-time

Conversation

@groeneai

@groeneai groeneai commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #128329

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

The Storage memory check scenarios insert a fixed time instead of now(), so the check no longer fails unrelated PRs at the start of every month.

Description

Storage memory check fails unrelated PRs during the first 27.8 hours of every month. Between 2026-10-31 23:00 and 2026-11-01 14:00 UTC, 6 PRs went red on 02, 03, 04, 05 or 09 by 12 to 47 KB of ZSTD workspace (ZSTD_resetCCtx_internal > ZSTD_cwksp_create), e.g. #128329 (02, 09) and another PR (04, 05, 09).

02_insert_data.sql inserted created = now() - INTERVAL number SECOND for 100,000 rows (27.8 h), and test_mt is PARTITION BY toYYYYMM(created) in the job's Europe/Amsterdam time zone. Near the start of a month the rows span two months, so the table gets two partitions instead of the single part the scenario intends. OPTIMIZE FINAL then merges them in parallel and the 03/04 mutations run one task per part, so ZSTD compressions overlap, and which pooled context (with which workspace size) serves which block depends on scheduling. The difference stays live after 09_cleanup.sql. Inside this window the 02 baseline also moves from ~26 KB to ~980 KB on both arms.

The scenario now inserts a fixed mid-month time. The literal and the partition key are evaluated in the same session time zone, so all rows land in one partition in any time zone.

Validated locally with a debug clickhouse-examples and the job's own analysis helpers: the unfixed 02 at the 2026-11-01 job time gives partitions 202610 and 202611, the fixed one gives a single 202601 partition under Europe/Amsterdam, UTC, Pacific/Kiritimati and Pacific/Pago_Pago. Over 30 profiler runs per variant, the fixed per-scenario medians equal the out-of-window ones (02: 25,084 vs 25,080 B; in-window 1,107,696 B).


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

Version info

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

`02_insert_data.sql` filled `created` with `now() - INTERVAL number SECOND`
for 100000 rows (a 27.8 h span), and `test_mt` is partitioned by
`toYYYYMM(created)` in the job's Europe/Amsterdam time zone. During the first
27.8 hours of every month the rows therefore spanned two months: two
partitions and two parts instead of the single part the scenario intends.

With two partitions `OPTIMIZE FINAL` merges them in parallel and the
mutations of 03 and 04 run one task per part, so ZSTD compressions overlap
and draw contexts from the shared per-CPU pools. Which pooled context (and
workspace size) serves which block then depends on scheduling, so the live
ZSTD workspace bytes at a checkpoint differ between the master and the PR
run by one size step (12 KB to 47 KB) and stay live after `09_cleanup.sql`.
On 2026-11-01 this failed unrelated PRs on 02/03/04/05/09; the 02 baseline
also moves from ~26 KB to ~980 KB inside the window (seen on 2026-10-01 too).

A fixed mid-month instant keeps all rows in one partition in any time zone,
because the literal and the partition key are evaluated in the same session
time zone.

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

groeneai commented Nov 1, 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; 2 findings, the same 2 again on a re-run against the final PR text).

# Sev Finding Verdict Evidence / action
1 ⚠️ 02_insert_data.sql does not assert its one-partition layout; add a throwIf over system.parts DISAGREE No self-tests for test infrastructure (#119766), and vacuous outside the window. Validated locally: unfixed 202610 + 202611, fixed 202601 under 4 time zones.
2 💡 README says "the inserted timestamps are fixed" while 07_many_parts.sql still inserts now() AGREE, not blocking 07's now() is not a partition or sort key, so only the wording is broad.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-9:20261101-144400

@groeneai

groeneai commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. clickhouse local, TZ=Europe/Amsterdam, 01 + 02, active partitions of test_mt: unfixed 02 gives 202610 + 202611 today, one partition on 2026-10-29.
b Root cause explained? now() - INTERVAL number SECOND spans 27.8 h under toYYYYMM(created), so near the 1st there are two partitions; overlapping ZSTD compressions make the live pooled workspace a scheduling draw (12 to 47 KB).
c Fix matches root cause? Yes. The wall-clock input is replaced where it is produced. No threshold, stack exclusion or tag change.
d Test intent preserved / new tests added? Yes. The check measures the same one-part workload it measures on every other day, and still sees real ZSTD regressions. No harness self-test (test-infrastructure change).
e Both directions demonstrated? Yes. Partition probe: unfixed 2 partitions, fixed 1. Profiler, 30 runs per variant: 02 in-window 1,107,696 B vs fixed 25,084 B vs out-of-window 25,080 B; 3 unfixed runs after the fixed ones bring the step back.
f Fix is general across code paths? Yes. 02 is the only writer of test_mt; 05 copies it (one partition per copy); 07's now() is not a partition or sort key; the job's inline scenario has no time input.
g Fix generalizes across inputs (params/datatypes/wrappers)? Yes. One 202601 partition under Europe/Amsterdam, UTC, Pacific/Kiritimati (UTC+14) and Pacific/Pago_Pago (UTC-11).
h Backward compatible? (maintainer-approved exception only) N/A. CI scenario input only; no setting, format or server code.
i Invariants and contracts preserved? Yes. The scenario's own invariant (one part after OPTIMIZE FINAL) now holds on every date; the job's two-pass measurement and both arms reading the scenarios from the PR checkout are unchanged.

Session id: cron:clickhouse-impl-slot-5:20261101-123343

@groeneai

groeneai commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

cc @qoega, could you review this and add the can be tested label so CI runs? 02_insert_data.sql inserted now() - INTERVAL number SECOND over 27.8 h into a toYYYYMM(created) partitioned table, so during the first day of every month it gets two partitions, and the parallel merges and mutations make the live ZSTD workspace a scheduling draw that fails unrelated PRs; the scenario now inserts a fixed mid-month time.

@clickhouse-gh

clickhouse-gh Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5d45260]

Summary: ✅


AI Review

Summary

PR #128485, reviewed at 5d452602d60f639997bffbf103310d8a64bafcac, replaces now with a fixed mid-month timestamp in 02_insert_data.sql, keeping the storage-memory workload in one monthly partition. No actionable findings remain after reviewing the diff, surrounding scenarios, profiler execution, and prior discussion. The documented partition probes and repeated profiler measurements support approval of this CI-only change.

Missing context / blind spots
  • ⚠️ Allocation measurements were not independently reproduced: no local profiling binary is available, and the current CI entry exposes no scenario results. A completed Storage memory check report would independently confirm the author's reported measurements.
Final Verdict

Status: ✅ Approve. No required changes.

@clickhouse-gh clickhouse-gh Bot added pr-ci comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). labels Nov 1, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Nov 1, 2026
@qoega
qoega added this pull request to the merge queue Nov 4, 2026
@qoega qoega self-assigned this Nov 4, 2026
Merged via the queue into ClickHouse:master with commit 508442d Nov 4, 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 4, 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-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). 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.

4 participants