Skip to content

chore(ci): flush the ClickHouse Kafka engine every 100 ms in dev and CI - #90709

Draft
jose-sequeira wants to merge 2 commits into
jose-sequeira/consumer-v2-shutdown-rebalancefrom
jose-sequeira/clickhouse-test-flush-interval
Draft

chore(ci): flush the ClickHouse Kafka engine every 100 ms in dev and CI#90709
jose-sequeira wants to merge 2 commits into
jose-sequeira/consumer-v2-shutdown-rebalancefrom
jose-sequeira/clickhouse-test-flush-interval

Conversation

@jose-sequeira

@jose-sequeira jose-sequeira commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Problem

Every Node.js test that waits for a row to land in ClickHouse pays the Kafka engine's flush interval on each round trip. With stream_flush_interval_ms at 500 in the dev and CI ClickHouse profile, that wait is most of the runtime of the ingestion e2e suites: instrumenting ingestion-e2e showed 85% of its time in test bodies, nearly all of it polling for that flush.

  • Nothing in posthog/clickhouse/kafka_engine.py pins kafka_flush_interval_ms per table, so the profile value in docker/clickhouse/users-dev.xml governs every Kafka engine table.
  • CI starts ClickHouse from docker-compose.dev.yml, which mounts that same file, so dev and CI share the setting.

Changes

  • ClickHouse-backed tests get their results about 400 ms sooner per round trip: stream_flush_interval_ms goes from 500 to 100 in the dev/CI profile. ingestion-e2e drops from about 16 s to 11 s locally, and the other suites that wait on ClickHouse (sessionreplay/consumer.e2e, rerun-paginator, person-state-batch, the CDP ClickHouse tests) benefit the same way.
  • Nothing user-visible changes, and production is unaffected: this file is only mounted by the dev and CI compose stack.

Note

On a dev machine this means smaller, more frequent parts under sustained ingestion traffic and a little more merge load. 200 ms is the conservative fallback if that shows up; the gain scales linearly with the interval.

How did you test this code?

  • Local dev ClickHouse restarted at 100 ms, then the five ingestion e2e harness suites (251 tests) three times: 11.4 s, 11.0 s, 11.3 s, no failures. The same suites at 500 ms take about 16 s.
  • The first run right after the ClickHouse restart failed 30 tests while its Kafka consumers re-attached; runs after that were clean. CI starts ClickHouse fresh and waits on waitForClickHouseKafkaConsumer, so it does not hit that window.
  • Not run: the full Node.js suite locally; CI on this layer will show the lane-level effect.

Automatic notifications

  • Publish to changelog?

Docs update

None.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Claude Code (Claude Fable 5) under @jose-sequeira's direction, as the third layer of the stack on #90032 and #90348. Skills invoked: /stacking-prs, /writing-pr-descriptions. The interval was identified as the per-round-trip floor after per-phase timing of the e2e harness ruled out infra setup as a cost; 100 ms was the value measured, with 200 ms noted as the conservative alternative.

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

🤖 CI report

🚨 Trunk lane — universal lane

This PR is assigned to the universal lane. It cannot merge in parallel with other PRs, so it can take longer to merge. Ask dev-ex if you think this is wrong.

Hobby preview — passed

Hobby deployment smoke test passed successfully.


Run 33155914942

@trunk-io

trunk-io Bot commented Aug 28, 2026

Copy link
Copy Markdown

Static BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

Tests that assert on rows landing in ClickHouse spend most of their time
waiting for the Kafka engine to flush, so stream_flush_interval_ms is the
floor of every such round trip. Nothing pins kafka_flush_interval_ms per
table, so this profile value governs all of them. 500 ms to 100 ms takes
ingestion-e2e from about 16 s to 11 s locally. The file is dev and CI
only; production is unaffected.
@jose-sequeira
jose-sequeira force-pushed the jose-sequeira/clickhouse-test-flush-interval branch from b1ef924 to 9e9874d Compare August 28, 2026 08:25
The Node.js change filter listed the compose files but not the ClickHouse
config they mount, so a change to docker/clickhouse skipped every Jest
job. The Kafka engine settings in that config set how long every
ClickHouse-backed test waits, so they must run the suite.
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