Skip to content

fix(clickhouse): request LZ4 responses from ClickHouse 26.9+ - #371

Merged
mattsse merged 2 commits into
mainfrom
claude/great-mendeleev-d82166
Oct 6, 2026
Merged

mattsse merged 2 commits into
mainfrom
claude/great-mendeleev-d82166

Conversation

@mattsse

@mattsse mattsse commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

ClickHouse 26.9 switched the codec of compress=1 HTTP responses to ZSTD (ClickHouse#108786), but the clickhouse crate 0.14 only decodes LZ4 native frames. Against clickhouse-server:latest, which all of our compose files use, every sink query fails with decompression error: incorrect magic number, starting with the version check in ensure_schema.

The sink client now sets network_compression_method=lz4. Every 26.9 stable release honors it for compress=1 responses (ClickHouse#119825), and older servers already respond with LZ4. The upstream crate fix (clickhouse-rs#482) is unreleased; it avoids this setting because read-only users cannot change it, which doesn't matter for the sink since it needs write access. The query engine in src/clickhouse.rs uses plain reqwest without compress=1 and was not affected.

This also fixes test_backfill_replays_blocks_with_extra_block_versions, which failed on every server version. It wrote the stale and canonical versions of block 1 in one INSERT, which ReplacingMergeTree collapses on insert, so the two-version precondition never held. The product check is correct (canonical_blocks_present reads without FINAL). The test now writes the stale version separately into another monthly partition so it survives until the backfill repairs it. Stopping merges would not work here because it also blocks the repair's ALTER TABLE ... DELETE mutation.

The ClickHouse integration tests pass against both 26.9.8.3 and 25.12.11.4.

🤖 Generated with Claude Code

ClickHouse 26.9 frames `compress=1` HTTP responses with ZSTD by default,
while the clickhouse crate 0.14 only decodes LZ4 native frames, so every
sink query failed with "decompression error: incorrect magic number".
Setting network_compression_method=lz4 restores LZ4 framing on 26.9 and
is a no-op on older servers.
The test wrote the stale and canonical versions of block 1 in a single
INSERT, which ReplacingMergeTree collapses on insert, so the two-version
precondition never held. Write the stale version separately into another
monthly partition; stopping merges instead would also block the repair's
DELETE mutation.
@mattsse
mattsse merged commit 334de6c into main Oct 6, 2026
11 checks passed
@mattsse
mattsse deleted the claude/great-mendeleev-d82166 branch October 6, 2026 03:56
@tempo-github-sts tempo-github-sts Bot mentioned this pull request Oct 6, 2026
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.

2 participants