Migrate math/rand to math/rand/v2#1810
Open
antonio-mello-ai wants to merge 1 commit into
Open
Conversation
Go 1.25 broke rand.Seed() from math/rand v1, which caused several connection failover tests to be skipped. This migrates the entire codebase to math/rand/v2, which is auto-seeded and concurrency-safe. Key changes: - All rand.Seed() and rand.NewSource() calls removed (v2 auto-seeds) - rand.Intn(n) → rand.IntN(n), rand.Int63() → rand.Int64() - Connection failover: random offset now computed once before the loop instead of on every iteration, ensuring all hosts are tried exactly once in a random-start round-robin order - Three skipped tests re-enabled (conn_test, std/conn_test, main_test) Closes ClickHouse#1653 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Author
|
Hi @kavirajk — this is my first contribution here, so the CI workflow may need a maintainer to approve the run. The CLA is signed and all changes are covered by existing tests. Could you take a look when you get a chance? Happy to address any feedback. |
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
Migrates the entire codebase from
math/randtomath/rand/v2, fixing the Go 1.25rand.Seed()breakage and re-enabling three skipped tests.Closes #1653
Changes
Core (connection failover fix):
clickhouse.go,clickhouse_std.go— Random host offset is now computed once before the loop instead of on every iteration. This ensures all hosts are tried exactly once in a random-start round-robin order, fixing the issue described in Upgrade tomath/rand/v2#1653 where duplicate addresses could be picked while others were skipped.Codebase-wide migration (20 files):
rand.Seed()andrand.NewSource()calls removed —math/rand/v2is auto-seeded and concurrency-saferand.Intn(n)→rand.IntN(n),rand.Int63()→rand.Int64()ResetRandSeed()helpers andrandSeedvariablesChecklist
Generative AI disclosure: This PR was co-authored with Claude (Anthropic).