Skip to content

[ISSUE-3402]: Ring.Pipelined return dial timeout error #3403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,8 @@ func (c *Ring) generalProcessPipeline(
}

var wg sync.WaitGroup
errs := make(chan error, len(cmdsMap))

for hash, cmds := range cmdsMap {
wg.Add(1)
go func(hash string, cmds []Cmder) {
Expand All @@ -789,16 +791,23 @@ func (c *Ring) generalProcessPipeline(
return
}

hook := shard.Client.processPipelineHook
if tx {
cmds = wrapMultiExec(ctx, cmds)
_ = shard.Client.processTxPipelineHook(ctx, cmds)
} else {
_ = shard.Client.processPipelineHook(ctx, cmds)
cmds, hook = wrapMultiExec(ctx, cmds), shard.Client.processTxPipelineHook
Copy link
Preview

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The inline reassignment of both cmds and hook for the transaction pipeline branch might benefit from clearer separation or additional comments to improve code clarity between transactional and non-transactional pipelines.

Suggested change
cmds, hook = wrapMultiExec(ctx, cmds), shard.Client.processTxPipelineHook
// Modify cmds for transactional pipeline.
cmds = wrapMultiExec(ctx, cmds)
// Use the transactional pipeline hook.
hook = shard.Client.processTxPipelineHook

Copilot uses AI. Check for mistakes.

}

if err = hook(ctx, cmds); err != nil {
errs <- err
}
}(hash, cmds)
}

wg.Wait()
close(errs)

if err := <-errs; err != nil {
return err
}
return cmdsFirstErr(cmds)
}

Expand Down
15 changes: 15 additions & 0 deletions ring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,21 @@ var _ = Describe("Redis Ring", func() {
Expect(ringShard1.Info(ctx).Val()).ToNot(ContainSubstring("keys="))
Expect(ringShard2.Info(ctx).Val()).To(ContainSubstring("keys=100"))
})

It("return dial timeout error", func() {
opt := redisRingOptions()
opt.DialTimeout = 250 * time.Millisecond
opt.Addrs = map[string]string{"ringShardNotExist": ":1997"}
ring = redis.NewRing(opt)

_, err := ring.Pipelined(ctx, func(pipe redis.Pipeliner) error {
pipe.HSet(ctx, "key", "value")
pipe.Expire(ctx, "key", time.Minute)
return nil
})

Expect(err).To(HaveOccurred())
})
})

Describe("new client callback", func() {
Expand Down
Loading