Skip to content
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

Race detector checking failed for AddHook API in redis v9 #2557

Closed
zcong1993 opened this issue Apr 24, 2023 · 4 comments · May be fixed by #2752
Closed

Race detector checking failed for AddHook API in redis v9 #2557

zcong1993 opened this issue Apr 24, 2023 · 4 comments · May be fixed by #2752

Comments

@zcong1993
Copy link

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

  1. 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
}
  1. run with go run -race v9.go, will panic
  2. 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
}
  1. run with go run -race v8.go, it works

Context (Environment)

Detailed Description

Possible Implementation

@monkey92t
Copy link
Collaborator

Yes, there is a conflict between the MinIdleConns configuration option and DialHook.

@zcong1993
Copy link
Author

Yes, there is a conflict between the MinIdleConns configuration option and DialHook.

Any updates for this?

@M-MoMoMo
Copy link

是的,MinIdleConns 配置选项和 DialHook 之间存在冲突。

Any updates for this?

@zcong1993
Copy link
Author

closed, #2814

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants