fix: preserve multi-host HA DSN addresses (Go 1.26) - #1946
fix: preserve multi-host HA DSN addresses (Go 1.26)#1946sankalpsthakur wants to merge 8 commits into
Conversation
chernser
left a comment
There was a problem hiding this comment.
- correct implementation - use std lib
- documentation how it works and changelog
- more tests with authentication
- ideally integration test
|
Thanks @chernser, addressed the feedback in the latest push. Documented lib/churl and refactored splitHostList to use net.SplitHostPort and JoinHostPort, expanded docs and added a changelog entry. Added more auth tests for multi-host cases including query overrides and IPv6. Unit tests pass. Let me know if you want integration coverage as well. |
🤖 Claude reviewHardens multi-host HA DSN parsing (#1784) by extracting the host list from the raw DSN authority instead of relying on Key concerns:
Blind spots: this review is static — the sandbox could not run Verdict: General findings
Inline comments are attached to the relevant lines. This summary updates in place on re-review. |
c54255c to
d1c8f2f
Compare
|
@chernser follow-up on 74b1af5: cluster-wide Auth test (userinfo, query override, post-ParseDSN Options mutation) and README notes for multi-host IPv6 / failover auth. Earlier (d1c8f2f): multi-host split in lib/churl.parseHost; fromDSN only SplitHostPort/JoinHostPort. Integration: TestMultiHostDSNFailover. Ready when you have a moment. |
|
Updated this for the stdlib-style multi-host parsing notes, auth/override cases, changelog, and renamed the tests off the issue number. Ready for another pass when you have time. |
|
Merged latest Review checklist remains covered: stdlib |
aa8edf8 to
fb742fe
Compare
|
Pushed ae9f6d5. After churl.Parse, hosts split with strings.Split + SplitHostPort. TestMultiHostDSNAuthOverride covers replacing Options.Auth after ParseDSN, including failover to the live host. |
Extract HA host lists from the raw DSN authority instead of only splitting url.Host, so multi-host DSNs (including bracketed IPv6) are not collapsed by URL host normalization. Add ParseDSN and churl regression tests for the issue 1784 multi-host cases.
- Use stdlib net.SplitHostPort/net.JoinHostPort in splitHostList for per-host validation/normalization; document HA handling and Go 1.26 net/url tightening (churl as Go 1.25.7 copy plus raw-authority extraction). Clarify single cluster-wide Auth and query override. - Add CHANGELOG Unreleased entry describing fix. - Expand ParseDSN tests: rename from issue-number style to functional names, add multi-host cases for auth overridden via query, auth via query only, encoded passwords, IPv6 with auth, and 3-host preservation. - Expand host-list helper tests: rename, add auth-override case and additional splitHostList coverage. Fixes ClickHouse#1784
Root cause of IPv6 multi-host collapse and mixed-list parse errors was churl.parseHost anchoring on LastIndex of '['. Split authority on top-level commas and parse each host so dsn.Host stays complete and percent-decoding (zone IDs) still works. fromDSN now only splits the parsed host with stdlib SplitHostPort. Add mixed IPv6/plain + zone-ID ParseDSN cases, churl coverage, and a multi-host DSN failover integration test.
Document that HA DSN credentials apply to every peer (userinfo, query override, and post-ParseDSN Options.Auth mutation). Expand README DSN section for multi-host IPv6 lists and cluster-wide auth.
Document cluster-wide Auth for multi-host DSNs in the Go docs, and keep CHANGELOG Unreleased notes with upstream CRLF endings. Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
fromDSN already gets a comma-separated host list from churl.Parse. Split with strings.Split and normalize via SplitHostPort/JoinHostPort. Add TestMultiHostDSNAuthOverride for post-ParseDSN Options.Auth mutation. Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
ae9f6d5 to
29b5fc6
Compare
|
Rebased onto current main to clear the merge conflict. Stdlib SplitHostPort after churl.Parse, cluster-wide auth tests, and the failover integration tests are unchanged. |
Go 1.26 can reject or collapse comma-separated host lists. Multi-host DSNs are parsed as a single-host URL, then peers are restored with strings.Split and net.SplitHostPort. Auth remains cluster-wide. Drop the extra HA parser in lib/churl.parseHost.
|
@chernser HA DSN parsing now uses net/url.Parse plus strings.Split and net.SplitHostPort, without a custom authority parser in lib/churl. Multi-host lists that Go 1.26 rejects or collapses are recovered by parsing a single-host rewrite. Auth is cluster-wide (userinfo, query username/password, Options.Auth after ParseDSN). Docs and changelog updated. Unit tests cover auth/IPv6 on Go 1.25 and 1.26; failover tests remain in tests/conn_test.go. |
Use net/url.Parse as the primary path, then strings.Split and net.SplitHostPort. Rewrite to a single host only when Parse rejects or collapses the list (Go 1.26 urlstrictcolons, bracketed IPv6).
Summary
Fixes #1784
Hardens multi-host (HA) DSN address parsing so host lists stay intact on Go 1.26.
DSN parsing uses
net/url.Parse. When Go 1.26 rejects or collapses a comma-separated host list (http(s) withGODEBUG=urlstrictcolons, or bracketed IPv6 lists), a single-host rewrite is parsed and peers are restored withstrings.Splitandnet.SplitHostPort.username/passwordquery override, and post-ParseDSNOptions.Authmutation)Validation
go testfor ParseDSN / SplitHostList / MultiHostAuth / HTTP strict-colons (Go 1.25.6 and Go 1.26.7)TestMultiHostDSNFailoverandTestMultiHostDSNAuthOverride(existingtests/conn_test.gopattern; not run locally without ClickHouse)AI/LLM disclosure