Skip to content

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

Closed
@singular-seal

Description

@singular-seal

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions