1
0
mirror of https://github.com/redis/go-redis.git synced 2025-08-07 12:42:55 +03:00

Fix/pubsub ping mutex (#1878)

* Fix PubSub.Ping to hold the lock

* Fix PubSub.Ping to hold the lock

* add write cmd data-race test

Signed-off-by: monkey92t <golang@88.com>

Co-authored-by: monkey92t <golang@88.com>
This commit is contained in:
Vladimir Mihailenco
2021-09-03 12:57:34 +03:00
committed by GitHub
parent 917c476e75
commit b94bde306e
2 changed files with 20 additions and 2 deletions

View File

@@ -373,6 +373,18 @@ var _ = Describe("cluster races", func() {
Expect(err).NotTo(HaveOccurred())
Expect(val).To(Equal(int64(C * N)))
})
It("write cmd data-race", func() {
pubsub := client.Subscribe(ctx)
defer pubsub.Close()
pubsub.Channel(redis.WithChannelHealthCheckInterval(time.Millisecond))
for i := 0; i < 100; i++ {
key := fmt.Sprintf("channel_%d", i)
pubsub.Subscribe(ctx, key)
pubsub.Unsubscribe(ctx, key)
}
})
})
func bigVal() []byte {