Skip to content

Commit

Permalink
Merge pull request #1510 from PalanQu/fix-strategy
Browse files Browse the repository at this point in the history
fix ConnOpenRandom strategy, issue: #1509
  • Loading branch information
SpencerTorres authored Feb 26, 2025
2 parents 469d018 + f694fae commit c7e323f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ func (ch *clickhouse) dial(ctx context.Context) (conn *connect, err error) {
}

func DefaultDialStrategy(ctx context.Context, connID int, opt *Options, dial Dial) (r DialResult, err error) {
random := rand.Int()
for i := range opt.Addr {
var num int
switch opt.ConnOpenStrategy {
Expand All @@ -243,6 +242,7 @@ func DefaultDialStrategy(ctx context.Context, connID int, opt *Options, dial Dia
case ConnOpenRoundRobin:
num = (int(connID) + i) % len(opt.Addr)
case ConnOpenRandom:
random := rand.Int()
num = (random + i) % len(opt.Addr)
}

Expand Down

0 comments on commit c7e323f

Please sign in to comment.