Skip to content

Commit 228d4e5

Browse files
Merge branch 'ndyakov/CAE-1242-e2e-hitless' of github.com:redis/go-redis into ndyakov/CAE-1242-e2e-hitless
2 parents 9812d7d + 41c78a8 commit 228d4e5

File tree

4 files changed

+42
-6
lines changed

4 files changed

+42
-6
lines changed

.github/workflows/spellcheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
- name: Checkout
99
uses: actions/checkout@v5
1010
- name: Check Spelling
11-
uses: rojopolis/spellcheck-github-actions@0.51.0
11+
uses: rojopolis/spellcheck-github-actions@0.52.0
1212
with:
1313
config_path: .github/spellcheck-settings.yml
1414
task_name: Markdown

hash_commands.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,16 @@ func (c cmdable) HMGet(ctx context.Context, key string, fields ...string) *Slice
116116

117117
// HSet accepts values in following formats:
118118
//
119-
// - HSet("myhash", "key1", "value1", "key2", "value2")
119+
// - HSet(ctx, "myhash", "key1", "value1", "key2", "value2")
120120
//
121-
// - HSet("myhash", []string{"key1", "value1", "key2", "value2"})
121+
// - HSet(ctx, "myhash", []string{"key1", "value1", "key2", "value2"})
122122
//
123-
// - HSet("myhash", map[string]interface{}{"key1": "value1", "key2": "value2"})
123+
// - HSet(ctx, "myhash", map[string]interface{}{"key1": "value1", "key2": "value2"})
124124
//
125125
// Playing struct With "redis" tag.
126126
// type MyHash struct { Key1 string `redis:"key1"`; Key2 int `redis:"key2"` }
127127
//
128-
// - HSet("myhash", MyHash{"value1", "value2"}) Warn: redis-server >= 4.0
128+
// - HSet(ctx, "myhash", MyHash{"value1", "value2"}) Warn: redis-server >= 4.0
129129
//
130130
// For struct, can be a structure pointer type, we only parse the field whose tag is redis.
131131
// if you don't want the field to be read, you can use the `redis:"-"` flag to ignore it,

pipeline_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,39 @@ var _ = Describe("pipelining", func() {
6060
Expect(cmds).To(BeEmpty())
6161
})
6262

63+
It("pipeline: basic exec", func() {
64+
p := client.Pipeline()
65+
p.Get(ctx, "key")
66+
p.Set(ctx, "key", "value", 0)
67+
p.Get(ctx, "key")
68+
cmds, err := p.Exec(ctx)
69+
Expect(err).To(Equal(redis.Nil))
70+
Expect(cmds).To(HaveLen(3))
71+
Expect(cmds[0].Err()).To(Equal(redis.Nil))
72+
Expect(cmds[1].(*redis.StatusCmd).Val()).To(Equal("OK"))
73+
Expect(cmds[1].Err()).NotTo(HaveOccurred())
74+
Expect(cmds[2].(*redis.StringCmd).Val()).To(Equal("value"))
75+
Expect(cmds[2].Err()).NotTo(HaveOccurred())
76+
})
77+
78+
It("pipeline: exec pipeline when get conn failed", func() {
79+
p := client.Pipeline()
80+
p.Get(ctx, "key")
81+
p.Set(ctx, "key", "value", 0)
82+
p.Get(ctx, "key")
83+
84+
client.Close()
85+
86+
cmds, err := p.Exec(ctx)
87+
Expect(err).To(Equal(redis.ErrClosed))
88+
Expect(cmds).To(HaveLen(3))
89+
for _, cmd := range cmds {
90+
Expect(cmd.Err()).To(Equal(redis.ErrClosed))
91+
}
92+
93+
client = redis.NewClient(redisOptions())
94+
})
95+
6396
assertPipeline := func() {
6497
It("returns no errors when there are no commands", func() {
6598
_, err := pipe.Exec(ctx)

redis.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,10 @@ func (c *baseClient) generalProcessPipeline(
773773
return err
774774
})
775775
if lastErr == nil || !canRetry || !shouldRetry(lastErr, true) {
776-
setCmdsErr(cmds, lastErr)
776+
// The error should be set here only when failing to obtain the conn.
777+
if !isRedisError(lastErr) {
778+
setCmdsErr(cmds, lastErr)
779+
}
777780
return lastErr
778781
}
779782
}

0 commit comments

Comments
 (0)