Repository navigation
Conversation
Since v2.49.0 every HTTP request with LZ4 or ZSTD compression sets network_compression_method, and network_zstd_compression_level for ZSTD with a level. The server rejects a request that changes a setting for a user with readonly = 1, so such a user could not open a connection when the configured codec or level was not the server default. The server hello query now reads the readonly setting and does not send the two settings itself. Later requests send them only when the user can change settings. compress and decompress are HTTP parameters and are still sent for every user. The two settings are also not replaced when the caller set them in Options.Settings or for the query.
xmasdev
requested review from
chernser,
kavirajk and
polyglotAI-bot
as code owners
November 14, 2026 07:48
1 task done
Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2118.
Since #1840 (v2.49.0) every HTTP request with
CompressionLZ4orCompressionZSTDsetsnetwork_compression_method, andnetwork_zstd_compression_levelfor ZSTD with a level. The server rejects a request that changes a setting for a user withreadonly = 1. The first request is the server hello query, so such a user cannot open a connection when the configured codec or level is not the server default. On 26.9 that includesCompressionLZ4andcompress=truein a DSN.What changes:
getSetting('readonly').readonlyis not 1. Withreadonly = 2the user can change settings, so nothing changes there.compress=1anddecompress=1are HTTP parameters and not settings, so they are still sent for every user. A read-only user gets responses in the server's codec. The reader takes the codec from each compressed frame, so decoding does not depend on the setting.Options.Settingsor for the query. Before, a connection-levelnetwork_compression_methodwas replaced by the per-request value, and the ZSTD level was replaced in both cases.For users that can change settings the configured codec and level still apply, so
Test1772_HTTPNativeCompressionMethodSettingspasses unchanged.I read
readonlyastoUInt8(getSetting('readonly'))because the type of the baregetSettingresult is not something I wanted the scan to depend on.This does not touch
max_execution_time(#1748, #1107). A read-only user still needs aDialTimeoutof 1s or less over HTTP, and the new test sets that.Checklist
Test2118creates areadonly = 1user and queries over HTTP with LZ4, ZSTD, and ZSTD with levels 1 and 9, throughclickhouse.Openanddatabase/sql.Test2118_ConnectionSettingschecks that values fromOptions.Settingsare kept and that a per-query value still has priority. I ran them on 26.9 (defaultZSTD) and 26.3 (defaultLZ4). Onmainthe LZ4 and ZSTD level cases fail on 26.9 withREADONLY.Note
Medium Risk
Touches HTTP native compression on every query/batch path; behavior changes for read-only users and when compression settings are pre-configured, though scope is narrow and well-tested.
Overview
Fixes HTTP connections failing for users with
readonly = 1when LZ4/ZSTD compression is enabled, because the client was sendingnetwork_compression_methodandnetwork_zstd_compression_levelon every request (including server hello)—settings ClickHouse rejects for that profile.The server hello query now reads
getSetting('readonly')and setscompressionSettingsso codec/level settings are only applied whenreadonly ≠ 1(readonly = 2still gets configured compression).compress/decompressstay on all requests; read-only users rely on the server’s default codec.applyNativeCompressionSettingsis now a connection method and no longer overwritesnetwork_compression_methodornetwork_zstd_compression_levelwhen they are already set inOptions.Settingsor per-query settings.Integration tests cover read-only HTTP queries (LZ4/ZSTD/levels), settings precedence, and
readonly = 2behavior.Reviewed by Cursor Bugbot for commit 23ce8db. Bugbot is set up for automated code reviews on this repo. Configure here.