Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
290f3764
Commit
290f3764
authored
Nov 09, 2023
by
Josh Hershberg
Browse files
Cluster refactor: fn renames + small compilation issue on ubuntu
Signed-off-by:
Josh Hershberg
<
yehoshua@redis.com
>
parent
13b75485
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/cluster.c
View file @
290f3764
...
@@ -812,7 +812,7 @@ void clusterCommandHelp(client *c) {
...
@@ -812,7 +812,7 @@ void clusterCommandHelp(client *c) {
NULL
NULL
};
};
addExtendedReplyHelp
(
c
,
help
,
clusterCommand
Special
Help
());
addExtendedReplyHelp
(
c
,
help
,
clusterCommand
Extended
Help
());
}
}
void
clusterCommand
(
client
*
c
)
{
void
clusterCommand
(
client
*
c
)
{
...
@@ -911,9 +911,9 @@ void clusterCommand(client *c) {
...
@@ -911,9 +911,9 @@ void clusterCommand(client *c) {
}
}
/* Report TLS ports to TLS client, and report non-TLS port to non-TLS client. */
/* Report TLS ports to TLS client, and report non-TLS port to non-TLS client. */
addReplyArrayLen
(
c
,
get
NumSlaves
(
n
));
addReplyArrayLen
(
c
,
clusterNode
NumSlaves
(
n
));
for
(
j
=
0
;
j
<
get
NumSlaves
(
n
);
j
++
)
{
for
(
j
=
0
;
j
<
clusterNode
NumSlaves
(
n
);
j
++
)
{
sds
ni
=
clusterGenNodeDescription
(
c
,
g
etSlave
(
n
,
j
),
shouldReturnTlsInfo
());
sds
ni
=
clusterGenNodeDescription
(
c
,
clusterNodeG
etSlave
(
n
,
j
),
shouldReturnTlsInfo
());
addReplyBulkCString
(
c
,
ni
);
addReplyBulkCString
(
c
,
ni
);
sdsfree
(
ni
);
sdsfree
(
ni
);
}
}
...
@@ -1193,11 +1193,11 @@ void clusterRedirectClient(client *c, clusterNode *n, int hashslot, int error_co
...
@@ -1193,11 +1193,11 @@ void clusterRedirectClient(client *c, clusterNode *n, int hashslot, int error_co
error_code
==
CLUSTER_REDIR_ASK
)
error_code
==
CLUSTER_REDIR_ASK
)
{
{
/* Report TLS ports to TLS client, and report non-TLS port to non-TLS client. */
/* Report TLS ports to TLS client, and report non-TLS port to non-TLS client. */
int
port
=
get
NodeClientPort
(
n
,
shouldReturnTlsInfo
());
int
port
=
cluster
NodeClientPort
(
n
,
shouldReturnTlsInfo
());
addReplyErrorSds
(
c
,
sdscatprintf
(
sdsempty
(),
addReplyErrorSds
(
c
,
sdscatprintf
(
sdsempty
(),
"-%s %d %s:%d"
,
"-%s %d %s:%d"
,
(
error_code
==
CLUSTER_REDIR_ASK
)
?
"ASK"
:
"MOVED"
,
(
error_code
==
CLUSTER_REDIR_ASK
)
?
"ASK"
:
"MOVED"
,
hashslot
,
get
PreferredEndpoint
(
n
),
port
));
hashslot
,
clusterNode
PreferredEndpoint
(
n
),
port
));
}
else
{
}
else
{
serverPanic
(
"getNodeByQuery() unknown error."
);
serverPanic
(
"getNodeByQuery() unknown error."
);
}
}
...
@@ -1285,7 +1285,7 @@ static int isReplicaAvailable(clusterNode *node) {
...
@@ -1285,7 +1285,7 @@ static int isReplicaAvailable(clusterNode *node) {
if
(
clusterNodeIsFailing
(
node
))
{
if
(
clusterNodeIsFailing
(
node
))
{
return
0
;
return
0
;
}
}
long
long
repl_offset
=
get
ReplOffset
(
node
);
long
long
repl_offset
=
clusterNode
ReplOffset
(
node
);
if
(
clusterNodeIsMyself
(
node
))
{
if
(
clusterNodeIsMyself
(
node
))
{
/* Nodes do not update their own information
/* Nodes do not update their own information
* in the cluster node list. */
* in the cluster node list. */
...
@@ -1312,7 +1312,7 @@ void addNodeToNodeReply(client *c, clusterNode *node) {
...
@@ -1312,7 +1312,7 @@ void addNodeToNodeReply(client *c, clusterNode *node) {
}
}
/* Report TLS ports to TLS client, and report non-TLS port to non-TLS client. */
/* Report TLS ports to TLS client, and report non-TLS port to non-TLS client. */
addReplyLongLong
(
c
,
get
NodeClientPort
(
node
,
shouldReturnTlsInfo
()));
addReplyLongLong
(
c
,
cluster
NodeClientPort
(
node
,
shouldReturnTlsInfo
()));
addReplyBulkCBuffer
(
c
,
clusterNodeGetName
(
node
),
CLUSTER_NAMELEN
);
addReplyBulkCBuffer
(
c
,
clusterNodeGetName
(
node
),
CLUSTER_NAMELEN
);
/* Add the additional endpoint information, this is all the known networking information
/* Add the additional endpoint information, this is all the known networking information
...
@@ -1347,8 +1347,8 @@ void addNodeToNodeReply(client *c, clusterNode *node) {
...
@@ -1347,8 +1347,8 @@ void addNodeToNodeReply(client *c, clusterNode *node) {
void
addNodeReplyForClusterSlot
(
client
*
c
,
clusterNode
*
node
,
int
start_slot
,
int
end_slot
)
{
void
addNodeReplyForClusterSlot
(
client
*
c
,
clusterNode
*
node
,
int
start_slot
,
int
end_slot
)
{
int
i
,
nested_elements
=
3
;
/* slots (2) + master addr (1) */
int
i
,
nested_elements
=
3
;
/* slots (2) + master addr (1) */
for
(
i
=
0
;
i
<
get
NumSlaves
(
node
);
i
++
)
{
for
(
i
=
0
;
i
<
clusterNode
NumSlaves
(
node
);
i
++
)
{
if
(
!
isReplicaAvailable
(
g
etSlave
(
node
,
i
)))
continue
;
if
(
!
isReplicaAvailable
(
clusterNodeG
etSlave
(
node
,
i
)))
continue
;
nested_elements
++
;
nested_elements
++
;
}
}
addReplyArrayLen
(
c
,
nested_elements
);
addReplyArrayLen
(
c
,
nested_elements
);
...
@@ -1357,11 +1357,11 @@ void addNodeReplyForClusterSlot(client *c, clusterNode *node, int start_slot, in
...
@@ -1357,11 +1357,11 @@ void addNodeReplyForClusterSlot(client *c, clusterNode *node, int start_slot, in
addNodeToNodeReply
(
c
,
node
);
addNodeToNodeReply
(
c
,
node
);
/* Remaining nodes in reply are replicas for slot range */
/* Remaining nodes in reply are replicas for slot range */
for
(
i
=
0
;
i
<
get
NumSlaves
(
node
);
i
++
)
{
for
(
i
=
0
;
i
<
clusterNode
NumSlaves
(
node
);
i
++
)
{
/* This loop is copy/pasted from clusterGenNodeDescription()
/* This loop is copy/pasted from clusterGenNodeDescription()
* with modifications for per-slot node aggregation. */
* with modifications for per-slot node aggregation. */
if
(
!
isReplicaAvailable
(
g
etSlave
(
node
,
i
)))
continue
;
if
(
!
isReplicaAvailable
(
clusterNodeG
etSlave
(
node
,
i
)))
continue
;
addNodeToNodeReply
(
c
,
g
etSlave
(
node
,
i
));
addNodeToNodeReply
(
c
,
clusterNodeG
etSlave
(
node
,
i
));
nested_elements
--
;
nested_elements
--
;
}
}
serverAssert
(
nested_elements
==
3
);
/* Original 3 elements */
serverAssert
(
nested_elements
==
3
);
/* Original 3 elements */
...
...
src/cluster.h
View file @
290f3764
...
@@ -35,7 +35,7 @@ struct clusterState;
...
@@ -35,7 +35,7 @@ struct clusterState;
/* ---------------------- API exported outside cluster.c -------------------- */
/* ---------------------- API exported outside cluster.c -------------------- */
/* functions requiring mechanism specific implementations */
/* functions requiring mechanism specific implementations */
void
clusterInit
(
void
);
void
clusterInit
(
void
);
void
clusterInitL
i
st
eners
(
void
);
void
clusterInitL
a
st
(
void
);
void
clusterCron
(
void
);
void
clusterCron
(
void
);
void
clusterBeforeSleep
(
void
);
void
clusterBeforeSleep
(
void
);
int
verifyClusterConfigWithData
(
void
);
int
verifyClusterConfigWithData
(
void
);
...
@@ -59,10 +59,10 @@ sds clusterGenNodesDescription(client *c, int filter, int tls_primary);
...
@@ -59,10 +59,10 @@ sds clusterGenNodesDescription(client *c, int filter, int tls_primary);
sds
genClusterInfoString
(
void
);
sds
genClusterInfoString
(
void
);
/* handle implementation specific debug cluster commands. Return 1 if handled, 0 otherwise. */
/* handle implementation specific debug cluster commands. Return 1 if handled, 0 otherwise. */
int
handleDebugClusterCommand
(
client
*
c
);
int
handleDebugClusterCommand
(
client
*
c
);
const
char
**
clusterDebugCommandHelp
(
void
);
const
char
**
clusterDebugCommand
Extended
Help
(
void
);
/* handle implementation specific cluster commands. Return 1 if handled, 0 otherwise. */
/* handle implementation specific cluster commands. Return 1 if handled, 0 otherwise. */
int
clusterCommandSpecial
(
client
*
c
);
int
clusterCommandSpecial
(
client
*
c
);
const
char
**
clusterCommand
Special
Help
(
void
);
const
char
**
clusterCommand
Extended
Help
(
void
);
int
clusterAllowFailoverCmd
(
client
*
c
);
int
clusterAllowFailoverCmd
(
client
*
c
);
void
clusterPromoteSelfToMaster
(
void
);
void
clusterPromoteSelfToMaster
(
void
);
...
@@ -81,9 +81,9 @@ clusterNode* getMyClusterNode(void);
...
@@ -81,9 +81,9 @@ clusterNode* getMyClusterNode(void);
char
*
getMyClusterId
(
void
);
char
*
getMyClusterId
(
void
);
int
getClusterSize
(
void
);
int
getClusterSize
(
void
);
char
**
getClusterNodesList
(
size_t
*
numnodes
);
char
**
getClusterNodesList
(
size_t
*
numnodes
);
int
nodeIsMaster
(
clusterNode
*
n
);
int
handleDebugClusterCommand
(
client
*
c
);
int
handleDebugClusterCommand
(
client
*
c
);
int
clusterNodePending
(
clusterNode
*
node
);
int
clusterNodePending
(
clusterNode
*
node
);
int
clusterNodeIsMaster
(
clusterNode
*
n
);
char
*
clusterNodeIp
(
clusterNode
*
node
);
char
*
clusterNodeIp
(
clusterNode
*
node
);
int
clusterNodeIsSlave
(
clusterNode
*
node
);
int
clusterNodeIsSlave
(
clusterNode
*
node
);
clusterNode
*
clusterNodeGetSlaveof
(
clusterNode
*
node
);
clusterNode
*
clusterNodeGetSlaveof
(
clusterNode
*
node
);
...
@@ -92,15 +92,15 @@ int clusterNodeTimedOut(clusterNode *node);
...
@@ -92,15 +92,15 @@ int clusterNodeTimedOut(clusterNode *node);
int
clusterNodeIsFailing
(
clusterNode
*
node
);
int
clusterNodeIsFailing
(
clusterNode
*
node
);
int
clusterNodeIsNoFailover
(
clusterNode
*
node
);
int
clusterNodeIsNoFailover
(
clusterNode
*
node
);
char
*
clusterNodeGetShardId
(
clusterNode
*
node
);
char
*
clusterNodeGetShardId
(
clusterNode
*
node
);
int
get
NumSlaves
(
clusterNode
*
node
);
int
clusterNode
NumSlaves
(
clusterNode
*
node
);
clusterNode
*
g
etSlave
(
clusterNode
*
node
,
int
slave_idx
);
clusterNode
*
clusterNodeG
etSlave
(
clusterNode
*
node
,
int
slave_idx
);
clusterNode
*
getMigratingSlotDest
(
int
slot
);
clusterNode
*
getMigratingSlotDest
(
int
slot
);
clusterNode
*
getImportingSlotSource
(
int
slot
);
clusterNode
*
getImportingSlotSource
(
int
slot
);
clusterNode
*
getNodeBySlot
(
int
slot
);
clusterNode
*
getNodeBySlot
(
int
slot
);
int
get
NodeClientPort
(
clusterNode
*
n
,
int
use_tls
);
int
cluster
NodeClientPort
(
clusterNode
*
n
,
int
use_tls
);
char
*
clusterNodeHostname
(
clusterNode
*
node
);
char
*
clusterNodeHostname
(
clusterNode
*
node
);
const
char
*
get
PreferredEndpoint
(
clusterNode
*
n
);
const
char
*
clusterNode
PreferredEndpoint
(
clusterNode
*
n
);
long
long
get
ReplOffset
(
clusterNode
*
node
);
long
long
clusterNode
ReplOffset
(
clusterNode
*
node
);
clusterNode
*
clusterLookupNode
(
const
char
*
name
,
int
length
);
clusterNode
*
clusterLookupNode
(
const
char
*
name
,
int
length
);
/* functions with shared implementations */
/* functions with shared implementations */
...
...
src/cluster_legacy.c
View file @
290f3764
...
@@ -41,6 +41,7 @@
...
@@ -41,6 +41,7 @@
#include <unistd.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <math.h>
#include <math.h>
#include <sys/file.h>
/* A global reference to myself is handy to make code more clear.
/* A global reference to myself is handy to make code more clear.
* Myself always points to server.cluster->myself, that is, the clusterNode
* Myself always points to server.cluster->myself, that is, the clusterNode
...
@@ -112,7 +113,7 @@ static inline int getNodeDefaultReplicationPort(clusterNode *n) {
...
@@ -112,7 +113,7 @@ static inline int getNodeDefaultReplicationPort(clusterNode *n) {
return
server
.
tls_replication
?
n
->
tls_port
:
n
->
tcp_port
;
return
server
.
tls_replication
?
n
->
tls_port
:
n
->
tcp_port
;
}
}
int
get
NodeClientPort
(
clusterNode
*
n
,
int
use_tls
)
{
int
cluster
NodeClientPort
(
clusterNode
*
n
,
int
use_tls
)
{
return
use_tls
?
n
->
tls_port
:
n
->
tcp_port
;
return
use_tls
?
n
->
tls_port
:
n
->
tcp_port
;
}
}
...
@@ -1028,7 +1029,7 @@ void clusterInit(void) {
...
@@ -1028,7 +1029,7 @@ void clusterInit(void) {
clusterUpdateMyselfHumanNodename
();
clusterUpdateMyselfHumanNodename
();
}
}
void
clusterInitL
i
st
eners
(
void
)
{
void
clusterInitL
a
st
(
void
)
{
if
(
connectionIndexByType
(
connTypeOfCluster
()
->
get_type
(
NULL
))
<
0
)
{
if
(
connectionIndexByType
(
connTypeOfCluster
()
->
get_type
(
NULL
))
<
0
)
{
serverLog
(
LL_WARNING
,
"Missing connection type %s, but it is required for the Cluster bus."
,
connTypeOfCluster
()
->
get_type
(
NULL
));
serverLog
(
LL_WARNING
,
"Missing connection type %s, but it is required for the Cluster bus."
,
connTypeOfCluster
()
->
get_type
(
NULL
));
exit
(
1
);
exit
(
1
);
...
@@ -1755,7 +1756,7 @@ int clusterBumpConfigEpochWithoutConsensus(void) {
...
@@ -1755,7 +1756,7 @@ int clusterBumpConfigEpochWithoutConsensus(void) {
void
clusterHandleConfigEpochCollision
(
clusterNode
*
sender
)
{
void
clusterHandleConfigEpochCollision
(
clusterNode
*
sender
)
{
/* Prerequisites: nodes have the same configEpoch and are both masters. */
/* Prerequisites: nodes have the same configEpoch and are both masters. */
if
(
sender
->
configEpoch
!=
myself
->
configEpoch
||
if
(
sender
->
configEpoch
!=
myself
->
configEpoch
||
!
n
odeIsMaster
(
sender
)
||
!
n
odeIsMaster
(
myself
))
return
;
!
clusterN
odeIsMaster
(
sender
)
||
!
clusterN
odeIsMaster
(
myself
))
return
;
/* Don't act if the colliding node has a smaller Node ID. */
/* Don't act if the colliding node has a smaller Node ID. */
if
(
memcmp
(
sender
->
name
,
myself
->
name
,
CLUSTER_NAMELEN
)
<=
0
)
return
;
if
(
memcmp
(
sender
->
name
,
myself
->
name
,
CLUSTER_NAMELEN
)
<=
0
)
return
;
/* Get the next ID available at the best of this node knowledge. */
/* Get the next ID available at the best of this node knowledge. */
...
@@ -1877,7 +1878,7 @@ void markNodeAsFailingIfNeeded(clusterNode *node) {
...
@@ -1877,7 +1878,7 @@ void markNodeAsFailingIfNeeded(clusterNode *node) {
failures
=
clusterNodeFailureReportsCount
(
node
);
failures
=
clusterNodeFailureReportsCount
(
node
);
/* Also count myself as a voter if I'm a master. */
/* Also count myself as a voter if I'm a master. */
if
(
n
odeIsMaster
(
myself
))
failures
++
;
if
(
clusterN
odeIsMaster
(
myself
))
failures
++
;
if
(
failures
<
needed_quorum
)
return
;
/* No weak agreement from masters. */
if
(
failures
<
needed_quorum
)
return
;
/* No weak agreement from masters. */
serverLog
(
LL_NOTICE
,
serverLog
(
LL_NOTICE
,
...
@@ -1920,7 +1921,7 @@ void clearNodeFailureIfNeeded(clusterNode *node) {
...
@@ -1920,7 +1921,7 @@ void clearNodeFailureIfNeeded(clusterNode *node) {
* 1) The FAIL state is old enough.
* 1) The FAIL state is old enough.
* 2) It is yet serving slots from our point of view (not failed over).
* 2) It is yet serving slots from our point of view (not failed over).
* Apparently no one is going to fix these slots, clear the FAIL flag. */
* Apparently no one is going to fix these slots, clear the FAIL flag. */
if
(
n
odeIsMaster
(
node
)
&&
node
->
numslots
>
0
&&
if
(
clusterN
odeIsMaster
(
node
)
&&
node
->
numslots
>
0
&&
(
now
-
node
->
fail_time
)
>
(
now
-
node
->
fail_time
)
>
(
server
.
cluster_node_timeout
*
CLUSTER_FAIL_UNDO_TIME_MULT
))
(
server
.
cluster_node_timeout
*
CLUSTER_FAIL_UNDO_TIME_MULT
))
{
{
...
@@ -2070,7 +2071,7 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) {
...
@@ -2070,7 +2071,7 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) {
if
(
node
)
{
if
(
node
)
{
/* We already know this node.
/* We already know this node.
Handle failure reports, only when the sender is a master. */
Handle failure reports, only when the sender is a master. */
if
(
sender
&&
n
odeIsMaster
(
sender
)
&&
node
!=
myself
)
{
if
(
sender
&&
clusterN
odeIsMaster
(
sender
)
&&
node
!=
myself
)
{
if
(
flags
&
(
CLUSTER_NODE_FAIL
|
CLUSTER_NODE_PFAIL
))
{
if
(
flags
&
(
CLUSTER_NODE_FAIL
|
CLUSTER_NODE_PFAIL
))
{
if
(
clusterNodeAddFailureReport
(
node
,
sender
))
{
if
(
clusterNodeAddFailureReport
(
node
,
sender
))
{
serverLog
(
LL_VERBOSE
,
serverLog
(
LL_VERBOSE
,
...
@@ -2233,7 +2234,7 @@ int nodeUpdateAddressIfNeeded(clusterNode *node, clusterLink *link,
...
@@ -2233,7 +2234,7 @@ int nodeUpdateAddressIfNeeded(clusterNode *node, clusterLink *link,
* a node that we believed to be a slave is now acting as master in order to
* a node that we believed to be a slave is now acting as master in order to
* update the state of the node. */
* update the state of the node. */
void
clusterSetNodeAsMaster
(
clusterNode
*
n
)
{
void
clusterSetNodeAsMaster
(
clusterNode
*
n
)
{
if
(
n
odeIsMaster
(
n
))
return
;
if
(
clusterN
odeIsMaster
(
n
))
return
;
if
(
n
->
slaveof
)
{
if
(
n
->
slaveof
)
{
clusterNodeRemoveSlave
(
n
->
slaveof
,
n
);
clusterNodeRemoveSlave
(
n
->
slaveof
,
n
);
...
@@ -2281,7 +2282,7 @@ void clusterUpdateSlotsConfigWith(clusterNode *sender, uint64_t senderConfigEpoc
...
@@ -2281,7 +2282,7 @@ void clusterUpdateSlotsConfigWith(clusterNode *sender, uint64_t senderConfigEpoc
/* Here we set curmaster to this node or the node this node
/* Here we set curmaster to this node or the node this node
* replicates to if it's a slave. In the for loop we are
* replicates to if it's a slave. In the for loop we are
* interested to check if slots are taken away from curmaster. */
* interested to check if slots are taken away from curmaster. */
curmaster
=
n
odeIsMaster
(
myself
)
?
myself
:
myself
->
slaveof
;
curmaster
=
clusterN
odeIsMaster
(
myself
)
?
myself
:
myself
->
slaveof
;
if
(
sender
==
myself
)
{
if
(
sender
==
myself
)
{
serverLog
(
LL_NOTICE
,
"Discarding UPDATE message about myself."
);
serverLog
(
LL_NOTICE
,
"Discarding UPDATE message about myself."
);
...
@@ -2920,7 +2921,7 @@ int clusterProcessPacket(clusterLink *link) {
...
@@ -2920,7 +2921,7 @@ int clusterProcessPacket(clusterLink *link) {
/* Node is a slave. */
/* Node is a slave. */
clusterNode
*
master
=
clusterLookupNode
(
hdr
->
slaveof
,
CLUSTER_NAMELEN
);
clusterNode
*
master
=
clusterLookupNode
(
hdr
->
slaveof
,
CLUSTER_NAMELEN
);
if
(
n
odeIsMaster
(
sender
))
{
if
(
clusterN
odeIsMaster
(
sender
))
{
/* Master turned into a slave! Reconfigure the node. */
/* Master turned into a slave! Reconfigure the node. */
clusterDelNodeSlots
(
sender
);
clusterDelNodeSlots
(
sender
);
sender
->
flags
&=
~
(
CLUSTER_NODE_MASTER
|
sender
->
flags
&=
~
(
CLUSTER_NODE_MASTER
|
...
@@ -2958,7 +2959,7 @@ int clusterProcessPacket(clusterLink *link) {
...
@@ -2958,7 +2959,7 @@ int clusterProcessPacket(clusterLink *link) {
int
dirty_slots
=
0
;
/* Sender claimed slots don't match my view? */
int
dirty_slots
=
0
;
/* Sender claimed slots don't match my view? */
if
(
sender
)
{
if
(
sender
)
{
sender_master
=
n
odeIsMaster
(
sender
)
?
sender
:
sender
->
slaveof
;
sender_master
=
clusterN
odeIsMaster
(
sender
)
?
sender
:
sender
->
slaveof
;
if
(
sender_master
)
{
if
(
sender_master
)
{
dirty_slots
=
memcmp
(
sender_master
->
slots
,
dirty_slots
=
memcmp
(
sender_master
->
slots
,
hdr
->
myslots
,
sizeof
(
hdr
->
myslots
))
!=
0
;
hdr
->
myslots
,
sizeof
(
hdr
->
myslots
))
!=
0
;
...
@@ -2968,7 +2969,7 @@ int clusterProcessPacket(clusterLink *link) {
...
@@ -2968,7 +2969,7 @@ int clusterProcessPacket(clusterLink *link) {
/* 1) If the sender of the message is a master, and we detected that
/* 1) If the sender of the message is a master, and we detected that
* the set of slots it claims changed, scan the slots to see if we
* the set of slots it claims changed, scan the slots to see if we
* need to update our configuration. */
* need to update our configuration. */
if
(
sender
&&
n
odeIsMaster
(
sender
)
&&
dirty_slots
)
if
(
sender
&&
clusterN
odeIsMaster
(
sender
)
&&
dirty_slots
)
clusterUpdateSlotsConfigWith
(
sender
,
senderConfigEpoch
,
hdr
->
myslots
);
clusterUpdateSlotsConfigWith
(
sender
,
senderConfigEpoch
,
hdr
->
myslots
);
/* 2) We also check for the reverse condition, that is, the sender
/* 2) We also check for the reverse condition, that is, the sender
...
@@ -3017,8 +3018,7 @@ int clusterProcessPacket(clusterLink *link) {
...
@@ -3017,8 +3018,7 @@ int clusterProcessPacket(clusterLink *link) {
/* If our config epoch collides with the sender's try to fix
/* If our config epoch collides with the sender's try to fix
* the problem. */
* the problem. */
if
(
sender
&&
if
(
sender
&&
clusterNodeIsMaster
(
myself
)
&&
clusterNodeIsMaster
(
sender
)
&&
nodeIsMaster
(
myself
)
&&
nodeIsMaster
(
sender
)
&&
senderConfigEpoch
==
myself
->
configEpoch
)
senderConfigEpoch
==
myself
->
configEpoch
)
{
{
clusterHandleConfigEpochCollision
(
sender
);
clusterHandleConfigEpochCollision
(
sender
);
...
@@ -3083,7 +3083,7 @@ int clusterProcessPacket(clusterLink *link) {
...
@@ -3083,7 +3083,7 @@ int clusterProcessPacket(clusterLink *link) {
/* We consider this vote only if the sender is a master serving
/* We consider this vote only if the sender is a master serving
* a non zero number of slots, and its currentEpoch is greater or
* a non zero number of slots, and its currentEpoch is greater or
* equal to epoch where this node started the election. */
* equal to epoch where this node started the election. */
if
(
n
odeIsMaster
(
sender
)
&&
sender
->
numslots
>
0
&&
if
(
clusterN
odeIsMaster
(
sender
)
&&
sender
->
numslots
>
0
&&
senderCurrentEpoch
>=
server
.
cluster
->
failover_auth_epoch
)
senderCurrentEpoch
>=
server
.
cluster
->
failover_auth_epoch
)
{
{
server
.
cluster
->
failover_auth_count
++
;
server
.
cluster
->
failover_auth_count
++
;
...
@@ -3438,7 +3438,7 @@ static void clusterBuildMessageHdr(clusterMsg *hdr, int type, size_t msglen) {
...
@@ -3438,7 +3438,7 @@ static void clusterBuildMessageHdr(clusterMsg *hdr, int type, size_t msglen) {
hdr
->
offset
=
htonu64
(
offset
);
hdr
->
offset
=
htonu64
(
offset
);
/* Set the message flags. */
/* Set the message flags. */
if
(
n
odeIsMaster
(
myself
)
&&
server
.
cluster
->
mf_end
)
if
(
clusterN
odeIsMaster
(
myself
)
&&
server
.
cluster
->
mf_end
)
hdr
->
mflags
[
0
]
|=
CLUSTERMSG_FLAG0_PAUSED
;
hdr
->
mflags
[
0
]
|=
CLUSTERMSG_FLAG0_PAUSED
;
hdr
->
totlen
=
htonl
(
msglen
);
hdr
->
totlen
=
htonl
(
msglen
);
...
@@ -3869,10 +3869,10 @@ void clusterSendFailoverAuthIfNeeded(clusterNode *node, clusterMsg *request) {
...
@@ -3869,10 +3869,10 @@ void clusterSendFailoverAuthIfNeeded(clusterNode *node, clusterMsg *request) {
/* Node must be a slave and its master down.
/* Node must be a slave and its master down.
* The master can be non failing if the request is flagged
* The master can be non failing if the request is flagged
* with CLUSTERMSG_FLAG0_FORCEACK (manual failover). */
* with CLUSTERMSG_FLAG0_FORCEACK (manual failover). */
if
(
n
odeIsMaster
(
node
)
||
master
==
NULL
||
if
(
clusterN
odeIsMaster
(
node
)
||
master
==
NULL
||
(
!
nodeFailed
(
master
)
&&
!
force_ack
))
(
!
nodeFailed
(
master
)
&&
!
force_ack
))
{
{
if
(
n
odeIsMaster
(
node
))
{
if
(
clusterN
odeIsMaster
(
node
))
{
serverLog
(
LL_WARNING
,
serverLog
(
LL_WARNING
,
"Failover auth denied to %.40s (%s): it is a master node"
,
"Failover auth denied to %.40s (%s): it is a master node"
,
node
->
name
,
node
->
human_nodename
);
node
->
name
,
node
->
human_nodename
);
...
@@ -4043,7 +4043,7 @@ void clusterFailoverReplaceYourMaster(void) {
...
@@ -4043,7 +4043,7 @@ void clusterFailoverReplaceYourMaster(void) {
int
j
;
int
j
;
clusterNode
*
oldmaster
=
myself
->
slaveof
;
clusterNode
*
oldmaster
=
myself
->
slaveof
;
if
(
n
odeIsMaster
(
myself
)
||
oldmaster
==
NULL
)
return
;
if
(
clusterN
odeIsMaster
(
myself
)
||
oldmaster
==
NULL
)
return
;
/* 1) Turn this node into a master. */
/* 1) Turn this node into a master. */
clusterSetNodeAsMaster
(
myself
);
clusterSetNodeAsMaster
(
myself
);
...
@@ -4105,7 +4105,7 @@ void clusterHandleSlaveFailover(void) {
...
@@ -4105,7 +4105,7 @@ void clusterHandleSlaveFailover(void) {
* 3) We don't have the no failover configuration set, and this is
* 3) We don't have the no failover configuration set, and this is
* not a manual failover.
* not a manual failover.
* 4) It is serving slots. */
* 4) It is serving slots. */
if
(
n
odeIsMaster
(
myself
)
||
if
(
clusterN
odeIsMaster
(
myself
)
||
myself
->
slaveof
==
NULL
||
myself
->
slaveof
==
NULL
||
(
!
nodeFailed
(
myself
->
slaveof
)
&&
!
manual_failover
)
||
(
!
nodeFailed
(
myself
->
slaveof
)
&&
!
manual_failover
)
||
(
server
.
cluster_slave_no_failover
&&
!
manual_failover
)
||
(
server
.
cluster_slave_no_failover
&&
!
manual_failover
)
||
...
@@ -4316,7 +4316,7 @@ void clusterHandleSlaveMigration(int max_slaves) {
...
@@ -4316,7 +4316,7 @@ void clusterHandleSlaveMigration(int max_slaves) {
if
(
!
(
node
->
flags
&
CLUSTER_NODE_MIGRATE_TO
))
is_orphaned
=
0
;
if
(
!
(
node
->
flags
&
CLUSTER_NODE_MIGRATE_TO
))
is_orphaned
=
0
;
/* Check number of working slaves. */
/* Check number of working slaves. */
if
(
n
odeIsMaster
(
node
))
okslaves
=
clusterCountNonFailingSlaves
(
node
);
if
(
clusterN
odeIsMaster
(
node
))
okslaves
=
clusterCountNonFailingSlaves
(
node
);
if
(
okslaves
>
0
)
is_orphaned
=
0
;
if
(
okslaves
>
0
)
is_orphaned
=
0
;
if
(
is_orphaned
)
{
if
(
is_orphaned
)
{
...
@@ -4591,7 +4591,7 @@ void clusterCron(void) {
...
@@ -4591,7 +4591,7 @@ void clusterCron(void) {
/* Orphaned master check, useful only if the current instance
/* Orphaned master check, useful only if the current instance
* is a slave that may migrate to another master. */
* is a slave that may migrate to another master. */
if
(
nodeIsSlave
(
myself
)
&&
n
odeIsMaster
(
node
)
&&
!
nodeFailed
(
node
))
{
if
(
nodeIsSlave
(
myself
)
&&
clusterN
odeIsMaster
(
node
)
&&
!
nodeFailed
(
node
))
{
int
okslaves
=
clusterCountNonFailingSlaves
(
node
);
int
okslaves
=
clusterCountNonFailingSlaves
(
node
);
/* A master is orphaned if it is serving a non-zero number of
/* A master is orphaned if it is serving a non-zero number of
...
@@ -4642,7 +4642,7 @@ void clusterCron(void) {
...
@@ -4642,7 +4642,7 @@ void clusterCron(void) {
/* If we are a master and one of the slaves requested a manual
/* If we are a master and one of the slaves requested a manual
* failover, ping it continuously. */
* failover, ping it continuously. */
if
(
server
.
cluster
->
mf_end
&&
if
(
server
.
cluster
->
mf_end
&&
n
odeIsMaster
(
myself
)
&&
clusterN
odeIsMaster
(
myself
)
&&
server
.
cluster
->
mf_slave
==
node
&&
server
.
cluster
->
mf_slave
==
node
&&
node
->
link
)
node
->
link
)
{
{
...
@@ -4912,7 +4912,7 @@ void clusterUpdateState(void) {
...
@@ -4912,7 +4912,7 @@ void clusterUpdateState(void) {
* the first call to this function and not since the server start, in order
* the first call to this function and not since the server start, in order
* to not count the DB loading time. */
* to not count the DB loading time. */
if
(
first_call_time
==
0
)
first_call_time
=
mstime
();
if
(
first_call_time
==
0
)
first_call_time
=
mstime
();
if
(
n
odeIsMaster
(
myself
)
&&
if
(
clusterN
odeIsMaster
(
myself
)
&&
server
.
cluster
->
state
==
CLUSTER_FAIL
&&
server
.
cluster
->
state
==
CLUSTER_FAIL
&&
mstime
()
-
first_call_time
<
CLUSTER_WRITABLE_DELAY
)
return
;
mstime
()
-
first_call_time
<
CLUSTER_WRITABLE_DELAY
)
return
;
...
@@ -4946,7 +4946,7 @@ void clusterUpdateState(void) {
...
@@ -4946,7 +4946,7 @@ void clusterUpdateState(void) {
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
clusterNode
*
node
=
dictGetVal
(
de
);
clusterNode
*
node
=
dictGetVal
(
de
);
if
(
n
odeIsMaster
(
node
)
&&
node
->
numslots
)
{
if
(
clusterN
odeIsMaster
(
node
)
&&
node
->
numslots
)
{
server
.
cluster
->
size
++
;
server
.
cluster
->
size
++
;
if
((
node
->
flags
&
(
CLUSTER_NODE_FAIL
|
CLUSTER_NODE_PFAIL
))
==
0
)
if
((
node
->
flags
&
(
CLUSTER_NODE_FAIL
|
CLUSTER_NODE_PFAIL
))
==
0
)
reachable_masters
++
;
reachable_masters
++
;
...
@@ -4980,7 +4980,7 @@ void clusterUpdateState(void) {
...
@@ -4980,7 +4980,7 @@ void clusterUpdateState(void) {
rejoin_delay
=
CLUSTER_MIN_REJOIN_DELAY
;
rejoin_delay
=
CLUSTER_MIN_REJOIN_DELAY
;
if
(
new_state
==
CLUSTER_OK
&&
if
(
new_state
==
CLUSTER_OK
&&
n
odeIsMaster
(
myself
)
&&
clusterN
odeIsMaster
(
myself
)
&&
mstime
()
-
among_minority_time
<
rejoin_delay
)
mstime
()
-
among_minority_time
<
rejoin_delay
)
{
{
return
;
return
;
...
@@ -5068,7 +5068,7 @@ int verifyClusterConfigWithData(void) {
...
@@ -5068,7 +5068,7 @@ int verifyClusterConfigWithData(void) {
/* Remove all the shard channel related information not owned by the current shard. */
/* Remove all the shard channel related information not owned by the current shard. */
static
inline
void
removeAllNotOwnedShardChannelSubscriptions
(
void
)
{
static
inline
void
removeAllNotOwnedShardChannelSubscriptions
(
void
)
{
if
(
!
dictSize
(
server
.
pubsubshard_channels
))
return
;
if
(
!
dictSize
(
server
.
pubsubshard_channels
))
return
;
clusterNode
*
currmaster
=
n
odeIsMaster
(
myself
)
?
myself
:
myself
->
slaveof
;
clusterNode
*
currmaster
=
clusterN
odeIsMaster
(
myself
)
?
myself
:
myself
->
slaveof
;
for
(
int
j
=
0
;
j
<
CLUSTER_SLOTS
;
j
++
)
{
for
(
int
j
=
0
;
j
<
CLUSTER_SLOTS
;
j
++
)
{
if
(
server
.
cluster
->
slots
[
j
]
!=
currmaster
)
{
if
(
server
.
cluster
->
slots
[
j
]
!=
currmaster
)
{
removeChannelsInSlot
(
j
);
removeChannelsInSlot
(
j
);
...
@@ -5086,7 +5086,7 @@ void clusterSetMaster(clusterNode *n) {
...
@@ -5086,7 +5086,7 @@ void clusterSetMaster(clusterNode *n) {
serverAssert
(
n
!=
myself
);
serverAssert
(
n
!=
myself
);
serverAssert
(
myself
->
numslots
==
0
);
serverAssert
(
myself
->
numslots
==
0
);
if
(
n
odeIsMaster
(
myself
))
{
if
(
clusterN
odeIsMaster
(
myself
))
{
myself
->
flags
&=
~
(
CLUSTER_NODE_MASTER
|
CLUSTER_NODE_MIGRATE_TO
);
myself
->
flags
&=
~
(
CLUSTER_NODE_MASTER
|
CLUSTER_NODE_MIGRATE_TO
);
myself
->
flags
|=
CLUSTER_NODE_SLAVE
;
myself
->
flags
|=
CLUSTER_NODE_SLAVE
;
clusterCloseAllSlots
();
clusterCloseAllSlots
();
...
@@ -5160,7 +5160,7 @@ sds representSlotInfo(sds ci, uint16_t *slot_info_pairs, int slot_info_pairs_cou
...
@@ -5160,7 +5160,7 @@ sds representSlotInfo(sds ci, uint16_t *slot_info_pairs, int slot_info_pairs_cou
sds
clusterGenNodeDescription
(
client
*
c
,
clusterNode
*
node
,
int
tls_primary
)
{
sds
clusterGenNodeDescription
(
client
*
c
,
clusterNode
*
node
,
int
tls_primary
)
{
int
j
,
start
;
int
j
,
start
;
sds
ci
;
sds
ci
;
int
port
=
get
NodeClientPort
(
node
,
tls_primary
);
int
port
=
cluster
NodeClientPort
(
node
,
tls_primary
);
/* Node coordinates */
/* Node coordinates */
ci
=
sdscatlen
(
sdsempty
(),
node
->
name
,
CLUSTER_NAMELEN
);
ci
=
sdscatlen
(
sdsempty
(),
node
->
name
,
CLUSTER_NAMELEN
);
...
@@ -5492,7 +5492,7 @@ void addNodeDetailsToShardReply(client *c, clusterNode *node) {
...
@@ -5492,7 +5492,7 @@ void addNodeDetailsToShardReply(client *c, clusterNode *node) {
reply_count
++
;
reply_count
++
;
addReplyBulkCString
(
c
,
"endpoint"
);
addReplyBulkCString
(
c
,
"endpoint"
);
addReplyBulkCString
(
c
,
get
PreferredEndpoint
(
node
));
addReplyBulkCString
(
c
,
clusterNode
PreferredEndpoint
(
node
));
reply_count
++
;
reply_count
++
;
if
(
sdslen
(
node
->
hostname
)
!=
0
)
{
if
(
sdslen
(
node
->
hostname
)
!=
0
)
{
...
@@ -5793,7 +5793,7 @@ char** getClusterNodesList(size_t *numnodes) {
...
@@ -5793,7 +5793,7 @@ char** getClusterNodesList(size_t *numnodes) {
return
ids
;
return
ids
;
}
}
int
n
odeIsMaster
(
clusterNode
*
n
)
{
int
clusterN
odeIsMaster
(
clusterNode
*
n
)
{
return
n
->
flags
&
CLUSTER_NODE_MASTER
;
return
n
->
flags
&
CLUSTER_NODE_MASTER
;
}
}
...
@@ -5864,7 +5864,7 @@ int clusterNodeIsNoFailover(clusterNode *node) {
...
@@ -5864,7 +5864,7 @@ int clusterNodeIsNoFailover(clusterNode *node) {
return
node
->
flags
&
CLUSTER_NODE_NOFAILOVER
;
return
node
->
flags
&
CLUSTER_NODE_NOFAILOVER
;
}
}
const
char
**
clusterDebugCommandHelp
(
void
)
{
const
char
**
clusterDebugCommand
Extended
Help
(
void
)
{
static
const
char
*
help
[]
=
{
static
const
char
*
help
[]
=
{
"CLUSTERLINK KILL <to|from|all> <node-id>"
,
"CLUSTERLINK KILL <to|from|all> <node-id>"
,
" Kills the link based on the direction to/from (both) with the provided node."
,
" Kills the link based on the direction to/from (both) with the provided node."
,
...
@@ -6174,7 +6174,7 @@ int clusterCommandSpecial(client *c) {
...
@@ -6174,7 +6174,7 @@ int clusterCommandSpecial(client *c) {
/* If the instance is currently a master, it should have no assigned
/* If the instance is currently a master, it should have no assigned
* slots nor keys to accept to replicate some other node.
* slots nor keys to accept to replicate some other node.
* Slaves can switch to another master without issues. */
* Slaves can switch to another master without issues. */
if
(
n
odeIsMaster
(
myself
)
&&
if
(
clusterN
odeIsMaster
(
myself
)
&&
(
myself
->
numslots
!=
0
||
dbSize
(
&
server
.
db
[
0
],
DB_MAIN
)
!=
0
))
{
(
myself
->
numslots
!=
0
||
dbSize
(
&
server
.
db
[
0
],
DB_MAIN
)
!=
0
))
{
addReplyError
(
c
,
addReplyError
(
c
,
"To set a master the node must be empty and "
"To set a master the node must be empty and "
...
@@ -6217,7 +6217,7 @@ int clusterCommandSpecial(client *c) {
...
@@ -6217,7 +6217,7 @@ int clusterCommandSpecial(client *c) {
}
}
/* Check preconditions. */
/* Check preconditions. */
if
(
n
odeIsMaster
(
myself
))
{
if
(
clusterN
odeIsMaster
(
myself
))
{
addReplyError
(
c
,
"You should send CLUSTER FAILOVER to a replica"
);
addReplyError
(
c
,
"You should send CLUSTER FAILOVER to a replica"
);
return
1
;
return
1
;
}
else
if
(
myself
->
slaveof
==
NULL
)
{
}
else
if
(
myself
->
slaveof
==
NULL
)
{
...
@@ -6309,7 +6309,7 @@ int clusterCommandSpecial(client *c) {
...
@@ -6309,7 +6309,7 @@ int clusterCommandSpecial(client *c) {
/* Slaves can be reset while containing data, but not master nodes
/* Slaves can be reset while containing data, but not master nodes
* that must be empty. */
* that must be empty. */
if
(
n
odeIsMaster
(
myself
)
&&
dbSize
(
c
->
db
,
DB_MAIN
)
!=
0
)
{
if
(
clusterN
odeIsMaster
(
myself
)
&&
dbSize
(
c
->
db
,
DB_MAIN
)
!=
0
)
{
addReplyError
(
c
,
"CLUSTER RESET can't be called with "
addReplyError
(
c
,
"CLUSTER RESET can't be called with "
"master nodes containing keys"
);
"master nodes containing keys"
);
return
1
;
return
1
;
...
@@ -6326,7 +6326,7 @@ int clusterCommandSpecial(client *c) {
...
@@ -6326,7 +6326,7 @@ int clusterCommandSpecial(client *c) {
return
1
;
return
1
;
}
}
const
char
**
clusterCommand
Special
Help
(
void
)
{
const
char
**
clusterCommand
Extended
Help
(
void
)
{
static
const
char
*
help
[]
=
{
static
const
char
*
help
[]
=
{
"ADDSLOTS <slot> [<slot> ...]"
,
"ADDSLOTS <slot> [<slot> ...]"
,
" Assign slots to current node."
,
" Assign slots to current node."
,
...
@@ -6367,11 +6367,11 @@ const char** clusterCommandSpecialHelp(void) {
...
@@ -6367,11 +6367,11 @@ const char** clusterCommandSpecialHelp(void) {
return
help
;
return
help
;
}
}
int
get
NumSlaves
(
clusterNode
*
node
)
{
int
clusterNode
NumSlaves
(
clusterNode
*
node
)
{
return
node
->
numslaves
;
return
node
->
numslaves
;
}
}
clusterNode
*
g
etSlave
(
clusterNode
*
node
,
int
slave_idx
)
{
clusterNode
*
clusterNodeG
etSlave
(
clusterNode
*
node
,
int
slave_idx
)
{
return
node
->
slaves
[
slave_idx
];
return
node
->
slaves
[
slave_idx
];
}
}
...
@@ -6395,11 +6395,11 @@ char* clusterNodeHostname(clusterNode *node) {
...
@@ -6395,11 +6395,11 @@ char* clusterNodeHostname(clusterNode *node) {
return
node
->
hostname
;
return
node
->
hostname
;
}
}
long
long
get
ReplOffset
(
clusterNode
*
node
)
{
long
long
clusterNode
ReplOffset
(
clusterNode
*
node
)
{
return
node
->
repl_offset
;
return
node
->
repl_offset
;
}
}
const
char
*
get
PreferredEndpoint
(
clusterNode
*
n
)
{
const
char
*
clusterNode
PreferredEndpoint
(
clusterNode
*
n
)
{
char
*
hostname
=
clusterNodeHostname
(
n
);
char
*
hostname
=
clusterNodeHostname
(
n
);
switch
(
server
.
cluster_preferred_endpoint_type
)
{
switch
(
server
.
cluster_preferred_endpoint_type
)
{
case
CLUSTER_ENDPOINT_TYPE_IP
:
case
CLUSTER_ENDPOINT_TYPE_IP
:
...
...
src/debug.c
View file @
290f3764
...
@@ -498,7 +498,7 @@ void debugCommand(client *c) {
...
@@ -498,7 +498,7 @@ void debugCommand(client *c) {
" Enable or disable the reply buffer resize cron job"
,
" Enable or disable the reply buffer resize cron job"
,
NULL
NULL
};
};
addExtendedReplyHelp
(
c
,
help
,
clusterDebugCommandHelp
());
addExtendedReplyHelp
(
c
,
help
,
clusterDebugCommand
Extended
Help
());
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"segfault"
))
{
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"segfault"
))
{
/* Compiler gives warnings about writing to a random address
/* Compiler gives warnings about writing to a random address
* e.g "*((char*)-1) = 'x';". As a workaround, we map a read-only area
* e.g "*((char*)-1) = 'x';". As a workaround, we map a read-only area
...
...
src/module.c
View file @
290f3764
...
@@ -8990,7 +8990,7 @@ int RM_GetClusterNodeInfo(RedisModuleCtx *ctx, const char *id, char *ip, char *m
...
@@ -8990,7 +8990,7 @@ int RM_GetClusterNodeInfo(RedisModuleCtx *ctx, const char *id, char *ip, char *m
if (flags) {
if (flags) {
*flags = 0;
*flags = 0;
if (clusterNodeIsMyself(node)) *flags |= REDISMODULE_NODE_MYSELF;
if (clusterNodeIsMyself(node)) *flags |= REDISMODULE_NODE_MYSELF;
if (
n
odeIsMaster(node)) *flags |= REDISMODULE_NODE_MASTER;
if (
clusterN
odeIsMaster(node)) *flags |= REDISMODULE_NODE_MASTER;
if (clusterNodeIsSlave(node)) *flags |= REDISMODULE_NODE_SLAVE;
if (clusterNodeIsSlave(node)) *flags |= REDISMODULE_NODE_SLAVE;
if (clusterNodeTimedOut(node)) *flags |= REDISMODULE_NODE_PFAIL;
if (clusterNodeTimedOut(node)) *flags |= REDISMODULE_NODE_PFAIL;
if (clusterNodeIsFailing(node)) *flags |= REDISMODULE_NODE_FAIL;
if (clusterNodeIsFailing(node)) *flags |= REDISMODULE_NODE_FAIL;
...
...
src/server.c
View file @
290f3764
...
@@ -6838,7 +6838,7 @@ int redisIsSupervised(int mode) {
...
@@ -6838,7 +6838,7 @@ int redisIsSupervised(int mode) {
int
iAmMaster
(
void
)
{
int
iAmMaster
(
void
)
{
return
((
!
server
.
cluster_enabled
&&
server
.
masterhost
==
NULL
)
||
return
((
!
server
.
cluster_enabled
&&
server
.
masterhost
==
NULL
)
||
(
server
.
cluster_enabled
&&
n
odeIsMaster
(
getMyClusterNode
())));
(
server
.
cluster_enabled
&&
clusterN
odeIsMaster
(
getMyClusterNode
())));
}
}
#ifdef REDIS_TEST
#ifdef REDIS_TEST
...
@@ -7161,7 +7161,7 @@ int main(int argc, char **argv) {
...
@@ -7161,7 +7161,7 @@ int main(int argc, char **argv) {
ACLLoadUsersAtStartup
();
ACLLoadUsersAtStartup
();
initListeners
();
initListeners
();
if
(
server
.
cluster_enabled
)
{
if
(
server
.
cluster_enabled
)
{
clusterInitL
i
st
eners
();
clusterInitL
a
st
();
}
}
InitServerLast
();
InitServerLast
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment