mirror of
https://github.com/redis/go-redis.git
synced 2025-07-18 00:20:57 +03:00
fix: Fixed issue with context cancelled error leading to connection spikes on Primary instances (#3190)
* fix: Fixed issue with context cancelled error leading to connection spikes on Master * fix: Added tests * fix: Updated tests --------- Co-authored-by: Bhargav Dodla <bdodla@expediagroup.com> Co-authored-by: Nedyalko Dyakov <nedyalko.dyakov@gmail.com>
This commit is contained in:
@ -539,6 +539,39 @@ var _ = Describe("ClusterClient", func() {
|
||||
AfterEach(func() {})
|
||||
|
||||
assertPipeline()
|
||||
|
||||
It("doesn't fail node with context.Canceled error", func() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
pipe.Set(ctx, "A", "A_value", 0)
|
||||
_, err := pipe.Exec(ctx)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(errors.Is(err, context.Canceled)).To(BeTrue())
|
||||
|
||||
clientNodes, _ := client.Nodes(ctx, "A")
|
||||
|
||||
for _, node := range clientNodes {
|
||||
Expect(node.Failing()).To(BeFalse())
|
||||
}
|
||||
})
|
||||
|
||||
It("doesn't fail node with context.DeadlineExceeded error", func() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Nanosecond)
|
||||
defer cancel()
|
||||
|
||||
pipe.Set(ctx, "A", "A_value", 0)
|
||||
_, err := pipe.Exec(ctx)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(errors.Is(err, context.DeadlineExceeded)).To(BeTrue())
|
||||
|
||||
clientNodes, _ := client.Nodes(ctx, "A")
|
||||
|
||||
for _, node := range clientNodes {
|
||||
Expect(node.Failing()).To(BeFalse())
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Describe("with TxPipeline", func() {
|
||||
|
Reference in New Issue
Block a user