You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Redis or Redis GO does not go well with Clustered PUBSUB of Redis
Expected Behavior
Redis GO works even when using the same PUBSUB pointer to subscribe to other channels later on.
Current Behavior
Redis GO does SSubscribe, but then if u do one later one let's say in a goroutine. It says MOVED to another IP or PORT. And doesn't receive the messages at all, afterwards.
Possible Solution
Keep track of shards where what comes from. Fred from Redis RS provides a way to see what shard channel a server was bound to. Per message u'd receive, you could see which server it was hooked too, if I am not wrong.
package main
import (
"context""log""time""github.com/redis/go-redis/v9"
)
funcmain() {
client:=redis.NewClusterClient(&redis.ClusterOptions{
Addrs: []string{"masked:7000"},
})
client_2:=redis.NewClusterClient(&redis.ClusterOptions{
Addrs: []string{"masked:7000"},
})
pubsub:=client.SSubscribe(context.Background(), "mychannel")
deferpubsub.Close()
gofunc() {
// Subscribe to a channeltime.Sleep(2*time.Second)
iferr:=pubsub.SSubscribe(context.Background(), "mychannel2"); err!=nil {
panic(err)
}
log.Println("Subscribed to mychannel2")
}()
gofunc() {
ticker:=time.NewTicker(1*time.Second)
forrangeticker.C {
// Channel 2 does not work when ssubscribing laterclient_2.SPublish(context.Background(), "mychannel2", "hello")
// Does work since we subscribed when we started the programclient.SPublish(context.Background(), "mychannel", "hello")
}
}()
for {
msg, err:=pubsub.ReceiveMessage(context.Background())
iferr!=nil {
log.Println("ERROR", err)
continue
}
log.Println(msg.Channel, msg.Payload)
}
}
All you need is a Redis Cluster and use SSUBSCRIBE and have it move across redis nodes to replicate this issue. I have tried several cluster setups correctly, but keep running into this issue. I assume IOREDIS from Node.JS has this exact same issue. The only that works is Fred from Redis which I actively use.
Context (Environment)
4 servers: Each has 3 master coupled with slave to each master. Granting 12 masters coupled with 12 slaves.
Each server is compiled with Redis:
Redis server v=7.2.5 sha=00000000:0 malloc=jemalloc-5.3.0 bits=64 build=b5c2f37750637637
Making Redis PUBSUB work correctly, without having to deal with weird issues like moving and it goes out of scope
Redis Clustered PUBSUB doesn't work after subscribing later on.
The text was updated successfully, but these errors were encountered:
Redis or Redis GO does not go well with Clustered PUBSUB of Redis
Expected Behavior
Redis GO works even when using the same PUBSUB pointer to subscribe to other channels later on.
Current Behavior
Redis GO does SSubscribe, but then if u do one later one let's say in a goroutine. It says MOVED to another IP or PORT. And doesn't receive the messages at all, afterwards.
Possible Solution
Keep track of shards where what comes from. Fred from Redis RS provides a way to see what shard channel a server was bound to. Per message u'd receive, you could see which server it was hooked too, if I am not wrong.
FRED RS
Steps to Reproduce
Output log:
All you need is a Redis Cluster and use SSUBSCRIBE and have it move across redis nodes to replicate this issue. I have tried several cluster setups correctly, but keep running into this issue. I assume IOREDIS from Node.JS has this exact same issue. The only that works is Fred from Redis which I actively use.
Context (Environment)
4 servers: Each has 3 master coupled with slave to each master. Granting 12 masters coupled with 12 slaves.
Each server is compiled with Redis:
Making Redis PUBSUB work correctly, without having to deal with weird issues like moving and it goes out of scope
Redis Clustered PUBSUB doesn't work after subscribing later on.
The text was updated successfully, but these errors were encountered: