Closed
Description
Issue tracker is used for reporting bugs and discussing new features. Please use
stackoverflow for supporting issues.
AddHook
API not pass race detector with config MinIdleConns > 0
in redis v9, which v8 works.
Expected Behavior
Redis v9 AddHook
API should pass race detector
Current Behavior
Redis v9 AddHook
API not pass race detector
Possible Solution
Steps to Reproduce
- create a test file
// v9.go
package main
import (
"github.com/redis/go-redis/v9"
)
func main() {
red := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
MinIdleConns: 1,
})
red.AddHook(noopHook{})
}
type noopHook struct{}
func (h noopHook) DialHook(next redis.DialHook) redis.DialHook {
return next
}
func (h noopHook) ProcessHook(next redis.ProcessHook) redis.ProcessHook {
return next
}
func (h noopHook) ProcessPipelineHook(next redis.ProcessPipelineHook) redis.ProcessPipelineHook {
return next
}
- run with
go run -race v9.go
, will panic - create v8 test file
package main
import (
"context"
"github.com/go-redis/redis/v8"
)
func main() {
red := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
MinIdleConns: 1,
})
red.AddHook(noopHook{})
}
type noopHook struct{}
func (h noopHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (context.Context, error) {
return ctx, nil
}
func (h noopHook) AfterProcess(ctx context.Context, cmd redis.Cmder) error {
return nil
}
func (h noopHook) BeforeProcessPipeline(ctx context.Context, cmds []redis.Cmder) (context.Context, error) {
return ctx, nil
}
func (h noopHook) AfterProcessPipeline(ctx context.Context, cmds []redis.Cmder) error {
return nil
}
- run with
go run -race v8.go
, it works
Context (Environment)
Detailed Description
Possible Implementation
Metadata
Metadata
Assignees
Labels
No labels