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

Client side failover failed due to getting not existing key #2959

Closed
singular-seal opened this issue Apr 4, 2024 · 0 comments
Closed

Client side failover failed due to getting not existing key #2959

singular-seal opened this issue Apr 4, 2024 · 0 comments

Comments

@singular-seal
Copy link
Contributor

I setup a redis cluster with 2 nodes(1 master and 1 slave) and tried to test go-redis client side behaviour using the code below

func ConnectRedisTarget() *ClusterClient {
	return NewClusterClient(&ClusterOptions{
		Addrs: []string{
			"127.0.0.1:6666",
		},
		ReadOnly: true,
	})
}

func TestOne(t *testing.T) {
	c := ConnectRedisTarget()
	ctx := context.Background()
	for i := 0; i < 100; i++ {
		p := c.Pipeline()
		p.Get(ctx, "c")
		cs, err := p.Exec(ctx)
		if err != nil {
			fmt.Println("err from c " + fmt.Sprint(err))
		} else {
			for _, cmder := range cs {
				fmt.Println(cmder.String())
			}
		}
		p.Get(ctx, "a")
		cs, err = p.Exec(ctx)
		if err != nil {
			fmt.Println("err from a " + fmt.Sprint(err))
			fmt.Println(err)
		} else {
			for _, cmder := range cs {
				fmt.Println(cmder.String())
			}
		}
		time.Sleep(time.Second * 5)
	}
}

The key 'a' is in redis and 'c' is not in redis.

Expected Behavior

It always prints

err from c redis: nil
get a: 1

Current Behavior

It prints

err from c dial tcp 127.0.0.1:6666: connect: connection refused
err from a dial tcp 127.0.0.1:6666: connect: connection refused
dial tcp 127.0.0.1:6666: connect: connection refused

after I shutdown the master node

Possible Solution

Don't mark node as failing when error Nil happens.

Steps to Reproduce

  1. Setup a redis cluster with one master and one slave and run 'set a=1' to set value for key 'a'
  2. Run the testing code and it will print the expected messages
  3. Shutdown the master node
  4. You can see the error message now

Context (Environment)

Detailed Description

Possible Implementation

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

No branches or pull requests

2 participants