Repository navigation
add a setting to allow disabling interserver mode over tcp_with_proxy interface - #123188
Conversation
…o-disable-interserver-mode-over-tcp-with-proxy # Conflicts: # src/Core/ServerSettings.cpp
|
Workflow [PR], commit [ebe4de8] Summary: ✅
AI ReviewSummaryThis PR adds the Missing context / blind spots
Final Verdict✅ No new blockers or majors found in the current revision. LLVM Coverage ReportMeasured on commit ebe4de8.
Changed lines: Changed C/C++ lines covered: 23/23 (100.00%) · Uncovered code |
- Declare `ServerSetting::tcp_with_proxy_allow_interserver_mode` in `TCPHandler.cpp`. - Add `/// NOLINT` to the `throw exception;` to satisfy `cert-err09-cpp`. - Document the setting with `false` in `config.xml` and mirror it in `config.yaml.example`. - Add an instance relying on the default value to check interserver mode stays allowed on `tcp_with_proxy_port`. - Assert the `LoginFailure` row in `system.session_log` for the rejection.
…tcp_with_proxy_port` The reject path logged the `LoginFailure` against `socket().peerAddress()`, so with `auth_use_forwarded_address` enabled `system.session_log` recorded the proxy instead of the real client. Use `getClientAddress` like the empty default user reject path does, and check `client_address` in the integration test. Related: ClickHouse#123188 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units9 translation units recompiled, 41 s compile time in total, 9 of them have a recent master baseline. |
…LED`-only With `auth_use_forwarded_address` enabled, `getClientAddress` throws `INCORRECT_DATA` for a non-IP PROXY source address. That skipped the `LoginFailure` row and the silent close for interserver peers in `runImpl`, sending a serialized error to an unauthenticated peer. Resolve the forwarded address without throwing in this path, and add a test with a malformed PROXY source address. Related: ClickHouse#123188 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The benchmark looked each row's group up in a constant array, `groups[number % 4096 + 1]`. About half of its CPU went to that lookup (`arrayElement` over a constant array copies row by row through a virtual `insertFrom`), not to the sampling-key code the test measures. On arm some builds run that loop about twice as slow in every server process: in the job profiles of the slow runs on ClickHouse#98708, ClickHouse#116376, ClickHouse#117754, ClickHouse#123545 and ClickHouse#123188 only that frame grew (x1.4 to x2.2) while every other frame stayed flat, so the query moved 20-27% and the confirmation restart reproduced it. The per-query tags collector numbers groups 0, 1, 2, ... with 0 reserved for the empty tag set (`ContextTimeSeriesTagsCollector.h`), so the 4096 groups the subquery creates are 1..4096 and the query can pass `number % length(groups) + 1` directly. `length(groups)` keeps the scalar subquery referenced: without it the analyzer drops the subquery, no group is registered and the function throws `Group 1 is out of bounds`. Checked on x86 with an official master build: the same keys over the 20M rows (`sum` and `groupBitXor` equal, 0 rows differ), 84 -> 52 ms, and the per-process medians of 24 processes span 79-91 ms before and 52-53 ms after. Co-Authored-By: Claude Opus 5.5 <[email protected]>
tiandiwonder
left a comment
There was a problem hiding this comment.
All addressed, thanks.
|
@groeneai Follow-up for a separate PR: the six other interserver |
|
Acknowledged. I will open a separate PR that moves the non-throwing PROXY address resolution from this PR into a helper and uses it at all seven interserver |
|
The follow-up is #125326. All seven interserver |
…ion failure On a PROXY listener with `auth_use_forwarded_address`, six of the seven interserver `onAuthenticationFailure` calls in `TCPHandler` passed `socket().peerAddress()`, so their `system.session_log` `LoginFailure` rows named the proxy instead of the client. Only the site added in ClickHouse#123188 resolved the forwarded address, through an inline block that must not throw: `getClientAddress` throws `INCORRECT_DATA` on a malformed forwarded value, which would turn the silent `AUTHENTICATION_FAILED` close into a serialized exception and drop the row. Move that block into `getClientAddressNoThrow` and call it at all seven sites (the `receiveHello` proxy-port and unknown-cluster / no-secret rejects, and the five `processQuery` failures). The helper takes no `ClientInfo` argument on purpose: in `processQuery` the local `client_info` has been overwritten from the still unauthenticated peer's Query packet, whose `forwarded_for` is chosen by that peer, so it must read the session's own `ClientInfo`, which carries only the connection-level value from the PROXY header or the `protocols` stack. The non-interserver rejects keep `getClientAddress`, which rejects a malformed forwarded address by design. Test: a third instance in `test_tcp_with_proxy_interserver_mode` that allows interserver mode on the proxy port, and three raw-protocol cases reaching the `receiveHello` unknown-cluster reject, the no-salt reject and the hash mismatch (the last with a decoy `X-Forwarded-For` in the Query packet, sent at protocol revision 54449 so that no addendum or nonce is involved). Requested in ClickHouse#123188 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cherry pick #123188 to 26.7: add a setting to allow disabling interserver mode over tcp_with_proxy interface
…r mode over tcp_with_proxy interface
Cherry pick #123188 to 26.8: add a setting to allow disabling interserver mode over tcp_with_proxy interface
…r mode over tcp_with_proxy interface
Cherry pick #123188 to 26.9: add a setting to allow disabling interserver mode over tcp_with_proxy interface
…r mode over tcp_with_proxy interface
Backport #123188 to 26.9: add a setting to allow disabling interserver mode over tcp_with_proxy interface
Backport #123188 to 26.8: add a setting to allow disabling interserver mode over tcp_with_proxy interface
Backport #123188 to 26.7: add a setting to allow disabling interserver mode over tcp_with_proxy interface
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Add the
tcp_with_proxy_allow_interserver_modeserver setting, which allows disabling the native protocol's interserver mode ontcp_with_proxy_portWorkflow [PR]
Sync PR [sync-upstream/pr/123188]
Version info
26.10.1.2179-master(included in26.10and later)26.9.25.14,26.8.34.12,26.7.38.9