redis / go-redis

Redis Go client
https://redis.uptrace.dev
BSD 2-Clause "Simplified" License
19.61k stars 2.31k forks source link

Sentinel with PubSub deadlocks on Close #2943

Open danilobuerger opened 3 months ago

danilobuerger commented 3 months ago

When using the FailoverClient (Sentinel) with PubSub, calling Close will deadlock.

Expected Behavior

Close will close the PubSub and return.

Current Behavior

Close does not return.

Steps to Reproduce

func main() {
    client := redis.NewFailoverClient(&redis.FailoverOptions{
        MasterName:    "...",
        SentinelAddrs: []string{"..."},
    })

    pubSub := client.Subscribe(context.Background())
    pubSub.Channel()
    time.Sleep(1 * time.Second)
    log.Println("Subscribed")

    pubSub.Close()
    log.Println("Closed")
}

Version: 9.5.1