Skip to content

Commit 3a8706b

Browse files
author
Runze Cui
committed
always attempt getConn to init the pool first so the following _withConn will have the valid conn to resolve hystrix
1 parent 51fcf37 commit 3a8706b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

redis.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,16 @@ func (c *baseClient) withConn(
365365
return err
366366
}
367367

368+
// always attempt getConn to init the pool first so the following _withConn will have the valid conn
369+
cn, connerr := c.getConn(ctx)
370+
if connerr != nil {
371+
return connerr
372+
}
373+
374+
defer func() {
375+
c.releaseConn(ctx, cn, connerr)
376+
}()
377+
368378
err := limiter.Execute(func() error {
369379
return c._withConn(ctx, fn)
370380
})

0 commit comments

Comments
 (0)