Repository navigation
Resolve the client hostname in ClientInfo on demand - #115491
Conversation
`ClientInfo::fillOSUserHostNameAndVersionInfo` resolved the local FQDN through `getFQDNOrHostName`, a blocking `getaddrinfo` that also dlopens the NSS modules. Every `clickhouse local` and `clickhouse client` invocation paid for it even when nothing ever asked for the name, and a slow resolver sat on the startup path with no short timeout. `getClientHostName` resolves it on first use instead. When the name arrives from a peer in `read` it describes that peer, so it is kept as received and never re-resolved locally. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [7ab6be0] Summary: ✅
AI ReviewSummaryThis PR moves Tests
Final VerdictLLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 37/37 (100.00%) · Uncovered code |
evillique
left a comment
There was a problem hiding this comment.
Maybe also a little test?
clickhouse-local --query "SELECT client_hostname != '' FROM system.processes"
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units1320 translation units recompiled, 7789 s compile time in total, 1320 of them have a recent master baseline. |
|
📊 Cloud Performance Report 🟢 AI verdict: This PR only changes how the client hostname is resolved for logging (system.processes, query_log, session_log) and defers it on demand; it does not touch any query-execution code path. Every flagged query is a plain SELECT, so none of the observed deltas are plausibly caused by this diff. Eight flagged improvements (clickbench Q13/Q15/Q16/Q18/Q30/Q33/Q34/Q35) were downgraded to not-sure as run-to-run variance, amplified by the asymmetric 6-vs-30 run counts. Three large deltas (clickbench Q23 \u00d72.4 faster, TPCH Q7 \u00d78.4 faster, Q8 \u00d72.2 faster) remain locked by the large-shift trust override, but they are unrelated to this change and reflect baseline/measurement differences, not a real speedup from the PR. clickbench🟢 1 improved · Flagged queries (9 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 2 improved Flagged queries (2 of 22)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. Debug info
|
`client_hostname` moves to the private section so it cannot be read by mistake instead of `getClientHostName`, and `resolve_client_hostname_on_demand` is cleared as soon as `read` knows it describes a peer rather than only on the TCP branch. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
| . "$CUR_DIR"/../shell_config.sh | ||
|
|
||
| # The client hostname is resolved on demand, so it must still be reported to whoever asks for it. | ||
| ${CLICKHOUSE_LOCAL} --query "SELECT client_hostname != '' FROM system.processes" |
There was a problem hiding this comment.
client_hostname is still populated once system.processes asks for it. It would still pass if ClientInfo::fillOSUserHostNameAndVersionInfo started calling getFQDNOrHostName() eagerly again, so it does not protect the actual contract behind the Performance Improvement label: lazy hostname resolution on startup.
Please either add focused evidence for the lazy behavior, or include the result of the existing tests/performance/clickhouse_local_startup.xml benchmark for this PR.
Split out of #112496.
ClientInfo::fillOSUserHostNameAndVersionInforesolved the local FQDN throughgetFQDNOrHostName, a blockinggetaddrinfothat also dlopens the NSS modules. Everyclickhouse localandclickhouse clientinvocation paid for it even when nothing ever asked for the name, and a resolver that is slow or unreachable sat on the startup path with no shorttimeout.
getClientHostNameresolves it on first use instead, andgetFQDNOrHostNamecaches process-wide, so the readers —system.processes,query_log,session_logand the TCP handshake — see the same value as before. When the name arrives from a peer inClientInfo::readit describes that peer rather than us, so it is kept as received and never re-resolved locally.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The client hostname is now resolved when it is first reported instead of on every
clickhouse clientandclickhouse localinvocation.Workflow [PR]
Sync PR [sync-upstream/pr/115491]