Comments (6)
Many thanks, Martin!
from redisc.
Hello,
It does handle cluster failover, it is a full implementation of the redis cluster spec for a client (https://redis.io/topics/cluster-spec). There is no option to be notified when a failover occurs, AFAIK there is no such option in redis (the only thing I found was this slightly unsatisfying stack overflow answer: https://stackoverflow.com/questions/36449254/how-to-get-notifications-about-failovers-in-redis-cluster-to-the-client-applicat).
Hope this helps,
Martin
from redisc.
I keep set of persistent connections and faced up with case when 2 nodes made failover. So one of connections become connection to r/o slave node. It looks like I need to make separate watchdog goroutine based on ROLE command.
from redisc.
Yeah possibly, this is redis behaviour in play. Is there anything else specific to redisc
you'd want to raise or discuss? Otherwise we can close the issue.
from redisc.
I see ReadOnly() method in redisc/conn.go file. if I add new one:
func (c *Conn) IsReadOnly() bool {
c.mu.Lock()
defer c.mu.Unlock()
return c.readOnly
}
- will it answer "true" in this case, when connected node become slave?
from redisc.
No, the ReadOnly()
method is used to indicate that a connection to a replica should be preferred, as data will only be read (https://pkg.go.dev/github.com/mna/redisc#Conn.ReadOnly). This results in execution of the READONLY
redis command after connection, so that the replica agrees to serve commands (otherwise it would always redirect to the primary node - https://redis.io/commands/readonly).
As you mentioned earlier, the proper way to check if the connected node is a replica is to execute the ROLE
command at the place and time when you need that information.
If you want to monitor failover, the idea of running a dedicated connection to each node involved and checking the ROLE at some interval seems like a good option (though I think that would only be for primary-replica failover, not cluster participation). There may be better ways using the CLUSTER ...
suite of commands, depending on how accurate you want the reports to be. For example, you could probably use a single connection to a random node to the cluster and call CLUSTER NODES
and check the flags for failure stats and primary/replica state (https://redis.io/commands/cluster-nodes).
from redisc.
Related Issues (20)
- Send PSUBSCRIBE failed HOT 1
- concurrent map iteration and map write HOT 3
- Refresh failed: redisc: all nodes failed HOT 2
- Connection failes if cluster consists only from one master HOT 5
- Separate pool for masters and slaves? HOT 9
- is HMSET operation supported, when using redis clustermode enabled? HOT 1
- Does it support pipeline in cluster mode HOT 5
- High Connection Churn HOT 25
- Pls Help HOT 1
- Add support for Pipeline and multi operation commands HOT 5
- Proposal: add `Cluster` method to wait for stable Redis cluster HOT 1
- Proposal: add `Cluster` method to split keys by nodes
- Proposal: relax the constraints on pipeline for the `RetryConn`
- Proposal: support Redis 7+ Cluster changes
- READONLY command on every requests HOT 3
- Proposal: improve handling of read-only connections HOT 3
- Does it support redis module command? HOT 2
- Support address mapping for nodes HOT 7
- Can redisc recover from master-slave node failover? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redisc.