Skip to content

Commit f0df920

Browse files
committed
Merge remote-tracking branch 'upstream/master' into fix-otel
2 parents 2016d55 + a17250d commit f0df920

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

.golangci.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
run:
2-
concurrency: 8
3-
deadline: 5m
2+
timeout: 5m
43
tests: false

redis.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ type (
4141
)
4242

4343
type hooksMixin struct {
44-
hooksMu *sync.Mutex
44+
hooksMu *sync.RWMutex
4545

4646
slice []Hook
4747
initial hooks
4848
current hooks
4949
}
5050

5151
func (hs *hooksMixin) initHooks(hooks hooks) {
52-
hs.hooksMu = new(sync.Mutex)
52+
hs.hooksMu = new(sync.RWMutex)
5353
hs.initial = hooks
5454
hs.chain()
5555
}
@@ -151,7 +151,7 @@ func (hs *hooksMixin) clone() hooksMixin {
151151
clone := *hs
152152
l := len(clone.slice)
153153
clone.slice = clone.slice[:l:l]
154-
clone.hooksMu = new(sync.Mutex)
154+
clone.hooksMu = new(sync.RWMutex)
155155
return clone
156156
}
157157

@@ -176,7 +176,14 @@ func (hs *hooksMixin) withProcessPipelineHook(
176176
}
177177

178178
func (hs *hooksMixin) dialHook(ctx context.Context, network, addr string) (net.Conn, error) {
179-
return hs.current.dial(ctx, network, addr)
179+
// Access to hs.current is guarded by a read-only lock since it may be mutated by AddHook(...)
180+
// while this dialer is concurrently accessed by the background connection pool population
181+
// routine when MinIdleConns > 0.
182+
hs.hooksMu.RLock()
183+
current := hs.current
184+
hs.hooksMu.RUnlock()
185+
186+
return current.dial(ctx, network, addr)
180187
}
181188

182189
func (hs *hooksMixin) processHook(ctx context.Context, cmd Cmder) error {

search_commands.go

+4-10
Original file line numberDiff line numberDiff line change
@@ -574,11 +574,8 @@ func FTAggregateQuery(query string, options *FTAggregateOptions) AggregateQuery
574574
if options.SortByMax > 0 {
575575
queryArgs = append(queryArgs, "MAX", options.SortByMax)
576576
}
577-
if options.LimitOffset > 0 {
578-
queryArgs = append(queryArgs, "LIMIT", options.LimitOffset)
579-
}
580-
if options.Limit > 0 {
581-
queryArgs = append(queryArgs, options.Limit)
577+
if options.LimitOffset >= 0 && options.Limit > 0 {
578+
queryArgs = append(queryArgs, "LIMIT", options.LimitOffset, options.Limit)
582579
}
583580
if options.Filter != "" {
584581
queryArgs = append(queryArgs, "FILTER", options.Filter)
@@ -773,11 +770,8 @@ func (c cmdable) FTAggregateWithArgs(ctx context.Context, index string, query st
773770
if options.SortByMax > 0 {
774771
args = append(args, "MAX", options.SortByMax)
775772
}
776-
if options.LimitOffset > 0 {
777-
args = append(args, "LIMIT", options.LimitOffset)
778-
}
779-
if options.Limit > 0 {
780-
args = append(args, options.Limit)
773+
if options.LimitOffset >= 0 && options.Limit > 0 {
774+
args = append(args, "LIMIT", options.LimitOffset, options.Limit)
781775
}
782776
if options.Filter != "" {
783777
args = append(args, "FILTER", options.Filter)

search_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,11 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() {
616616
res, err = client.FTAggregateWithArgs(ctx, "idx1", "*", options).Result()
617617
Expect(err).NotTo(HaveOccurred())
618618
Expect(res.Rows[0].Fields["t1"]).To(BeEquivalentTo("b"))
619+
620+
options = &redis.FTAggregateOptions{SortBy: []redis.FTAggregateSortBy{{FieldName: "@t1"}}, Limit: 1, LimitOffset: 0}
621+
res, err = client.FTAggregateWithArgs(ctx, "idx1", "*", options).Result()
622+
Expect(err).NotTo(HaveOccurred())
623+
Expect(res.Rows[0].Fields["t1"]).To(BeEquivalentTo("a"))
619624
})
620625

621626
It("should FTAggregate load ", Label("search", "ftaggregate"), func() {

0 commit comments

Comments
 (0)