-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Issue tracker is used for reporting bugs and discussing new features. Please use
stackoverflow for supporting issues.
When using redis-client 9.5.1 we have issue at ipv6 environment.
We have a kubernetes environment and we are using redis cluster.
In our application we first create a new redis client
client = redis.NewClusterClient(opt)
with address redisdb service name: xxx-crdb.test.svc.cluster.local.:6379
Then we are checking connection with
resp, err := c.redisClient.Ping(context.Background()).Result()
Ping is successful.
After that are are creating a consumer group:
c.redisClient.XGroupCreateMkStream(context.Background(), streamName, groupName, start).Err()
The later command fails with redis-client 9.5.1 with error:
dial tcp: address fd01:abcd::7d03:6379: too many colons in address.
We have many retries and it constantly fails.
With redis-client 9.3.0 it fails once and then it succeeds.
Activity
monkey92t commentedon Apr 18, 2024
Thank you for your feedback. go-redis has not been adapted for IPv6. Are you interested in submitting a PR?
panagiotspappas commentedon Apr 21, 2024
Hi, I have a question.
How come ping succeeds and the creation of group fails?
I mean, don't these two commands use/establish the same connection?
Is it possible to point to the differences between Ping and XGroupCreateMkStream, regarding to the connection?
monkey92t commentedon Apr 21, 2024
I'm not sure where the problem lies. In cluster mode, go-redis perceives all nodes within the cluster through the cluster slots command, using their IP addresses and ports to establish connections. However, I've checked all operations involving IP addresses, and they all use net.JoinHostPort(), which requires an IPv6 Redis cluster for testing.
monkey92t commentedon Apr 21, 2024
Can you print the result of cluster slots?
See: https://redis.io/docs/latest/commands/cluster-slots/
daviddzxy commentedon Apr 24, 2024
I also encountered this error. Seems like
moved, ask, addr = isMovedError(lastErr)
infunc (c *ClusterClient) process(ctx context.Context, cmd Cmder) error
function returns IPv6 in bad format. I will try to make PR with a fix.daviddzxy commentedon Apr 24, 2024
Here is the PR @monkey92t
monkey92t commentedon Apr 25, 2024
I currently do not have more devices to build an IPv6 cluster for testing. I am not sure about the data format of MOVE ADDR. If it looks like MOVE fd01:abcd::7d03:6379, then it is not a valid IPv6 format. However, after Redis fixes it, it may look like MOVE [fd01:abcd::7d03]:6379, which could cause compatibility issues.
monkey92t commentedon Apr 25, 2024
redis ipv6 issue redis/redis#6238
It looks like we can make some compatibility adjustments to handle both fd01:abcd::7d03:6379 and [fd01:abcd::7d03]:6379 types of IPv6 addresses properly. @daviddzxy, can you continue?
monkey92t commentedon Apr 25, 2024
Moreover, under normal circumstances, go-redis should not encounter MOVE. Before sending a command, go-redis calculates the node for the key and sends the Redis command to that node. This type of issue only occurs when Redis is reassigning slots, and it seems we triggered another bug that caused slot calculation errors.
daviddzxy commentedon Apr 25, 2024
Sure, I ll update the PR.
daviddzxy commentedon Apr 25, 2024
I updated the PR. @monkey92t
daviddzxy commentedon Apr 26, 2024
I have done some more debugging. It turns out that when
XGroupCreateMkStream
function is called thefunc cmdFirstKeyPos(cmd Cmder) int
function returns wrong pos number (It returns 1 instead of 2). As a result of this, the functionfunc Slot(key string) int
will receive "create" key argument. This causes incorrectly calculated slot number and therefore we get MOVED error. @monkey92tdaviddzxy commentedon Apr 26, 2024
Should I create another issue for this bug? I plan to make a PR with a fix later today.
monkey92t commentedon Apr 26, 2024
OK!
5 remaining items