mirror of
https://github.com/redis/go-redis.git
synced 2025-12-03 18:31:14 +03:00
better timeouts
This commit is contained in:
4
redis.go
4
redis.go
@@ -394,8 +394,8 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
|
||||
if finalState == pool.StateInitializing {
|
||||
// Another goroutine is initializing - WAIT for it to complete
|
||||
// Use AwaitAndTransition to wait for IDLE or IN_USE state
|
||||
// Add 1ms timeout to prevent indefinite blocking
|
||||
waitCtx, cancel := context.WithTimeout(ctx, time.Millisecond)
|
||||
// use DialTimeout as the timeout for the wait
|
||||
waitCtx, cancel := context.WithTimeout(ctx, c.opt.DialTimeout)
|
||||
defer cancel()
|
||||
|
||||
finalState, err := cn.GetStateMachine().AwaitAndTransition(
|
||||
|
||||
Reference in New Issue
Block a user