summaryrefslogtreecommitdiff
path: root/src/cluster.h
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2015-03-24 11:07:10 +0100
committerantirez <antirez@gmail.com>2015-03-24 11:56:24 +0100
commit9b7f8b1c9b379ab842d40df4636dfbbeb6376fcb (patch)
tree363f417f8d54bed9f9c3a6a6adeda4f3c047f6a9 /src/cluster.h
parenteff68bd656e09b33b1edc6ff927c2cf06978a503 (diff)
downloadredis-9b7f8b1c9b379ab842d40df4636dfbbeb6376fcb.tar.gz
Cluster: redirection refactoring + handling of blocked clients.
There was a bug in Redis Cluster caused by clients blocked in a blocking list pop operation, for keys no longer handled by the instance, or in a condition where the cluster became down after the client blocked. A typical situation is: 1) BLPOP <somekey> 0 2) <somekey> hash slot is resharded to another master. The client will block forever int this case. A symmentrical non-cluster-specific bug happens when an instance is turned from master to slave. In that case it is more serious since this will desynchronize data between slaves and masters. This other bug was discovered as a side effect of thinking about the bug explained and fixed in this commit, but will be fixed in a separated commit.
Diffstat (limited to 'src/cluster.h')
-rw-r--r--src/cluster.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/cluster.h b/src/cluster.h
index 8eaa0ab98..bf442a222 100644
--- a/src/cluster.h
+++ b/src/cluster.h
@@ -26,11 +26,12 @@
/* Redirection errors returned by getNodeByQuery(). */
#define REDIS_CLUSTER_REDIR_NONE 0 /* Node can serve the request. */
-#define REDIS_CLUSTER_REDIR_CROSS_SLOT 1 /* Keys in different slots. */
-#define REDIS_CLUSTER_REDIR_UNSTABLE 2 /* Keys in slot resharding. */
+#define REDIS_CLUSTER_REDIR_CROSS_SLOT 1 /* -CROSSSLOT request. */
+#define REDIS_CLUSTER_REDIR_UNSTABLE 2 /* -TRYAGAIN redirection required */
#define REDIS_CLUSTER_REDIR_ASK 3 /* -ASK redirection required. */
#define REDIS_CLUSTER_REDIR_MOVED 4 /* -MOVED redirection required. */
-#define REDIS_CLUSTER_REDIR_DOWN 5 /* -CLUSTERDOWN error. */
+#define REDIS_CLUSTER_REDIR_DOWN_STATE 5 /* -CLUSTERDOWN, global state. */
+#define REDIS_CLUSTER_REDIR_DOWN_UNBOUND 6 /* -CLUSTERDOWN, unbound slot. */
struct clusterNode;
@@ -249,5 +250,7 @@ typedef struct {
/* ---------------------- API exported outside cluster.c -------------------- */
clusterNode *getNodeByQuery(redisClient *c, struct redisCommand *cmd, robj **argv, int argc, int *hashslot, int *ask);
+int clusterRedirectBlockedClientIfNeeded(redisClient *c);
+void clusterRedirectClient(redisClient *c, clusterNode *n, int hashslot, int error_code);
#endif /* __REDIS_CLUSTER_H */