1
0
mirror of https://github.com/redis/go-redis.git synced 2025-06-15 12:41:41 +03:00

Fixes #1386; pipeline.Exec() sometimes returns spurious StatusCmd

This is caused by function `wrapMultiExec` sometimes clobbering the caller's
cmd slice, corrupting future requests.
This commit is contained in:
Scott Parkerson
2020-09-17 10:35:34 -04:00
parent 2eb40d83aa
commit 26a6d4714c
2 changed files with 22 additions and 5 deletions

View File

@ -1,6 +1,8 @@
package redis_test
import (
"strconv"
"github.com/go-redis/redis/v8"
. "github.com/onsi/ginkgo"
@ -67,6 +69,21 @@ var _ = Describe("pipelining", func() {
Expect(err).NotTo(HaveOccurred())
Expect(cmds).To(HaveLen(1))
})
It("handles large pipelines", func() {
for callCount := 1; callCount < 16; callCount++ {
for i := 1; i <= callCount; i++ {
pipe.SetNX(ctx, strconv.Itoa(i)+"_key", strconv.Itoa(i)+"_value", 0)
}
cmds, err := pipe.Exec(ctx)
Expect(err).NotTo(HaveOccurred())
Expect(cmds).To(HaveLen(callCount))
for _, cmd := range cmds {
Expect(cmd).To(BeAssignableToTypeOf(&redis.BoolCmd{}))
}
}
})
}
Describe("Pipeline", func() {