Skip to content

Commit

Permalink
Fix "invalid argument to Intn"
Browse files Browse the repository at this point in the history
Signed-off-by: Bin Shi <[email protected]>
  • Loading branch information
binshi-bing committed Apr 19, 2023
1 parent fb0cf06 commit a5c61ff
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion client/tso_service_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,9 @@ func (c *tsoServiceDiscovery) getTSOServer() (string, error) {

// Pick a TSO server in a round-robin way.
len := len(c.tsoServerDiscovery.addrs)
c.tsoServerDiscovery.selectIdx++
tsoServerAddr := c.tsoServerDiscovery.addrs[rand.Intn(c.tsoServerDiscovery.selectIdx)]
c.tsoServerDiscovery.selectIdx = (c.tsoServerDiscovery.selectIdx + 1) % len
c.tsoServerDiscovery.selectIdx %= len
if _, err := c.GetOrCreateGRPCConn(tsoServerAddr); err != nil {
log.Warn("[tso] failed to connect the tso server",
zap.String("tso-server", tsoServerAddr), errs.ZapError(err))
Expand Down

0 comments on commit a5c61ff

Please sign in to comment.