Skip to content

ClickHouse 26.8: pin synchronous inserts, 26.8-safe fixtures, CI on 26.8 - #11

Merged
ar2rsawseen merged 1 commit into
mainfrom
claude/clickhouse-26.8-compat
Oct 15, 2026
Merged

ar2rsawseen merged 1 commit into
mainfrom
claude/clickhouse-26.8-compat

Conversation

@ar2rsawseen

Copy link
Copy Markdown
Member

Why

countly-platform now runs ClickHouse 26.8 (floor 26.8.6). Two things in that move reach the migrator:

  • 26.8 reads a bare JSON number for a DateTime64 column as seconds, so a millisecond epoch lands on 9999-12-31 unless input_format_read_datetime_number_as_raw_value=1 (platform runbook: docs/runbooks/clickhouse-26.8-upgrade.md).
  • Countly's ClickHouse default profile sets async_insert=1 (deploy/compose/clickhouse/users.d/async-insert.xml, Helm countly-clickhouse profile). The migrator never set it, so its staging inserts silently became async inserts.

What changes

  • StagingManager sets async_insert: 0 on its client. Verify-then-attach counts rows right after an insert and needs an ack to mean the rows are written. Under the profile that held only while wait_for_async_insert stays on, which is an env knob there (CLICKHOUSE_WAIT_FOR_ASYNC_INSERT).
  • Timestamps need no change: ts/cd/lu are written as quoted yyyy-MM-dd HH:mm:ss.SSS strings, which parse the same on every version with or without the setting. A comment there now says why they must stay strings.
  • Test fixtures that inserted bare ms numbers into ts in VALUES now use fromUnixTimestamp64Milli(...). On a 26.8 server without the setting, a bare number stores 9999-12-31.
  • The ledger e2e test creates the platform's real drill_events DDL (codecs, cd_minmax, object serialization settings) and asserts:
    • exact stored ts/cd/lu and partitions;
    • zero rows in year 9999;
    • every insert in the run had async_insert=0 (from system.query_log).
  • CI moves from clickhouse-server:26.4 to stock 26.8. The stock image has no Countly profile, so the raw-value setting is off: the strictest case, as on an external ClickHouse. The opt-in outage test defaults to 26.8 too.

Already compatible, no change needed:

  • Overflowing integers in event data. sanitizeJsonValue already stringifies them with the same bounds as the platform's eventTransformer.ts.
  • Unquoted 64-bit ints in JSON output on 26.x. Every ClickHouse read goes through Number(), and the cd checksum is reduced mod 2^32, so nothing exceeds 2^53. Content sampling compares timestamps as text and JSON columns by key set.

How it was tested

Run against ClickHouse 26.8.17 with Countly's production profile (async_insert=1, raw-value=1) and MongoDB 8.3:

  • Before the change, the suite passed (100 integration tests), but query_log showed every staging insert as an async insert.
  • After the change, vitest run tests/differential tests/integration passes: 174 passed, 1 skipped (opt-in outage).
  • With the async_insert: 0 line removed, the new e2e assertion fails (['1'] vs ['0']), so it guards the pin.
  • With the raw-value setting forced off (an external 26.8 without the profile), a transformed row stored the right ts/lu/cd (2025-09-04). A bare-number control row stored 9999-12-31.

🤖 Generated with Claude Code

Countly's ClickHouse runs its default profile with async_insert=1, so the
staging inserts silently became async inserts. The verify-then-attach count
right after an insert relies on an ack meaning the rows are written, which
then held only while wait_for_async_insert stays on (an env knob there).
The client now sets async_insert=0 itself.

ts/cd/lu are already written as quoted datetime strings, so the 26.8 change
that reads a bare JSON number for DateTime64 as seconds does not reach the
migrator's writes, with or without
input_format_read_datetime_number_as_raw_value. Test fixtures did write bare
millisecond numbers into ts in VALUES, which stores 9999-12-31 on a 26.8
server without that setting; they now use fromUnixTimestamp64Milli.

The ledger e2e test now creates the platform's drill_events DDL (codecs, cd
index, object serialization settings) and asserts exact stored ts/cd/lu and
partitions, no 9999 rows, and that every insert ran with async_insert=0.
CI moves from ClickHouse 26.4 to the stock 26.8 image (no Countly profile,
the strictest case); the opt-in outage test defaults to 26.8 too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 14, 2026 13:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T13:03:18.302109Z 50324d8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ar2rsawseen
ar2rsawseen merged commit 8bd92db into main Oct 15, 2026
2 checks passed
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.

3 participants