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

fix: handle panic in ringShards Hash function when Ring got closed

Fixes #2126
This commit is contained in:
Max Riveiro
2022-07-13 18:09:42 +03:00
parent 092a692384
commit a80b84f01f
2 changed files with 27 additions and 14 deletions

View File

@ -114,6 +114,21 @@ var _ = Describe("Redis Ring", func() {
})
Describe("pipeline", func() {
It("doesn't panic closed ring, returns error", func() {
pipe := ring.Pipeline()
for i := 0; i < 3; i++ {
err := pipe.Set(ctx, fmt.Sprintf("key%d", i), "value", 0).Err()
Expect(err).NotTo(HaveOccurred())
}
Expect(ring.Close()).NotTo(HaveOccurred())
Expect(func() {
_, execErr := pipe.Exec(ctx)
Expect(execErr).To(HaveOccurred())
}).NotTo(Panic())
})
It("distributes keys", func() {
pipe := ring.Pipeline()
for i := 0; i < 100; i++ {