Update remaining master
references to primary
(#660)
Signed-off-by: Ping Xie <pingxie@google.com>
This commit is contained in:
parent
495a121f19
commit
4135894a5d
@ -86,7 +86,7 @@ void initClientBlockingState(client *c) {
|
|||||||
* flag is set client query buffer is not longer processed, but accumulated,
|
* flag is set client query buffer is not longer processed, but accumulated,
|
||||||
* and will be processed when the client is unblocked. */
|
* and will be processed when the client is unblocked. */
|
||||||
void blockClient(client *c, int btype) {
|
void blockClient(client *c, int btype) {
|
||||||
/* Master client should never be blocked unless pause or module */
|
/* Primary client should never be blocked unless pause or module */
|
||||||
serverAssert(!(c->flags & CLIENT_PRIMARY && btype != BLOCKED_MODULE && btype != BLOCKED_POSTPONE));
|
serverAssert(!(c->flags & CLIENT_PRIMARY && btype != BLOCKED_MODULE && btype != BLOCKED_POSTPONE));
|
||||||
|
|
||||||
c->flags |= CLIENT_BLOCKED;
|
c->flags |= CLIENT_BLOCKED;
|
||||||
@ -265,8 +265,8 @@ void replyToClientsBlockedOnShutdown(void) {
|
|||||||
|
|
||||||
/* Mass-unblock clients because something changed in the instance that makes
|
/* Mass-unblock clients because something changed in the instance that makes
|
||||||
* blocking no longer safe. For example clients blocked in list operations
|
* blocking no longer safe. For example clients blocked in list operations
|
||||||
* in an instance which turns from master to replica is unsafe, so this function
|
* in an instance which turns from primary to replica is unsafe, so this function
|
||||||
* is called when a master turns into a replica.
|
* is called when a primary turns into a replica.
|
||||||
*
|
*
|
||||||
* The semantics is to send an -UNBLOCKED error to the client, disconnecting
|
* The semantics is to send an -UNBLOCKED error to the client, disconnecting
|
||||||
* it at the same time. */
|
* it at the same time. */
|
||||||
|
@ -813,12 +813,12 @@ void clusterCommandHelp(client *c) {
|
|||||||
" Return the node's shard id.",
|
" Return the node's shard id.",
|
||||||
"NODES",
|
"NODES",
|
||||||
" Return cluster configuration seen by node. Output format:",
|
" Return cluster configuration seen by node. Output format:",
|
||||||
" <id> <ip:port@bus-port[,hostname]> <flags> <master> <pings> <pongs> <epoch> <link> <slot> ...",
|
" <id> <ip:port@bus-port[,hostname]> <flags> <primary> <pings> <pongs> <epoch> <link> <slot> ...",
|
||||||
"REPLICAS <node-id>",
|
"REPLICAS <node-id>",
|
||||||
" Return <node-id> replicas.",
|
" Return <node-id> replicas.",
|
||||||
"SLOTS",
|
"SLOTS",
|
||||||
" Return information about slots range mappings. Each range is made of:",
|
" Return information about slots range mappings. Each range is made of:",
|
||||||
" start, end, master and replicas IP addresses, ports and ids",
|
" start, end, primary and replicas IP addresses, ports and ids",
|
||||||
"SHARDS",
|
"SHARDS",
|
||||||
" Return information about slot range mappings and the nodes associated with them.",
|
" Return information about slot range mappings and the nodes associated with them.",
|
||||||
NULL};
|
NULL};
|
||||||
|
@ -533,9 +533,9 @@ int clusterLoadConfig(char *filename) {
|
|||||||
serverAssert(server.cluster->myself == NULL);
|
serverAssert(server.cluster->myself == NULL);
|
||||||
myself = server.cluster->myself = n;
|
myself = server.cluster->myself = n;
|
||||||
n->flags |= CLUSTER_NODE_MYSELF;
|
n->flags |= CLUSTER_NODE_MYSELF;
|
||||||
} else if (!strcasecmp(s, "master")) {
|
} else if (!strcasecmp(s, "master") || !strcasecmp(s, "primary")) {
|
||||||
n->flags |= CLUSTER_NODE_PRIMARY;
|
n->flags |= CLUSTER_NODE_PRIMARY;
|
||||||
} else if (!strcasecmp(s, "slave")) {
|
} else if (!strcasecmp(s, "slave") || !strcasecmp(s, "replica")) {
|
||||||
n->flags |= CLUSTER_NODE_REPLICA;
|
n->flags |= CLUSTER_NODE_REPLICA;
|
||||||
} else if (!strcasecmp(s, "fail?")) {
|
} else if (!strcasecmp(s, "fail?")) {
|
||||||
n->flags |= CLUSTER_NODE_PFAIL;
|
n->flags |= CLUSTER_NODE_PFAIL;
|
||||||
@ -1903,7 +1903,7 @@ void clearNodeFailureIfNeeded(clusterNode *node) {
|
|||||||
* node again. */
|
* node again. */
|
||||||
if (nodeIsReplica(node) || node->numslots == 0) {
|
if (nodeIsReplica(node) || node->numslots == 0) {
|
||||||
serverLog(LL_NOTICE, "Clear FAIL state for node %.40s (%s):%s is reachable again.", node->name,
|
serverLog(LL_NOTICE, "Clear FAIL state for node %.40s (%s):%s is reachable again.", node->name,
|
||||||
node->human_nodename, nodeIsReplica(node) ? "replica" : "master without slots");
|
node->human_nodename, nodeIsReplica(node) ? "replica" : "primary without slots");
|
||||||
node->flags &= ~CLUSTER_NODE_FAIL;
|
node->flags &= ~CLUSTER_NODE_FAIL;
|
||||||
clusterDoBeforeSleep(CLUSTER_TODO_UPDATE_STATE | CLUSTER_TODO_SAVE_CONFIG);
|
clusterDoBeforeSleep(CLUSTER_TODO_UPDATE_STATE | CLUSTER_TODO_SAVE_CONFIG);
|
||||||
}
|
}
|
||||||
@ -4154,7 +4154,7 @@ void clusterLogCantFailover(int reason) {
|
|||||||
|
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case CLUSTER_CANT_FAILOVER_DATA_AGE:
|
case CLUSTER_CANT_FAILOVER_DATA_AGE:
|
||||||
msg = "Disconnected from master for longer than allowed. "
|
msg = "Disconnected from primary for longer than allowed. "
|
||||||
"Please check the 'cluster-replica-validity-factor' configuration "
|
"Please check the 'cluster-replica-validity-factor' configuration "
|
||||||
"option.";
|
"option.";
|
||||||
break;
|
break;
|
||||||
|
@ -961,7 +961,7 @@ struct COMMAND_STRUCT CLUSTER_Subcommands[] = {
|
|||||||
{MAKE_CMD("countkeysinslot","Returns the number of keys in a hash slot.","O(1)","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_COUNTKEYSINSLOT_History,0,CLUSTER_COUNTKEYSINSLOT_Tips,0,clusterCommand,3,CMD_STALE,0,CLUSTER_COUNTKEYSINSLOT_Keyspecs,0,NULL,1),.args=CLUSTER_COUNTKEYSINSLOT_Args},
|
{MAKE_CMD("countkeysinslot","Returns the number of keys in a hash slot.","O(1)","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_COUNTKEYSINSLOT_History,0,CLUSTER_COUNTKEYSINSLOT_Tips,0,clusterCommand,3,CMD_STALE,0,CLUSTER_COUNTKEYSINSLOT_Keyspecs,0,NULL,1),.args=CLUSTER_COUNTKEYSINSLOT_Args},
|
||||||
{MAKE_CMD("delslots","Sets hash slots as unbound for a node.","O(N) where N is the total number of hash slot arguments","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_DELSLOTS_History,0,CLUSTER_DELSLOTS_Tips,0,clusterCommand,-3,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_STALE,0,CLUSTER_DELSLOTS_Keyspecs,0,NULL,1),.args=CLUSTER_DELSLOTS_Args},
|
{MAKE_CMD("delslots","Sets hash slots as unbound for a node.","O(N) where N is the total number of hash slot arguments","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_DELSLOTS_History,0,CLUSTER_DELSLOTS_Tips,0,clusterCommand,-3,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_STALE,0,CLUSTER_DELSLOTS_Keyspecs,0,NULL,1),.args=CLUSTER_DELSLOTS_Args},
|
||||||
{MAKE_CMD("delslotsrange","Sets hash slot ranges as unbound for a node.","O(N) where N is the total number of the slots between the start slot and end slot arguments.","7.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_DELSLOTSRANGE_History,0,CLUSTER_DELSLOTSRANGE_Tips,0,clusterCommand,-4,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_STALE,0,CLUSTER_DELSLOTSRANGE_Keyspecs,0,NULL,1),.args=CLUSTER_DELSLOTSRANGE_Args},
|
{MAKE_CMD("delslotsrange","Sets hash slot ranges as unbound for a node.","O(N) where N is the total number of the slots between the start slot and end slot arguments.","7.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_DELSLOTSRANGE_History,0,CLUSTER_DELSLOTSRANGE_Tips,0,clusterCommand,-4,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_STALE,0,CLUSTER_DELSLOTSRANGE_Keyspecs,0,NULL,1),.args=CLUSTER_DELSLOTSRANGE_Args},
|
||||||
{MAKE_CMD("failover","Forces a replica to perform a manual failover of its master.","O(1)","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_FAILOVER_History,0,CLUSTER_FAILOVER_Tips,0,clusterCommand,-2,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_STALE,0,CLUSTER_FAILOVER_Keyspecs,0,NULL,1),.args=CLUSTER_FAILOVER_Args},
|
{MAKE_CMD("failover","Forces a replica to perform a manual failover of its primary.","O(1)","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_FAILOVER_History,0,CLUSTER_FAILOVER_Tips,0,clusterCommand,-2,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_STALE,0,CLUSTER_FAILOVER_Keyspecs,0,NULL,1),.args=CLUSTER_FAILOVER_Args},
|
||||||
{MAKE_CMD("flushslots","Deletes all slots information from a node.","O(1)","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_FLUSHSLOTS_History,0,CLUSTER_FLUSHSLOTS_Tips,0,clusterCommand,2,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_STALE,0,CLUSTER_FLUSHSLOTS_Keyspecs,0,NULL,0)},
|
{MAKE_CMD("flushslots","Deletes all slots information from a node.","O(1)","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_FLUSHSLOTS_History,0,CLUSTER_FLUSHSLOTS_Tips,0,clusterCommand,2,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_STALE,0,CLUSTER_FLUSHSLOTS_Keyspecs,0,NULL,0)},
|
||||||
{MAKE_CMD("forget","Removes a node from the nodes table.","O(1)","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_FORGET_History,0,CLUSTER_FORGET_Tips,0,clusterCommand,3,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_STALE,0,CLUSTER_FORGET_Keyspecs,0,NULL,1),.args=CLUSTER_FORGET_Args},
|
{MAKE_CMD("forget","Removes a node from the nodes table.","O(1)","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_FORGET_History,0,CLUSTER_FORGET_Tips,0,clusterCommand,3,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_STALE,0,CLUSTER_FORGET_Keyspecs,0,NULL,1),.args=CLUSTER_FORGET_Args},
|
||||||
{MAKE_CMD("getkeysinslot","Returns the key names in a hash slot.","O(N) where N is the number of requested keys","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_GETKEYSINSLOT_History,0,CLUSTER_GETKEYSINSLOT_Tips,1,clusterCommand,4,CMD_STALE,0,CLUSTER_GETKEYSINSLOT_Keyspecs,0,NULL,2),.args=CLUSTER_GETKEYSINSLOT_Args},
|
{MAKE_CMD("getkeysinslot","Returns the key names in a hash slot.","O(N) where N is the number of requested keys","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_GETKEYSINSLOT_History,0,CLUSTER_GETKEYSINSLOT_Tips,1,clusterCommand,4,CMD_STALE,0,CLUSTER_GETKEYSINSLOT_Keyspecs,0,NULL,2),.args=CLUSTER_GETKEYSINSLOT_Args},
|
||||||
@ -973,14 +973,14 @@ struct COMMAND_STRUCT CLUSTER_Subcommands[] = {
|
|||||||
{MAKE_CMD("myid","Returns the ID of a node.","O(1)","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_MYID_History,0,CLUSTER_MYID_Tips,0,clusterCommand,2,CMD_LOADING|CMD_STALE,0,CLUSTER_MYID_Keyspecs,0,NULL,0)},
|
{MAKE_CMD("myid","Returns the ID of a node.","O(1)","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_MYID_History,0,CLUSTER_MYID_Tips,0,clusterCommand,2,CMD_LOADING|CMD_STALE,0,CLUSTER_MYID_Keyspecs,0,NULL,0)},
|
||||||
{MAKE_CMD("myshardid","Returns the shard ID of a node.","O(1)","7.2.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_MYSHARDID_History,0,CLUSTER_MYSHARDID_Tips,1,clusterCommand,2,CMD_LOADING|CMD_STALE,0,CLUSTER_MYSHARDID_Keyspecs,0,NULL,0)},
|
{MAKE_CMD("myshardid","Returns the shard ID of a node.","O(1)","7.2.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_MYSHARDID_History,0,CLUSTER_MYSHARDID_Tips,1,clusterCommand,2,CMD_LOADING|CMD_STALE,0,CLUSTER_MYSHARDID_Keyspecs,0,NULL,0)},
|
||||||
{MAKE_CMD("nodes","Returns the cluster configuration for a node.","O(N) where N is the total number of Cluster nodes","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_NODES_History,0,CLUSTER_NODES_Tips,1,clusterCommand,2,CMD_LOADING|CMD_STALE,0,CLUSTER_NODES_Keyspecs,0,NULL,0)},
|
{MAKE_CMD("nodes","Returns the cluster configuration for a node.","O(N) where N is the total number of Cluster nodes","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_NODES_History,0,CLUSTER_NODES_Tips,1,clusterCommand,2,CMD_LOADING|CMD_STALE,0,CLUSTER_NODES_Keyspecs,0,NULL,0)},
|
||||||
{MAKE_CMD("replicas","Lists the replica nodes of a master node.","O(N) where N is the number of replicas.","5.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_REPLICAS_History,0,CLUSTER_REPLICAS_Tips,1,clusterCommand,3,CMD_ADMIN|CMD_STALE,0,CLUSTER_REPLICAS_Keyspecs,0,NULL,1),.args=CLUSTER_REPLICAS_Args},
|
{MAKE_CMD("replicas","Lists the replica nodes of a primary node.","O(N) where N is the number of replicas.","5.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_REPLICAS_History,0,CLUSTER_REPLICAS_Tips,1,clusterCommand,3,CMD_ADMIN|CMD_STALE,0,CLUSTER_REPLICAS_Keyspecs,0,NULL,1),.args=CLUSTER_REPLICAS_Args},
|
||||||
{MAKE_CMD("replicate","Configure a node as replica of a master node.","O(1)","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_REPLICATE_History,0,CLUSTER_REPLICATE_Tips,0,clusterCommand,3,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_STALE,0,CLUSTER_REPLICATE_Keyspecs,0,NULL,1),.args=CLUSTER_REPLICATE_Args},
|
{MAKE_CMD("replicate","Configure a node as replica of a primary node.","O(1)","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_REPLICATE_History,0,CLUSTER_REPLICATE_Tips,0,clusterCommand,3,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_STALE,0,CLUSTER_REPLICATE_Keyspecs,0,NULL,1),.args=CLUSTER_REPLICATE_Args},
|
||||||
{MAKE_CMD("reset","Resets a node.","O(N) where N is the number of known nodes. The command may execute a FLUSHALL as a side effect.","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_RESET_History,0,CLUSTER_RESET_Tips,0,clusterCommand,-2,CMD_ADMIN|CMD_STALE|CMD_NOSCRIPT,0,CLUSTER_RESET_Keyspecs,0,NULL,1),.args=CLUSTER_RESET_Args},
|
{MAKE_CMD("reset","Resets a node.","O(N) where N is the number of known nodes. The command may execute a FLUSHALL as a side effect.","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_RESET_History,0,CLUSTER_RESET_Tips,0,clusterCommand,-2,CMD_ADMIN|CMD_STALE|CMD_NOSCRIPT,0,CLUSTER_RESET_Keyspecs,0,NULL,1),.args=CLUSTER_RESET_Args},
|
||||||
{MAKE_CMD("saveconfig","Forces a node to save the cluster configuration to disk.","O(1)","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_SAVECONFIG_History,0,CLUSTER_SAVECONFIG_Tips,0,clusterCommand,2,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_STALE,0,CLUSTER_SAVECONFIG_Keyspecs,0,NULL,0)},
|
{MAKE_CMD("saveconfig","Forces a node to save the cluster configuration to disk.","O(1)","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_SAVECONFIG_History,0,CLUSTER_SAVECONFIG_Tips,0,clusterCommand,2,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_STALE,0,CLUSTER_SAVECONFIG_Keyspecs,0,NULL,0)},
|
||||||
{MAKE_CMD("set-config-epoch","Sets the configuration epoch for a new node.","O(1)","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_SET_CONFIG_EPOCH_History,0,CLUSTER_SET_CONFIG_EPOCH_Tips,0,clusterCommand,3,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_STALE,0,CLUSTER_SET_CONFIG_EPOCH_Keyspecs,0,NULL,1),.args=CLUSTER_SET_CONFIG_EPOCH_Args},
|
{MAKE_CMD("set-config-epoch","Sets the configuration epoch for a new node.","O(1)","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_SET_CONFIG_EPOCH_History,0,CLUSTER_SET_CONFIG_EPOCH_Tips,0,clusterCommand,3,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_STALE,0,CLUSTER_SET_CONFIG_EPOCH_Keyspecs,0,NULL,1),.args=CLUSTER_SET_CONFIG_EPOCH_Args},
|
||||||
{MAKE_CMD("setslot","Binds a hash slot to a node.","O(1)","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_SETSLOT_History,1,CLUSTER_SETSLOT_Tips,0,clusterCommand,-4,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_STALE|CMD_MAY_REPLICATE,0,CLUSTER_SETSLOT_Keyspecs,0,NULL,3),.args=CLUSTER_SETSLOT_Args},
|
{MAKE_CMD("setslot","Binds a hash slot to a node.","O(1)","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_SETSLOT_History,1,CLUSTER_SETSLOT_Tips,0,clusterCommand,-4,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_STALE|CMD_MAY_REPLICATE,0,CLUSTER_SETSLOT_Keyspecs,0,NULL,3),.args=CLUSTER_SETSLOT_Args},
|
||||||
{MAKE_CMD("shards","Returns the mapping of cluster slots to shards.","O(N) where N is the total number of cluster nodes","7.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_SHARDS_History,0,CLUSTER_SHARDS_Tips,1,clusterCommand,2,CMD_LOADING|CMD_STALE,0,CLUSTER_SHARDS_Keyspecs,0,NULL,0)},
|
{MAKE_CMD("shards","Returns the mapping of cluster slots to shards.","O(N) where N is the total number of cluster nodes","7.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_SHARDS_History,0,CLUSTER_SHARDS_Tips,1,clusterCommand,2,CMD_LOADING|CMD_STALE,0,CLUSTER_SHARDS_Keyspecs,0,NULL,0)},
|
||||||
{MAKE_CMD("slaves","Lists the replica nodes of a master node.","O(N) where N is the number of replicas.","3.0.0",CMD_DOC_DEPRECATED,"`CLUSTER REPLICAS`","5.0.0","cluster",COMMAND_GROUP_CLUSTER,CLUSTER_SLAVES_History,0,CLUSTER_SLAVES_Tips,1,clusterCommand,3,CMD_ADMIN|CMD_STALE,0,CLUSTER_SLAVES_Keyspecs,0,NULL,1),.args=CLUSTER_SLAVES_Args},
|
{MAKE_CMD("slaves","Lists the replica nodes of a primary node.","O(N) where N is the number of replicas.","3.0.0",CMD_DOC_DEPRECATED,"`CLUSTER REPLICAS`","5.0.0","cluster",COMMAND_GROUP_CLUSTER,CLUSTER_SLAVES_History,0,CLUSTER_SLAVES_Tips,1,clusterCommand,3,CMD_ADMIN|CMD_STALE,0,CLUSTER_SLAVES_Keyspecs,0,NULL,1),.args=CLUSTER_SLAVES_Args},
|
||||||
{MAKE_CMD("slots","Returns the mapping of cluster slots to nodes.","O(N) where N is the total number of Cluster nodes","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_SLOTS_History,2,CLUSTER_SLOTS_Tips,1,clusterCommand,2,CMD_LOADING|CMD_STALE,0,CLUSTER_SLOTS_Keyspecs,0,NULL,0)},
|
{MAKE_CMD("slots","Returns the mapping of cluster slots to nodes.","O(N) where N is the total number of Cluster nodes","3.0.0",CMD_DOC_NONE,NULL,NULL,"cluster",COMMAND_GROUP_CLUSTER,CLUSTER_SLOTS_History,2,CLUSTER_SLOTS_Tips,1,clusterCommand,2,CMD_LOADING|CMD_STALE,0,CLUSTER_SLOTS_Keyspecs,0,NULL,0)},
|
||||||
{0}
|
{0}
|
||||||
};
|
};
|
||||||
@ -1187,6 +1187,7 @@ commandHistory CLIENT_KILL_History[] = {
|
|||||||
{"5.0.0","Replaced `slave` `TYPE` with `replica`. `slave` still supported for backward compatibility."},
|
{"5.0.0","Replaced `slave` `TYPE` with `replica`. `slave` still supported for backward compatibility."},
|
||||||
{"6.2.0","`LADDR` option."},
|
{"6.2.0","`LADDR` option."},
|
||||||
{"8.0.0","`MAXAGE` option."},
|
{"8.0.0","`MAXAGE` option."},
|
||||||
|
{"8.0.0","Replaced `master` `TYPE` with `primary`. `master` still supported for backward compatibility."},
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1204,6 +1205,7 @@ commandHistory CLIENT_KILL_History[] = {
|
|||||||
struct COMMAND_ARG CLIENT_KILL_filter_new_format_client_type_Subargs[] = {
|
struct COMMAND_ARG CLIENT_KILL_filter_new_format_client_type_Subargs[] = {
|
||||||
{MAKE_ARG("normal",ARG_TYPE_PURE_TOKEN,-1,"NORMAL",NULL,NULL,CMD_ARG_NONE,0,NULL)},
|
{MAKE_ARG("normal",ARG_TYPE_PURE_TOKEN,-1,"NORMAL",NULL,NULL,CMD_ARG_NONE,0,NULL)},
|
||||||
{MAKE_ARG("master",ARG_TYPE_PURE_TOKEN,-1,"MASTER",NULL,"3.2.0",CMD_ARG_NONE,0,NULL)},
|
{MAKE_ARG("master",ARG_TYPE_PURE_TOKEN,-1,"MASTER",NULL,"3.2.0",CMD_ARG_NONE,0,NULL)},
|
||||||
|
{MAKE_ARG("primary",ARG_TYPE_PURE_TOKEN,-1,"PRIMARY",NULL,"8.0.0",CMD_ARG_NONE,0,NULL)},
|
||||||
{MAKE_ARG("slave",ARG_TYPE_PURE_TOKEN,-1,"SLAVE",NULL,NULL,CMD_ARG_NONE,0,NULL)},
|
{MAKE_ARG("slave",ARG_TYPE_PURE_TOKEN,-1,"SLAVE",NULL,NULL,CMD_ARG_NONE,0,NULL)},
|
||||||
{MAKE_ARG("replica",ARG_TYPE_PURE_TOKEN,-1,"REPLICA",NULL,"5.0.0",CMD_ARG_NONE,0,NULL)},
|
{MAKE_ARG("replica",ARG_TYPE_PURE_TOKEN,-1,"REPLICA",NULL,"5.0.0",CMD_ARG_NONE,0,NULL)},
|
||||||
{MAKE_ARG("pubsub",ARG_TYPE_PURE_TOKEN,-1,"PUBSUB",NULL,NULL,CMD_ARG_NONE,0,NULL)},
|
{MAKE_ARG("pubsub",ARG_TYPE_PURE_TOKEN,-1,"PUBSUB",NULL,NULL,CMD_ARG_NONE,0,NULL)},
|
||||||
@ -1218,7 +1220,7 @@ struct COMMAND_ARG CLIENT_KILL_filter_new_format_skipme_Subargs[] = {
|
|||||||
/* CLIENT KILL filter new_format argument table */
|
/* CLIENT KILL filter new_format argument table */
|
||||||
struct COMMAND_ARG CLIENT_KILL_filter_new_format_Subargs[] = {
|
struct COMMAND_ARG CLIENT_KILL_filter_new_format_Subargs[] = {
|
||||||
{MAKE_ARG("client-id",ARG_TYPE_INTEGER,-1,"ID",NULL,"2.8.12",CMD_ARG_OPTIONAL,0,NULL)},
|
{MAKE_ARG("client-id",ARG_TYPE_INTEGER,-1,"ID",NULL,"2.8.12",CMD_ARG_OPTIONAL,0,NULL)},
|
||||||
{MAKE_ARG("client-type",ARG_TYPE_ONEOF,-1,"TYPE",NULL,"2.8.12",CMD_ARG_OPTIONAL,5,NULL),.subargs=CLIENT_KILL_filter_new_format_client_type_Subargs},
|
{MAKE_ARG("client-type",ARG_TYPE_ONEOF,-1,"TYPE",NULL,"2.8.12",CMD_ARG_OPTIONAL,6,NULL),.subargs=CLIENT_KILL_filter_new_format_client_type_Subargs},
|
||||||
{MAKE_ARG("username",ARG_TYPE_STRING,-1,"USER",NULL,NULL,CMD_ARG_OPTIONAL,0,NULL)},
|
{MAKE_ARG("username",ARG_TYPE_STRING,-1,"USER",NULL,NULL,CMD_ARG_OPTIONAL,0,NULL)},
|
||||||
{MAKE_ARG("addr",ARG_TYPE_STRING,-1,"ADDR",NULL,NULL,CMD_ARG_OPTIONAL,0,NULL),.display_text="ip:port"},
|
{MAKE_ARG("addr",ARG_TYPE_STRING,-1,"ADDR",NULL,NULL,CMD_ARG_OPTIONAL,0,NULL),.display_text="ip:port"},
|
||||||
{MAKE_ARG("laddr",ARG_TYPE_STRING,-1,"LADDR",NULL,"6.2.0",CMD_ARG_OPTIONAL,0,NULL),.display_text="ip:port"},
|
{MAKE_ARG("laddr",ARG_TYPE_STRING,-1,"LADDR",NULL,"6.2.0",CMD_ARG_OPTIONAL,0,NULL),.display_text="ip:port"},
|
||||||
@ -1248,6 +1250,7 @@ commandHistory CLIENT_LIST_History[] = {
|
|||||||
{"6.2.0","Added `argv-mem`, `tot-mem`, `laddr` and `redir` fields and the optional `ID` filter."},
|
{"6.2.0","Added `argv-mem`, `tot-mem`, `laddr` and `redir` fields and the optional `ID` filter."},
|
||||||
{"7.0.0","Added `resp`, `multi-mem`, `rbs` and `rbp` fields."},
|
{"7.0.0","Added `resp`, `multi-mem`, `rbs` and `rbp` fields."},
|
||||||
{"7.0.3","Added `ssub` field."},
|
{"7.0.3","Added `ssub` field."},
|
||||||
|
{"8.0.0","Replaced `master` `TYPE` with `primary`. `master` still supported for backward compatibility."},
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1554,8 +1557,8 @@ struct COMMAND_STRUCT CLIENT_Subcommands[] = {
|
|||||||
{MAKE_CMD("help","Returns helpful text about the different subcommands.","O(1)","5.0.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_HELP_History,0,CLIENT_HELP_Tips,0,clientCommand,2,CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_HELP_Keyspecs,0,NULL,0)},
|
{MAKE_CMD("help","Returns helpful text about the different subcommands.","O(1)","5.0.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_HELP_History,0,CLIENT_HELP_Tips,0,clientCommand,2,CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_HELP_Keyspecs,0,NULL,0)},
|
||||||
{MAKE_CMD("id","Returns the unique client ID of the connection.","O(1)","5.0.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_ID_History,0,CLIENT_ID_Tips,0,clientCommand,2,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_ID_Keyspecs,0,NULL,0)},
|
{MAKE_CMD("id","Returns the unique client ID of the connection.","O(1)","5.0.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_ID_History,0,CLIENT_ID_Tips,0,clientCommand,2,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_ID_Keyspecs,0,NULL,0)},
|
||||||
{MAKE_CMD("info","Returns information about the connection.","O(1)","6.2.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_INFO_History,0,CLIENT_INFO_Tips,1,clientCommand,2,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_INFO_Keyspecs,0,NULL,0)},
|
{MAKE_CMD("info","Returns information about the connection.","O(1)","6.2.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_INFO_History,0,CLIENT_INFO_Tips,1,clientCommand,2,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_INFO_Keyspecs,0,NULL,0)},
|
||||||
{MAKE_CMD("kill","Terminates open connections.","O(N) where N is the number of client connections","2.4.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_KILL_History,6,CLIENT_KILL_Tips,0,clientCommand,-3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_KILL_Keyspecs,0,NULL,1),.args=CLIENT_KILL_Args},
|
{MAKE_CMD("kill","Terminates open connections.","O(N) where N is the number of client connections","2.4.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_KILL_History,7,CLIENT_KILL_Tips,0,clientCommand,-3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_KILL_Keyspecs,0,NULL,1),.args=CLIENT_KILL_Args},
|
||||||
{MAKE_CMD("list","Lists open connections.","O(N) where N is the number of client connections","2.4.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_LIST_History,6,CLIENT_LIST_Tips,1,clientCommand,-2,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_LIST_Keyspecs,0,NULL,2),.args=CLIENT_LIST_Args},
|
{MAKE_CMD("list","Lists open connections.","O(N) where N is the number of client connections","2.4.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_LIST_History,7,CLIENT_LIST_Tips,1,clientCommand,-2,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_LIST_Keyspecs,0,NULL,2),.args=CLIENT_LIST_Args},
|
||||||
{MAKE_CMD("no-evict","Sets the client eviction mode of the connection.","O(1)","7.0.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_NO_EVICT_History,0,CLIENT_NO_EVICT_Tips,0,clientCommand,3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_NO_EVICT_Keyspecs,0,NULL,1),.args=CLIENT_NO_EVICT_Args},
|
{MAKE_CMD("no-evict","Sets the client eviction mode of the connection.","O(1)","7.0.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_NO_EVICT_History,0,CLIENT_NO_EVICT_Tips,0,clientCommand,3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_NO_EVICT_Keyspecs,0,NULL,1),.args=CLIENT_NO_EVICT_Args},
|
||||||
{MAKE_CMD("no-touch","Controls whether commands sent by the client affect the LRU/LFU of accessed keys.","O(1)","7.2.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_NO_TOUCH_History,0,CLIENT_NO_TOUCH_Tips,0,clientCommand,3,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION,CLIENT_NO_TOUCH_Keyspecs,0,NULL,1),.args=CLIENT_NO_TOUCH_Args},
|
{MAKE_CMD("no-touch","Controls whether commands sent by the client affect the LRU/LFU of accessed keys.","O(1)","7.2.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_NO_TOUCH_History,0,CLIENT_NO_TOUCH_Tips,0,clientCommand,3,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION,CLIENT_NO_TOUCH_Keyspecs,0,NULL,1),.args=CLIENT_NO_TOUCH_Args},
|
||||||
{MAKE_CMD("pause","Suspends commands processing.","O(1)","3.0.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_PAUSE_History,1,CLIENT_PAUSE_Tips,0,clientCommand,-3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_PAUSE_Keyspecs,0,NULL,2),.args=CLIENT_PAUSE_Args},
|
{MAKE_CMD("pause","Suspends commands processing.","O(1)","3.0.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_PAUSE_History,1,CLIENT_PAUSE_Tips,0,clientCommand,-3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_PAUSE_Keyspecs,0,NULL,2),.args=CLIENT_PAUSE_Args},
|
||||||
@ -10816,7 +10819,7 @@ struct COMMAND_STRUCT serverCommandTable[] = {
|
|||||||
{MAKE_CMD("monitor","Listens for all requests received by the server in real-time.",NULL,"1.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,MONITOR_History,0,MONITOR_Tips,0,monitorCommand,1,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,0,MONITOR_Keyspecs,0,NULL,0)},
|
{MAKE_CMD("monitor","Listens for all requests received by the server in real-time.",NULL,"1.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,MONITOR_History,0,MONITOR_Tips,0,monitorCommand,1,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,0,MONITOR_Keyspecs,0,NULL,0)},
|
||||||
{MAKE_CMD("psync","An internal command used in replication.",NULL,"2.8.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,PSYNC_History,0,PSYNC_Tips,0,syncCommand,-3,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_NO_MULTI|CMD_NOSCRIPT,0,PSYNC_Keyspecs,0,NULL,2),.args=PSYNC_Args},
|
{MAKE_CMD("psync","An internal command used in replication.",NULL,"2.8.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,PSYNC_History,0,PSYNC_Tips,0,syncCommand,-3,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_NO_MULTI|CMD_NOSCRIPT,0,PSYNC_Keyspecs,0,NULL,2),.args=PSYNC_Args},
|
||||||
{MAKE_CMD("replconf","An internal command for configuring the replication stream.","O(1)","3.0.0",CMD_DOC_SYSCMD,NULL,NULL,"server",COMMAND_GROUP_SERVER,REPLCONF_History,0,REPLCONF_Tips,0,replconfCommand,-1,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_ALLOW_BUSY,0,REPLCONF_Keyspecs,0,NULL,0)},
|
{MAKE_CMD("replconf","An internal command for configuring the replication stream.","O(1)","3.0.0",CMD_DOC_SYSCMD,NULL,NULL,"server",COMMAND_GROUP_SERVER,REPLCONF_History,0,REPLCONF_Tips,0,replconfCommand,-1,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_ALLOW_BUSY,0,REPLCONF_Keyspecs,0,NULL,0)},
|
||||||
{MAKE_CMD("replicaof","Configures a server as replica of another, or promotes it to a master.","O(1)","5.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,REPLICAOF_History,0,REPLICAOF_Tips,0,replicaofCommand,3,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_NOSCRIPT|CMD_STALE,0,REPLICAOF_Keyspecs,0,NULL,1),.args=REPLICAOF_Args},
|
{MAKE_CMD("replicaof","Configures a server as replica of another, or promotes it to a primary.","O(1)","5.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,REPLICAOF_History,0,REPLICAOF_Tips,0,replicaofCommand,3,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_NOSCRIPT|CMD_STALE,0,REPLICAOF_Keyspecs,0,NULL,1),.args=REPLICAOF_Args},
|
||||||
{MAKE_CMD("restore-asking","An internal command for migrating keys in a cluster.","O(1) to create the new key and additional O(N*M) to reconstruct the serialized value, where N is the number of objects composing the value and M their average size. For small string values the time complexity is thus O(1)+O(1*M) where M is small, so simply O(1). However for sorted set values the complexity is O(N*M*log(N)) because inserting values into sorted sets is O(log(N)).","3.0.0",CMD_DOC_SYSCMD,NULL,NULL,"server",COMMAND_GROUP_SERVER,RESTORE_ASKING_History,3,RESTORE_ASKING_Tips,0,restoreCommand,-4,CMD_WRITE|CMD_DENYOOM|CMD_ASKING,ACL_CATEGORY_KEYSPACE|ACL_CATEGORY_DANGEROUS,RESTORE_ASKING_Keyspecs,1,NULL,7),.args=RESTORE_ASKING_Args},
|
{MAKE_CMD("restore-asking","An internal command for migrating keys in a cluster.","O(1) to create the new key and additional O(N*M) to reconstruct the serialized value, where N is the number of objects composing the value and M their average size. For small string values the time complexity is thus O(1)+O(1*M) where M is small, so simply O(1). However for sorted set values the complexity is O(N*M*log(N)) because inserting values into sorted sets is O(log(N)).","3.0.0",CMD_DOC_SYSCMD,NULL,NULL,"server",COMMAND_GROUP_SERVER,RESTORE_ASKING_History,3,RESTORE_ASKING_Tips,0,restoreCommand,-4,CMD_WRITE|CMD_DENYOOM|CMD_ASKING,ACL_CATEGORY_KEYSPACE|ACL_CATEGORY_DANGEROUS,RESTORE_ASKING_Keyspecs,1,NULL,7),.args=RESTORE_ASKING_Args},
|
||||||
{MAKE_CMD("role","Returns the replication role.","O(1)","2.8.12",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,ROLE_History,0,ROLE_Tips,0,roleCommand,1,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_FAST|CMD_SENTINEL,ACL_CATEGORY_ADMIN|ACL_CATEGORY_DANGEROUS,ROLE_Keyspecs,0,NULL,0)},
|
{MAKE_CMD("role","Returns the replication role.","O(1)","2.8.12",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,ROLE_History,0,ROLE_Tips,0,roleCommand,1,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_FAST|CMD_SENTINEL,ACL_CATEGORY_ADMIN|ACL_CATEGORY_DANGEROUS,ROLE_Keyspecs,0,NULL,0)},
|
||||||
{MAKE_CMD("save","Synchronously saves the database(s) to disk.","O(N) where N is the total number of keys in all databases","1.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,SAVE_History,0,SAVE_Tips,0,saveCommand,1,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_NOSCRIPT|CMD_NO_MULTI,0,SAVE_Keyspecs,0,NULL,0)},
|
{MAKE_CMD("save","Synchronously saves the database(s) to disk.","O(N) where N is the total number of keys in all databases","1.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,SAVE_History,0,SAVE_Tips,0,saveCommand,1,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_NOSCRIPT|CMD_NO_MULTI,0,SAVE_Keyspecs,0,NULL,0)},
|
||||||
|
@ -31,6 +31,10 @@
|
|||||||
[
|
[
|
||||||
"8.0.0",
|
"8.0.0",
|
||||||
"`MAXAGE` option."
|
"`MAXAGE` option."
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"8.0.0",
|
||||||
|
"Replaced `master` `TYPE` with `primary`. `master` still supported for backward compatibility."
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"command_flags": [
|
"command_flags": [
|
||||||
@ -84,6 +88,12 @@
|
|||||||
"token": "master",
|
"token": "master",
|
||||||
"since": "3.2.0"
|
"since": "3.2.0"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "primary",
|
||||||
|
"type": "pure-token",
|
||||||
|
"token": "primary",
|
||||||
|
"since": "8.0.0"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "slave",
|
"name": "slave",
|
||||||
"type": "pure-token",
|
"type": "pure-token",
|
||||||
|
@ -31,6 +31,10 @@
|
|||||||
[
|
[
|
||||||
"7.0.3",
|
"7.0.3",
|
||||||
"Added `ssub` field."
|
"Added `ssub` field."
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"8.0.0",
|
||||||
|
"Replaced `master` `TYPE` with `primary`. `master` still supported for backward compatibility."
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"command_flags": [
|
"command_flags": [
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"FAILOVER": {
|
"FAILOVER": {
|
||||||
"summary": "Forces a replica to perform a manual failover of its master.",
|
"summary": "Forces a replica to perform a manual failover of its primary.",
|
||||||
"complexity": "O(1)",
|
"complexity": "O(1)",
|
||||||
"group": "cluster",
|
"group": "cluster",
|
||||||
"since": "3.0.0",
|
"since": "3.0.0",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"REPLICAS": {
|
"REPLICAS": {
|
||||||
"summary": "Lists the replica nodes of a master node.",
|
"summary": "Lists the replica nodes of a primary node.",
|
||||||
"complexity": "O(N) where N is the number of replicas.",
|
"complexity": "O(N) where N is the number of replicas.",
|
||||||
"group": "cluster",
|
"group": "cluster",
|
||||||
"since": "5.0.0",
|
"since": "5.0.0",
|
||||||
@ -21,7 +21,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"reply_schema": {
|
"reply_schema": {
|
||||||
"description": "A list of replica nodes replicating from the specified master node provided in the same format used by CLUSTER NODES.",
|
"description": "A list of replica nodes replicating from the specified primary node provided in the same format used by CLUSTER NODES.",
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"REPLICATE": {
|
"REPLICATE": {
|
||||||
"summary": "Configure a node as replica of a master node.",
|
"summary": "Configure a node as replica of a primary node.",
|
||||||
"complexity": "O(1)",
|
"complexity": "O(1)",
|
||||||
"group": "cluster",
|
"group": "cluster",
|
||||||
"since": "3.0.0",
|
"since": "3.0.0",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"SLAVES": {
|
"SLAVES": {
|
||||||
"summary": "Lists the replica nodes of a master node.",
|
"summary": "Lists the replica nodes of a primary node.",
|
||||||
"complexity": "O(N) where N is the number of replicas.",
|
"complexity": "O(N) where N is the number of replicas.",
|
||||||
"group": "cluster",
|
"group": "cluster",
|
||||||
"since": "3.0.0",
|
"since": "3.0.0",
|
||||||
@ -26,7 +26,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"reply_schema": {
|
"reply_schema": {
|
||||||
"description": "A list of replica nodes replicating from the specified master node provided in the same format used by CLUSTER NODES.",
|
"description": "A list of replica nodes replicating from the specified primary node provided in the same format used by CLUSTER NODES.",
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"description": "Master node for the slot range.",
|
"description": "Primary node for the slot range.",
|
||||||
"minItems": 4,
|
"minItems": 4,
|
||||||
"maxItems": 4,
|
"maxItems": 4,
|
||||||
"items": [
|
"items": [
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"REPLICAOF": {
|
"REPLICAOF": {
|
||||||
"summary": "Configures a server as replica of another, or promotes it to a master.",
|
"summary": "Configures a server as replica of another, or promotes it to a primary.",
|
||||||
"complexity": "O(1)",
|
"complexity": "O(1)",
|
||||||
"group": "server",
|
"group": "server",
|
||||||
"since": "5.0.0",
|
"since": "5.0.0",
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
"const": "master"
|
"const": "master"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Current replication master offset.",
|
"description": "Current replication primary offset.",
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -65,18 +65,18 @@
|
|||||||
"const": "slave"
|
"const": "slave"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "IP of master.",
|
"description": "IP of primary.",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Port number of master.",
|
"description": "Port number of primary.",
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "State of the replication from the point of view of the master.",
|
"description": "State of the replication from the point of view of the primary.",
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"description": "The instance is in handshake with its master.",
|
"description": "The instance is in handshake with its primary.",
|
||||||
"const": "handshake"
|
"const": "handshake"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -84,15 +84,15 @@
|
|||||||
"const": "none"
|
"const": "none"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "The instance needs to connect to its master.",
|
"description": "The instance needs to connect to its primary.",
|
||||||
"const": "connect"
|
"const": "connect"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "The master-replica connection is in progress.",
|
"description": "The primary-replica connection is in progress.",
|
||||||
"const": "connecting"
|
"const": "connecting"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "The master and replica are trying to perform the synchronization.",
|
"description": "The primary and replica are trying to perform the synchronization.",
|
||||||
"const": "sync"
|
"const": "sync"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -106,7 +106,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "The amount of data received from the replica so far in terms of master replication offset.",
|
"description": "The amount of data received from the replica so far in terms of primary replication offset.",
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -120,7 +120,7 @@
|
|||||||
"const": "sentinel"
|
"const": "sentinel"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "List of master names monitored by this sentinel instance.",
|
"description": "List of primary names monitored by this sentinel instance.",
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
@ -2891,7 +2891,7 @@ static int setConfigReplicaOfOption(standardConfig *config, sds *argv, int argc,
|
|||||||
char *ptr;
|
char *ptr;
|
||||||
server.primary_port = strtol(argv[1], &ptr, 10);
|
server.primary_port = strtol(argv[1], &ptr, 10);
|
||||||
if (server.primary_port < 0 || server.primary_port > 65535 || *ptr != '\0') {
|
if (server.primary_port < 0 || server.primary_port > 65535 || *ptr != '\0') {
|
||||||
*err = "Invalid master port";
|
*err = "Invalid primary port";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
server.primary_host = sdsnew(argv[0]);
|
server.primary_host = sdsnew(argv[0]);
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "script.h"
|
#include "script.h"
|
||||||
#include "fpconv_dtoa.h"
|
#include "fpconv_dtoa.h"
|
||||||
#include "fmtargs.h"
|
#include "fmtargs.h"
|
||||||
|
#include <strings.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@ -586,11 +587,11 @@ void afterErrorReply(client *c, const char *s, size_t len, int flags) {
|
|||||||
to = "AOF-loading-client";
|
to = "AOF-loading-client";
|
||||||
from = "server";
|
from = "server";
|
||||||
} else if (ctype == CLIENT_TYPE_PRIMARY) {
|
} else if (ctype == CLIENT_TYPE_PRIMARY) {
|
||||||
to = "master";
|
to = "primary";
|
||||||
from = "replica";
|
from = "replica";
|
||||||
} else {
|
} else {
|
||||||
to = "replica";
|
to = "replica";
|
||||||
from = "master";
|
from = "primary";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len > 4096) len = 4096;
|
if (len > 4096) len = 4096;
|
||||||
@ -2232,7 +2233,7 @@ int processInlineBuffer(client *c) {
|
|||||||
sdsfreesplitres(argv, argc);
|
sdsfreesplitres(argv, argc);
|
||||||
serverLog(LL_WARNING, "WARNING: Receiving inline protocol from primary, primary stream corruption? Closing the "
|
serverLog(LL_WARNING, "WARNING: Receiving inline protocol from primary, primary stream corruption? Closing the "
|
||||||
"primary connection and discarding the cached primary.");
|
"primary connection and discarding the cached primary.");
|
||||||
setProtocolError("Master using the inline protocol. Desync?", c);
|
setProtocolError("Primary using the inline protocol. Desync?", c);
|
||||||
return C_ERR;
|
return C_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3075,7 +3076,7 @@ void clientCommand(client *c) {
|
|||||||
" Kill connections made from the specified address",
|
" Kill connections made from the specified address",
|
||||||
" * LADDR (<ip:port>|<unixsocket>:0)",
|
" * LADDR (<ip:port>|<unixsocket>:0)",
|
||||||
" Kill connections made to specified local address",
|
" Kill connections made to specified local address",
|
||||||
" * TYPE (NORMAL|MASTER|REPLICA|PUBSUB)",
|
" * TYPE (NORMAL|PRIMARY|REPLICA|PUBSUB)",
|
||||||
" Kill connections by type.",
|
" Kill connections by type.",
|
||||||
" * USER <username>",
|
" * USER <username>",
|
||||||
" Kill connections authenticated by <username>.",
|
" Kill connections authenticated by <username>.",
|
||||||
@ -3087,7 +3088,7 @@ void clientCommand(client *c) {
|
|||||||
" Kill connections older than the specified age.",
|
" Kill connections older than the specified age.",
|
||||||
"LIST [options ...]",
|
"LIST [options ...]",
|
||||||
" Return information about client connections. Options:",
|
" Return information about client connections. Options:",
|
||||||
" * TYPE (NORMAL|MASTER|REPLICA|PUBSUB)",
|
" * TYPE (NORMAL|PRIMARY|REPLICA|PUBSUB)",
|
||||||
" Return clients of specified type.",
|
" Return clients of specified type.",
|
||||||
"UNPAUSE",
|
"UNPAUSE",
|
||||||
" Stop the current client pause, resuming traffic.",
|
" Stop the current client pause, resuming traffic.",
|
||||||
@ -3898,7 +3899,7 @@ int getClientTypeByName(char *name) {
|
|||||||
return CLIENT_TYPE_REPLICA;
|
return CLIENT_TYPE_REPLICA;
|
||||||
else if (!strcasecmp(name, "pubsub"))
|
else if (!strcasecmp(name, "pubsub"))
|
||||||
return CLIENT_TYPE_PUBSUB;
|
return CLIENT_TYPE_PUBSUB;
|
||||||
else if (!strcasecmp(name, "master"))
|
else if (!strcasecmp(name, "master") || !strcasecmp(name, "primary"))
|
||||||
return CLIENT_TYPE_PRIMARY;
|
return CLIENT_TYPE_PRIMARY;
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1385,7 +1385,7 @@ sds getMemoryDoctorReport(void) {
|
|||||||
" * Big replica buffers: The replica output buffers in this instance are greater than 10MB for "
|
" * Big replica buffers: The replica output buffers in this instance are greater than 10MB for "
|
||||||
"each replica (on average). This likely means that there is some replica instance that is "
|
"each replica (on average). This likely means that there is some replica instance that is "
|
||||||
"struggling receiving data, either because it is too slow or because of networking issues. As a "
|
"struggling receiving data, either because it is too slow or because of networking issues. As a "
|
||||||
"result, data piles on the master output buffers. Please try to identify what replica is not "
|
"result, data piles on the primary output buffers. Please try to identify what replica is not "
|
||||||
"receiving data correctly and why. You can use the INFO output in order to check the replicas "
|
"receiving data correctly and why. You can use the INFO output in order to check the replicas "
|
||||||
"delays and the CLIENT LIST command to check the output buffers of each replica.\n\n");
|
"delays and the CLIENT LIST command to check the output buffers of each replica.\n\n");
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,8 @@
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
void replicationDiscardCachedMaster(void);
|
void replicationDiscardCachedPrimary(void);
|
||||||
void replicationResurrectCachedMaster(connection *conn);
|
void replicationResurrectCachedPrimary(connection *conn);
|
||||||
void replicationSendAck(void);
|
void replicationSendAck(void);
|
||||||
int replicaPutOnline(client *replica);
|
int replicaPutOnline(client *replica);
|
||||||
void replicaStartCommandStream(client *replica);
|
void replicaStartCommandStream(client *replica);
|
||||||
@ -114,7 +114,7 @@ int bg_unlink(const char *filename) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------- MASTER -------------------------------- */
|
/* ---------------------------------- PRIMARY -------------------------------- */
|
||||||
|
|
||||||
void createReplicationBacklog(void) {
|
void createReplicationBacklog(void) {
|
||||||
serverAssert(server.repl_backlog == NULL);
|
serverAssert(server.repl_backlog == NULL);
|
||||||
@ -420,7 +420,7 @@ void feedReplicationBuffer(char *s, size_t len) {
|
|||||||
* This function is used if the instance is a primary: we use the commands
|
* This function is used if the instance is a primary: we use the commands
|
||||||
* received by our clients in order to create the replication stream.
|
* received by our clients in order to create the replication stream.
|
||||||
* Instead if the instance is a replica and has sub-replicas attached, we use
|
* Instead if the instance is a replica and has sub-replicas attached, we use
|
||||||
* replicationFeedStreamFromMasterStream() */
|
* replicationFeedStreamFromPrimaryStream() */
|
||||||
void replicationFeedReplicas(int dictid, robj **argv, int argc) {
|
void replicationFeedReplicas(int dictid, robj **argv, int argc) {
|
||||||
int j, len;
|
int j, len;
|
||||||
char llstr[LONG_STR_SIZE];
|
char llstr[LONG_STR_SIZE];
|
||||||
@ -925,7 +925,7 @@ void syncCommand(client *c) {
|
|||||||
replicationUnsetPrimary();
|
replicationUnsetPrimary();
|
||||||
}
|
}
|
||||||
sds client = catClientInfoString(sdsempty(), c);
|
sds client = catClientInfoString(sdsempty(), c);
|
||||||
serverLog(LL_NOTICE, "MASTER MODE enabled (failover request from '%s')", client);
|
serverLog(LL_NOTICE, "PRIMARY MODE enabled (failover request from '%s')", client);
|
||||||
sdsfree(client);
|
sdsfree(client);
|
||||||
} else {
|
} else {
|
||||||
addReplyError(c, "PSYNC FAILOVER replid must match my replid.");
|
addReplyError(c, "PSYNC FAILOVER replid must match my replid.");
|
||||||
@ -1706,7 +1706,7 @@ void replicationEmptyDbCallback(dict *d) {
|
|||||||
/* Once we have a link with the primary and the synchronization was
|
/* Once we have a link with the primary and the synchronization was
|
||||||
* performed, this function materializes the primary client we store
|
* performed, this function materializes the primary client we store
|
||||||
* at server.primary, starting from the specified file descriptor. */
|
* at server.primary, starting from the specified file descriptor. */
|
||||||
void replicationCreateMasterClient(connection *conn, int dbid) {
|
void replicationCreatePrimaryClient(connection *conn, int dbid) {
|
||||||
server.primary = createClient(conn);
|
server.primary = createClient(conn);
|
||||||
if (conn) connSetReadHandler(server.primary->conn, readQueryFromClient);
|
if (conn) connSetReadHandler(server.primary->conn, readQueryFromClient);
|
||||||
|
|
||||||
@ -1793,11 +1793,11 @@ void disklessLoadDiscardTempDb(serverDb *tempDb) {
|
|||||||
* we have no way to incrementally feed our replicas after that.
|
* we have no way to incrementally feed our replicas after that.
|
||||||
* We want our replicas to resync with us as well, if we have any sub-replicas.
|
* We want our replicas to resync with us as well, if we have any sub-replicas.
|
||||||
* This is useful on readSyncBulkPayload in places where we just finished transferring db. */
|
* This is useful on readSyncBulkPayload in places where we just finished transferring db. */
|
||||||
void replicationAttachToNewMaster(void) {
|
void replicationAttachToNewPrimary(void) {
|
||||||
/* Replica starts to apply data from new primary, we must discard the cached
|
/* Replica starts to apply data from new primary, we must discard the cached
|
||||||
* primary structure. */
|
* primary structure. */
|
||||||
serverAssert(server.primary == NULL);
|
serverAssert(server.primary == NULL);
|
||||||
replicationDiscardCachedMaster();
|
replicationDiscardCachedPrimary();
|
||||||
|
|
||||||
disconnectReplicas(); /* Force our replicas to resync with us as well. */
|
disconnectReplicas(); /* Force our replicas to resync with us as well. */
|
||||||
freeReplicationBacklog(); /* Don't allow our chained replicas to PSYNC. */
|
freeReplicationBacklog(); /* Don't allow our chained replicas to PSYNC. */
|
||||||
@ -1825,7 +1825,7 @@ void readSyncBulkPayload(connection *conn) {
|
|||||||
if (server.repl_transfer_size == -1) {
|
if (server.repl_transfer_size == -1) {
|
||||||
nread = connSyncReadLine(conn, buf, 1024, server.repl_syncio_timeout * 1000);
|
nread = connSyncReadLine(conn, buf, 1024, server.repl_syncio_timeout * 1000);
|
||||||
if (nread == -1) {
|
if (nread == -1) {
|
||||||
serverLog(LL_WARNING, "I/O error reading bulk count from MASTER: %s", connGetLastError(conn));
|
serverLog(LL_WARNING, "I/O error reading bulk count from PRIMARY: %s", connGetLastError(conn));
|
||||||
goto error;
|
goto error;
|
||||||
} else {
|
} else {
|
||||||
/* nread here is returned by connSyncReadLine(), which calls syncReadLine() and
|
/* nread here is returned by connSyncReadLine(), which calls syncReadLine() and
|
||||||
@ -1834,7 +1834,7 @@ void readSyncBulkPayload(connection *conn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] == '-') {
|
if (buf[0] == '-') {
|
||||||
serverLog(LL_WARNING, "MASTER aborted replication with an error: %s", buf + 1);
|
serverLog(LL_WARNING, "PRIMARY aborted replication with an error: %s", buf + 1);
|
||||||
goto error;
|
goto error;
|
||||||
} else if (buf[0] == '\0') {
|
} else if (buf[0] == '\0') {
|
||||||
/* At this stage just a newline works as a PING in order to take
|
/* At this stage just a newline works as a PING in order to take
|
||||||
@ -1844,7 +1844,7 @@ void readSyncBulkPayload(connection *conn) {
|
|||||||
return;
|
return;
|
||||||
} else if (buf[0] != '$') {
|
} else if (buf[0] != '$') {
|
||||||
serverLog(LL_WARNING,
|
serverLog(LL_WARNING,
|
||||||
"Bad protocol from MASTER, the first byte is not '$' (we received '%s'), are you sure the host "
|
"Bad protocol from PRIMARY, the first byte is not '$' (we received '%s'), are you sure the host "
|
||||||
"and port are right?",
|
"and port are right?",
|
||||||
buf);
|
buf);
|
||||||
goto error;
|
goto error;
|
||||||
@ -1867,12 +1867,12 @@ void readSyncBulkPayload(connection *conn) {
|
|||||||
/* Set any repl_transfer_size to avoid entering this code path
|
/* Set any repl_transfer_size to avoid entering this code path
|
||||||
* at the next call. */
|
* at the next call. */
|
||||||
server.repl_transfer_size = 0;
|
server.repl_transfer_size = 0;
|
||||||
serverLog(LL_NOTICE, "MASTER <-> REPLICA sync: receiving streamed RDB from primary with EOF %s",
|
serverLog(LL_NOTICE, "PRIMARY <-> REPLICA sync: receiving streamed RDB from primary with EOF %s",
|
||||||
use_diskless_load ? "to parser" : "to disk");
|
use_diskless_load ? "to parser" : "to disk");
|
||||||
} else {
|
} else {
|
||||||
usemark = 0;
|
usemark = 0;
|
||||||
server.repl_transfer_size = strtol(buf + 1, NULL, 10);
|
server.repl_transfer_size = strtol(buf + 1, NULL, 10);
|
||||||
serverLog(LL_NOTICE, "MASTER <-> REPLICA sync: receiving %lld bytes from primary %s",
|
serverLog(LL_NOTICE, "PRIMARY <-> REPLICA sync: receiving %lld bytes from primary %s",
|
||||||
(long long)server.repl_transfer_size, use_diskless_load ? "to parser" : "to disk");
|
(long long)server.repl_transfer_size, use_diskless_load ? "to parser" : "to disk");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -1894,7 +1894,7 @@ void readSyncBulkPayload(connection *conn) {
|
|||||||
/* equivalent to EAGAIN */
|
/* equivalent to EAGAIN */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
serverLog(LL_WARNING, "I/O error trying to sync with MASTER: %s",
|
serverLog(LL_WARNING, "I/O error trying to sync with PRIMARY: %s",
|
||||||
(nread == -1) ? connGetLastError(conn) : "connection lost");
|
(nread == -1) ? connGetLastError(conn) : "connection lost");
|
||||||
cancelReplicationHandshake(1);
|
cancelReplicationHandshake(1);
|
||||||
return;
|
return;
|
||||||
@ -1925,7 +1925,7 @@ void readSyncBulkPayload(connection *conn) {
|
|||||||
if ((nwritten = write(server.repl_transfer_fd, buf, nread)) != nread) {
|
if ((nwritten = write(server.repl_transfer_fd, buf, nread)) != nread) {
|
||||||
serverLog(LL_WARNING,
|
serverLog(LL_WARNING,
|
||||||
"Write error or short write writing to the DB dump file "
|
"Write error or short write writing to the DB dump file "
|
||||||
"needed for MASTER <-> REPLICA synchronization: %s",
|
"needed for PRIMARY <-> REPLICA synchronization: %s",
|
||||||
(nwritten == -1) ? strerror(errno) : "short write");
|
(nwritten == -1) ? strerror(errno) : "short write");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -1996,9 +1996,9 @@ void readSyncBulkPayload(connection *conn) {
|
|||||||
|
|
||||||
moduleFireServerEvent(VALKEYMODULE_EVENT_REPL_ASYNC_LOAD, VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED, NULL);
|
moduleFireServerEvent(VALKEYMODULE_EVENT_REPL_ASYNC_LOAD, VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED, NULL);
|
||||||
} else {
|
} else {
|
||||||
replicationAttachToNewMaster();
|
replicationAttachToNewPrimary();
|
||||||
|
|
||||||
serverLog(LL_NOTICE, "MASTER <-> REPLICA sync: Flushing old data");
|
serverLog(LL_NOTICE, "PRIMARY <-> REPLICA sync: Flushing old data");
|
||||||
emptyData(-1, empty_db_flags, replicationEmptyDbCallback);
|
emptyData(-1, empty_db_flags, replicationEmptyDbCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2008,7 +2008,7 @@ void readSyncBulkPayload(connection *conn) {
|
|||||||
* time for non blocking loading. */
|
* time for non blocking loading. */
|
||||||
connSetReadHandler(conn, NULL);
|
connSetReadHandler(conn, NULL);
|
||||||
|
|
||||||
serverLog(LL_NOTICE, "MASTER <-> REPLICA sync: Loading DB in memory");
|
serverLog(LL_NOTICE, "PRIMARY <-> REPLICA sync: Loading DB in memory");
|
||||||
rdbSaveInfo rsi = RDB_SAVE_INFO_INIT;
|
rdbSaveInfo rsi = RDB_SAVE_INFO_INIT;
|
||||||
if (use_diskless_load) {
|
if (use_diskless_load) {
|
||||||
rio rdb;
|
rio rdb;
|
||||||
@ -2045,7 +2045,7 @@ void readSyncBulkPayload(connection *conn) {
|
|||||||
rdbLoadingCtx loadingCtx = {.dbarray = dbarray, .functions_lib_ctx = functions_lib_ctx};
|
rdbLoadingCtx loadingCtx = {.dbarray = dbarray, .functions_lib_ctx = functions_lib_ctx};
|
||||||
if (rdbLoadRioWithLoadingCtx(&rdb, RDBFLAGS_REPLICATION, &rsi, &loadingCtx) != C_OK) {
|
if (rdbLoadRioWithLoadingCtx(&rdb, RDBFLAGS_REPLICATION, &rsi, &loadingCtx) != C_OK) {
|
||||||
/* RDB loading failed. */
|
/* RDB loading failed. */
|
||||||
serverLog(LL_WARNING, "Failed trying to load the MASTER synchronization DB "
|
serverLog(LL_WARNING, "Failed trying to load the PRIMARY synchronization DB "
|
||||||
"from socket, check server logs.");
|
"from socket, check server logs.");
|
||||||
loadingFailed = 1;
|
loadingFailed = 1;
|
||||||
} else if (usemark) {
|
} else if (usemark) {
|
||||||
@ -2068,7 +2068,7 @@ void readSyncBulkPayload(connection *conn) {
|
|||||||
|
|
||||||
disklessLoadDiscardTempDb(diskless_load_tempDb);
|
disklessLoadDiscardTempDb(diskless_load_tempDb);
|
||||||
functionsLibCtxFree(temp_functions_lib_ctx);
|
functionsLibCtxFree(temp_functions_lib_ctx);
|
||||||
serverLog(LL_NOTICE, "MASTER <-> REPLICA sync: Discarding temporary DB in background");
|
serverLog(LL_NOTICE, "PRIMARY <-> REPLICA sync: Discarding temporary DB in background");
|
||||||
} else {
|
} else {
|
||||||
/* Remove the half-loaded data in case we started with an empty replica. */
|
/* Remove the half-loaded data in case we started with an empty replica. */
|
||||||
emptyData(-1, empty_db_flags, replicationEmptyDbCallback);
|
emptyData(-1, empty_db_flags, replicationEmptyDbCallback);
|
||||||
@ -2085,9 +2085,9 @@ void readSyncBulkPayload(connection *conn) {
|
|||||||
/* We will soon swap main db with tempDb and replicas will start
|
/* We will soon swap main db with tempDb and replicas will start
|
||||||
* to apply data from new primary, we must discard the cached
|
* to apply data from new primary, we must discard the cached
|
||||||
* primary structure and force resync of sub-replicas. */
|
* primary structure and force resync of sub-replicas. */
|
||||||
replicationAttachToNewMaster();
|
replicationAttachToNewPrimary();
|
||||||
|
|
||||||
serverLog(LL_NOTICE, "MASTER <-> REPLICA sync: Swapping active DB with loaded DB");
|
serverLog(LL_NOTICE, "PRIMARY <-> REPLICA sync: Swapping active DB with loaded DB");
|
||||||
swapMainDbWithTempDb(diskless_load_tempDb);
|
swapMainDbWithTempDb(diskless_load_tempDb);
|
||||||
|
|
||||||
/* swap existing functions ctx with the temporary one */
|
/* swap existing functions ctx with the temporary one */
|
||||||
@ -2098,7 +2098,7 @@ void readSyncBulkPayload(connection *conn) {
|
|||||||
|
|
||||||
/* Delete the old db as it's useless now. */
|
/* Delete the old db as it's useless now. */
|
||||||
disklessLoadDiscardTempDb(diskless_load_tempDb);
|
disklessLoadDiscardTempDb(diskless_load_tempDb);
|
||||||
serverLog(LL_NOTICE, "MASTER <-> REPLICA sync: Discarding old DB in background");
|
serverLog(LL_NOTICE, "PRIMARY <-> REPLICA sync: Discarding old DB in background");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Inform about db change, as replication was diskless and didn't cause a save. */
|
/* Inform about db change, as replication was diskless and didn't cause a save. */
|
||||||
@ -2117,7 +2117,7 @@ void readSyncBulkPayload(connection *conn) {
|
|||||||
if (fsync(server.repl_transfer_fd) == -1) {
|
if (fsync(server.repl_transfer_fd) == -1) {
|
||||||
serverLog(LL_WARNING,
|
serverLog(LL_WARNING,
|
||||||
"Failed trying to sync the temp DB to disk in "
|
"Failed trying to sync the temp DB to disk in "
|
||||||
"MASTER <-> REPLICA synchronization: %s",
|
"PRIMARY <-> REPLICA synchronization: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
cancelReplicationHandshake(1);
|
cancelReplicationHandshake(1);
|
||||||
return;
|
return;
|
||||||
@ -2128,7 +2128,7 @@ void readSyncBulkPayload(connection *conn) {
|
|||||||
if (rename(server.repl_transfer_tmpfile, server.rdb_filename) == -1) {
|
if (rename(server.repl_transfer_tmpfile, server.rdb_filename) == -1) {
|
||||||
serverLog(LL_WARNING,
|
serverLog(LL_WARNING,
|
||||||
"Failed trying to rename the temp DB into %s in "
|
"Failed trying to rename the temp DB into %s in "
|
||||||
"MASTER <-> REPLICA synchronization: %s",
|
"PRIMARY <-> REPLICA synchronization: %s",
|
||||||
server.rdb_filename, strerror(errno));
|
server.rdb_filename, strerror(errno));
|
||||||
cancelReplicationHandshake(1);
|
cancelReplicationHandshake(1);
|
||||||
if (old_rdb_fd != -1) close(old_rdb_fd);
|
if (old_rdb_fd != -1) close(old_rdb_fd);
|
||||||
@ -2141,14 +2141,14 @@ void readSyncBulkPayload(connection *conn) {
|
|||||||
if (fsyncFileDir(server.rdb_filename) == -1) {
|
if (fsyncFileDir(server.rdb_filename) == -1) {
|
||||||
serverLog(LL_WARNING,
|
serverLog(LL_WARNING,
|
||||||
"Failed trying to sync DB directory %s in "
|
"Failed trying to sync DB directory %s in "
|
||||||
"MASTER <-> REPLICA synchronization: %s",
|
"PRIMARY <-> REPLICA synchronization: %s",
|
||||||
server.rdb_filename, strerror(errno));
|
server.rdb_filename, strerror(errno));
|
||||||
cancelReplicationHandshake(1);
|
cancelReplicationHandshake(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rdbLoad(server.rdb_filename, &rsi, RDBFLAGS_REPLICATION) != RDB_OK) {
|
if (rdbLoad(server.rdb_filename, &rsi, RDBFLAGS_REPLICATION) != RDB_OK) {
|
||||||
serverLog(LL_WARNING, "Failed trying to load the MASTER synchronization "
|
serverLog(LL_WARNING, "Failed trying to load the PRIMARY synchronization "
|
||||||
"DB from disk, check server logs.");
|
"DB from disk, check server logs.");
|
||||||
cancelReplicationHandshake(1);
|
cancelReplicationHandshake(1);
|
||||||
if (server.rdb_del_sync_files && allPersistenceDisabled()) {
|
if (server.rdb_del_sync_files && allPersistenceDisabled()) {
|
||||||
@ -2181,7 +2181,7 @@ void readSyncBulkPayload(connection *conn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Final setup of the connected replica <- primary link */
|
/* Final setup of the connected replica <- primary link */
|
||||||
replicationCreateMasterClient(server.repl_transfer_s, rsi.repl_stream_db);
|
replicationCreatePrimaryClient(server.repl_transfer_s, rsi.repl_stream_db);
|
||||||
server.repl_state = REPL_STATE_CONNECTED;
|
server.repl_state = REPL_STATE_CONNECTED;
|
||||||
server.repl_down_since = 0;
|
server.repl_down_since = 0;
|
||||||
|
|
||||||
@ -2200,11 +2200,11 @@ void readSyncBulkPayload(connection *conn) {
|
|||||||
* or not, in order to behave correctly if they are promoted to
|
* or not, in order to behave correctly if they are promoted to
|
||||||
* primaries after a failover. */
|
* primaries after a failover. */
|
||||||
if (server.repl_backlog == NULL) createReplicationBacklog();
|
if (server.repl_backlog == NULL) createReplicationBacklog();
|
||||||
serverLog(LL_NOTICE, "MASTER <-> REPLICA sync: Finished with success");
|
serverLog(LL_NOTICE, "PRIMARY <-> REPLICA sync: Finished with success");
|
||||||
|
|
||||||
if (server.supervised_mode == SUPERVISED_SYSTEMD) {
|
if (server.supervised_mode == SUPERVISED_SYSTEMD) {
|
||||||
serverCommunicateSystemd(
|
serverCommunicateSystemd("STATUS=PRIMARY <-> REPLICA sync: Finished with success. Ready to accept connections "
|
||||||
"STATUS=MASTER <-> REPLICA sync: Finished with success. Ready to accept connections in read-write mode.\n");
|
"in read-write mode.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send the initial ACK immediately to put this replica in online state. */
|
/* Send the initial ACK immediately to put this replica in online state. */
|
||||||
@ -2314,7 +2314,7 @@ char *sendCommandArgv(connection *conn, int argc, char **argv, size_t *argv_lens
|
|||||||
* command in order to obtain the primary replid and the primary replication
|
* command in order to obtain the primary replid and the primary replication
|
||||||
* global offset.
|
* global offset.
|
||||||
*
|
*
|
||||||
* This function is designed to be called from syncWithMaster(), so the
|
* This function is designed to be called from syncWithPrimary(), so the
|
||||||
* following assumptions are made:
|
* following assumptions are made:
|
||||||
*
|
*
|
||||||
* 1) We pass the function an already connected socket "fd".
|
* 1) We pass the function an already connected socket "fd".
|
||||||
@ -2345,7 +2345,7 @@ char *sendCommandArgv(connection *conn, int argc, char **argv, size_t *argv_lens
|
|||||||
* the caller should fall back to SYNC.
|
* the caller should fall back to SYNC.
|
||||||
* PSYNC_WRITE_ERROR: There was an error writing the command to the socket.
|
* PSYNC_WRITE_ERROR: There was an error writing the command to the socket.
|
||||||
* PSYNC_WAIT_REPLY: Call again the function with read_reply set to 1.
|
* PSYNC_WAIT_REPLY: Call again the function with read_reply set to 1.
|
||||||
* PSYNC_TRY_LATER: Master is currently in a transient error condition.
|
* PSYNC_TRY_LATER: Primary is currently in a transient error condition.
|
||||||
*
|
*
|
||||||
* Notable side effects:
|
* Notable side effects:
|
||||||
*
|
*
|
||||||
@ -2406,10 +2406,10 @@ int replicaTryPartialResynchronization(connection *conn, int read_reply) {
|
|||||||
|
|
||||||
/* Reading half */
|
/* Reading half */
|
||||||
reply = receiveSynchronousResponse(conn);
|
reply = receiveSynchronousResponse(conn);
|
||||||
/* Master did not reply to PSYNC */
|
/* Primary did not reply to PSYNC */
|
||||||
if (reply == NULL) {
|
if (reply == NULL) {
|
||||||
connSetReadHandler(conn, NULL);
|
connSetReadHandler(conn, NULL);
|
||||||
serverLog(LL_WARNING, "Master did not reply to PSYNC, will try later");
|
serverLog(LL_WARNING, "Primary did not reply to PSYNC, will try later");
|
||||||
return PSYNC_TRY_LATER;
|
return PSYNC_TRY_LATER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2434,7 +2434,7 @@ int replicaTryPartialResynchronization(connection *conn, int read_reply) {
|
|||||||
if (offset) offset++;
|
if (offset) offset++;
|
||||||
}
|
}
|
||||||
if (!replid || !offset || (offset - replid - 1) != CONFIG_RUN_ID_SIZE) {
|
if (!replid || !offset || (offset - replid - 1) != CONFIG_RUN_ID_SIZE) {
|
||||||
serverLog(LL_WARNING, "Master replied with wrong +FULLRESYNC syntax.");
|
serverLog(LL_WARNING, "Primary replied with wrong +FULLRESYNC syntax.");
|
||||||
/* This is an unexpected condition, actually the +FULLRESYNC
|
/* This is an unexpected condition, actually the +FULLRESYNC
|
||||||
* reply means that the primary supports PSYNC, but the reply
|
* reply means that the primary supports PSYNC, but the reply
|
||||||
* format seems wrong. To stay safe we blank the primary
|
* format seems wrong. To stay safe we blank the primary
|
||||||
@ -2469,8 +2469,8 @@ int replicaTryPartialResynchronization(connection *conn, int read_reply) {
|
|||||||
new[CONFIG_RUN_ID_SIZE] = '\0';
|
new[CONFIG_RUN_ID_SIZE] = '\0';
|
||||||
|
|
||||||
if (strcmp(new, server.cached_primary->replid)) {
|
if (strcmp(new, server.cached_primary->replid)) {
|
||||||
/* Master ID changed. */
|
/* Primary ID changed. */
|
||||||
serverLog(LL_NOTICE, "Master replication ID changed to %s", new);
|
serverLog(LL_NOTICE, "Primary replication ID changed to %s", new);
|
||||||
|
|
||||||
/* Set the old ID as our ID2, up to the current offset+1. */
|
/* Set the old ID as our ID2, up to the current offset+1. */
|
||||||
memcpy(server.replid2, server.cached_primary->replid, sizeof(server.replid2));
|
memcpy(server.replid2, server.cached_primary->replid, sizeof(server.replid2));
|
||||||
@ -2488,7 +2488,7 @@ int replicaTryPartialResynchronization(connection *conn, int read_reply) {
|
|||||||
|
|
||||||
/* Setup the replication to continue. */
|
/* Setup the replication to continue. */
|
||||||
sdsfree(reply);
|
sdsfree(reply);
|
||||||
replicationResurrectCachedMaster(conn);
|
replicationResurrectCachedPrimary(conn);
|
||||||
|
|
||||||
/* If this instance was restarted and we read the metadata to
|
/* If this instance was restarted and we read the metadata to
|
||||||
* PSYNC from the persistence file, our replication backlog could
|
* PSYNC from the persistence file, our replication backlog could
|
||||||
@ -2506,7 +2506,7 @@ int replicaTryPartialResynchronization(connection *conn, int read_reply) {
|
|||||||
|
|
||||||
if (!strncmp(reply, "-NOMASTERLINK", 13) || !strncmp(reply, "-LOADING", 8)) {
|
if (!strncmp(reply, "-NOMASTERLINK", 13) || !strncmp(reply, "-LOADING", 8)) {
|
||||||
serverLog(LL_NOTICE,
|
serverLog(LL_NOTICE,
|
||||||
"Master is currently unable to PSYNC "
|
"Primary is currently unable to PSYNC "
|
||||||
"but should be in the future: %s",
|
"but should be in the future: %s",
|
||||||
reply);
|
reply);
|
||||||
sdsfree(reply);
|
sdsfree(reply);
|
||||||
@ -2518,7 +2518,7 @@ int replicaTryPartialResynchronization(connection *conn, int read_reply) {
|
|||||||
serverLog(LL_WARNING, "Unexpected reply to PSYNC from primary: %s", reply);
|
serverLog(LL_WARNING, "Unexpected reply to PSYNC from primary: %s", reply);
|
||||||
} else {
|
} else {
|
||||||
serverLog(LL_NOTICE,
|
serverLog(LL_NOTICE,
|
||||||
"Master does not support PSYNC or is in "
|
"Primary does not support PSYNC or is in "
|
||||||
"error state (reply: %s)",
|
"error state (reply: %s)",
|
||||||
reply);
|
reply);
|
||||||
}
|
}
|
||||||
@ -2528,7 +2528,7 @@ int replicaTryPartialResynchronization(connection *conn, int read_reply) {
|
|||||||
|
|
||||||
/* This handler fires when the non blocking connect was able to
|
/* This handler fires when the non blocking connect was able to
|
||||||
* establish a connection with the primary. */
|
* establish a connection with the primary. */
|
||||||
void syncWithMaster(connection *conn) {
|
void syncWithPrimary(connection *conn) {
|
||||||
char tmpfile[256], *err = NULL;
|
char tmpfile[256], *err = NULL;
|
||||||
int dfd = -1, maxtries = 5;
|
int dfd = -1, maxtries = 5;
|
||||||
int psync_result;
|
int psync_result;
|
||||||
@ -2552,7 +2552,7 @@ void syncWithMaster(connection *conn) {
|
|||||||
serverLog(LL_NOTICE, "Non blocking connect for SYNC fired the event.");
|
serverLog(LL_NOTICE, "Non blocking connect for SYNC fired the event.");
|
||||||
/* Delete the writable event so that the readable event remains
|
/* Delete the writable event so that the readable event remains
|
||||||
* registered and we can wait for the PONG reply. */
|
* registered and we can wait for the PONG reply. */
|
||||||
connSetReadHandler(conn, syncWithMaster);
|
connSetReadHandler(conn, syncWithPrimary);
|
||||||
connSetWriteHandler(conn, NULL);
|
connSetWriteHandler(conn, NULL);
|
||||||
server.repl_state = REPL_STATE_RECEIVE_PING_REPLY;
|
server.repl_state = REPL_STATE_RECEIVE_PING_REPLY;
|
||||||
/* Send the PING, don't check for errors at all, we have the timeout
|
/* Send the PING, don't check for errors at all, we have the timeout
|
||||||
@ -2580,7 +2580,7 @@ void syncWithMaster(connection *conn) {
|
|||||||
sdsfree(err);
|
sdsfree(err);
|
||||||
goto error;
|
goto error;
|
||||||
} else {
|
} else {
|
||||||
serverLog(LL_NOTICE, "Master replied to PING, replication can continue...");
|
serverLog(LL_NOTICE, "Primary replied to PING, replication can continue...");
|
||||||
}
|
}
|
||||||
sdsfree(err);
|
sdsfree(err);
|
||||||
err = NULL;
|
err = NULL;
|
||||||
@ -2605,7 +2605,7 @@ void syncWithMaster(connection *conn) {
|
|||||||
if (err) goto write_error;
|
if (err) goto write_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the replica port, so that Master's INFO command can list the
|
/* Set the replica port, so that primary's INFO command can list the
|
||||||
* replica listening port correctly. */
|
* replica listening port correctly. */
|
||||||
{
|
{
|
||||||
int port;
|
int port;
|
||||||
@ -2621,7 +2621,7 @@ void syncWithMaster(connection *conn) {
|
|||||||
if (err) goto write_error;
|
if (err) goto write_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the replica ip, so that Master's INFO command can list the
|
/* Set the replica ip, so that primary's INFO command can list the
|
||||||
* replica IP address port correctly in case of port forwarding or NAT.
|
* replica IP address port correctly in case of port forwarding or NAT.
|
||||||
* Skip REPLCONF ip-address if there is no replica-announce-ip option set. */
|
* Skip REPLCONF ip-address if there is no replica-announce-ip option set. */
|
||||||
if (server.replica_announce_ip) {
|
if (server.replica_announce_ip) {
|
||||||
@ -2654,7 +2654,7 @@ void syncWithMaster(connection *conn) {
|
|||||||
err = receiveSynchronousResponse(conn);
|
err = receiveSynchronousResponse(conn);
|
||||||
if (err == NULL) goto no_response_error;
|
if (err == NULL) goto no_response_error;
|
||||||
if (err[0] == '-') {
|
if (err[0] == '-') {
|
||||||
serverLog(LL_WARNING, "Unable to AUTH to MASTER: %s", err);
|
serverLog(LL_WARNING, "Unable to AUTH to PRIMARY: %s", err);
|
||||||
sdsfree(err);
|
sdsfree(err);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -2672,7 +2672,7 @@ void syncWithMaster(connection *conn) {
|
|||||||
* REPLCONF listening-port. */
|
* REPLCONF listening-port. */
|
||||||
if (err[0] == '-') {
|
if (err[0] == '-') {
|
||||||
serverLog(LL_NOTICE,
|
serverLog(LL_NOTICE,
|
||||||
"(Non critical) Master does not understand "
|
"(Non critical) Primary does not understand "
|
||||||
"REPLCONF listening-port: %s",
|
"REPLCONF listening-port: %s",
|
||||||
err);
|
err);
|
||||||
}
|
}
|
||||||
@ -2692,7 +2692,7 @@ void syncWithMaster(connection *conn) {
|
|||||||
* REPLCONF ip-address. */
|
* REPLCONF ip-address. */
|
||||||
if (err[0] == '-') {
|
if (err[0] == '-') {
|
||||||
serverLog(LL_NOTICE,
|
serverLog(LL_NOTICE,
|
||||||
"(Non critical) Master does not understand "
|
"(Non critical) Primary does not understand "
|
||||||
"REPLCONF ip-address: %s",
|
"REPLCONF ip-address: %s",
|
||||||
err);
|
err);
|
||||||
}
|
}
|
||||||
@ -2709,7 +2709,7 @@ void syncWithMaster(connection *conn) {
|
|||||||
* REPLCONF capa. */
|
* REPLCONF capa. */
|
||||||
if (err[0] == '-') {
|
if (err[0] == '-') {
|
||||||
serverLog(LL_NOTICE,
|
serverLog(LL_NOTICE,
|
||||||
"(Non critical) Master does not understand "
|
"(Non critical) Primary does not understand "
|
||||||
"REPLCONF capa: %s",
|
"REPLCONF capa: %s",
|
||||||
err);
|
err);
|
||||||
}
|
}
|
||||||
@ -2752,7 +2752,7 @@ void syncWithMaster(connection *conn) {
|
|||||||
/* If reached this point, we should be in REPL_STATE_RECEIVE_PSYNC_REPLY. */
|
/* If reached this point, we should be in REPL_STATE_RECEIVE_PSYNC_REPLY. */
|
||||||
if (server.repl_state != REPL_STATE_RECEIVE_PSYNC_REPLY) {
|
if (server.repl_state != REPL_STATE_RECEIVE_PSYNC_REPLY) {
|
||||||
serverLog(LL_WARNING,
|
serverLog(LL_WARNING,
|
||||||
"syncWithMaster(): state machine error, "
|
"syncWithPrimary(): state machine error, "
|
||||||
"state should be RECEIVE_PSYNC but is %d",
|
"state should be RECEIVE_PSYNC but is %d",
|
||||||
server.repl_state);
|
server.repl_state);
|
||||||
goto error;
|
goto error;
|
||||||
@ -2783,9 +2783,9 @@ void syncWithMaster(connection *conn) {
|
|||||||
* uninstalling the read handler from the file descriptor. */
|
* uninstalling the read handler from the file descriptor. */
|
||||||
|
|
||||||
if (psync_result == PSYNC_CONTINUE) {
|
if (psync_result == PSYNC_CONTINUE) {
|
||||||
serverLog(LL_NOTICE, "MASTER <-> REPLICA sync: Master accepted a Partial Resynchronization.");
|
serverLog(LL_NOTICE, "PRIMARY <-> REPLICA sync: Primary accepted a Partial Resynchronization.");
|
||||||
if (server.supervised_mode == SUPERVISED_SYSTEMD) {
|
if (server.supervised_mode == SUPERVISED_SYSTEMD) {
|
||||||
serverCommunicateSystemd("STATUS=MASTER <-> REPLICA sync: Partial Resynchronization accepted. Ready to "
|
serverCommunicateSystemd("STATUS=PRIMARY <-> REPLICA sync: Partial Resynchronization accepted. Ready to "
|
||||||
"accept connections in read-write mode.\n");
|
"accept connections in read-write mode.\n");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -2797,7 +2797,7 @@ void syncWithMaster(connection *conn) {
|
|||||||
if (psync_result == PSYNC_NOT_SUPPORTED) {
|
if (psync_result == PSYNC_NOT_SUPPORTED) {
|
||||||
serverLog(LL_NOTICE, "Retrying with SYNC...");
|
serverLog(LL_NOTICE, "Retrying with SYNC...");
|
||||||
if (connSyncWrite(conn, "SYNC\r\n", 6, server.repl_syncio_timeout * 1000) == -1) {
|
if (connSyncWrite(conn, "SYNC\r\n", 6, server.repl_syncio_timeout * 1000) == -1) {
|
||||||
serverLog(LL_WARNING, "I/O error writing to MASTER: %s", connGetLastError(conn));
|
serverLog(LL_WARNING, "I/O error writing to PRIMARY: %s", connGetLastError(conn));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2811,7 +2811,7 @@ void syncWithMaster(connection *conn) {
|
|||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
if (dfd == -1) {
|
if (dfd == -1) {
|
||||||
serverLog(LL_WARNING, "Opening the temp file needed for MASTER <-> REPLICA synchronization: %s",
|
serverLog(LL_WARNING, "Opening the temp file needed for PRIMARY <-> REPLICA synchronization: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -2835,7 +2835,7 @@ void syncWithMaster(connection *conn) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
no_response_error: /* Handle receiveSynchronousResponse() error when primary has no reply */
|
no_response_error: /* Handle receiveSynchronousResponse() error when primary has no reply */
|
||||||
serverLog(LL_WARNING, "Master did not respond to command during SYNC handshake");
|
serverLog(LL_WARNING, "Primary did not respond to command during SYNC handshake");
|
||||||
/* Fall through to regular error handling */
|
/* Fall through to regular error handling */
|
||||||
|
|
||||||
error:
|
error:
|
||||||
@ -2855,11 +2855,11 @@ write_error: /* Handle sendCommand() errors. */
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
int connectWithMaster(void) {
|
int connectWithPrimary(void) {
|
||||||
server.repl_transfer_s = connCreate(connTypeOfReplication());
|
server.repl_transfer_s = connCreate(connTypeOfReplication());
|
||||||
if (connConnect(server.repl_transfer_s, server.primary_host, server.primary_port, server.bind_source_addr,
|
if (connConnect(server.repl_transfer_s, server.primary_host, server.primary_port, server.bind_source_addr,
|
||||||
syncWithMaster) == C_ERR) {
|
syncWithPrimary) == C_ERR) {
|
||||||
serverLog(LL_WARNING, "Unable to connect to MASTER: %s", connGetLastError(server.repl_transfer_s));
|
serverLog(LL_WARNING, "Unable to connect to PRIMARY: %s", connGetLastError(server.repl_transfer_s));
|
||||||
connClose(server.repl_transfer_s);
|
connClose(server.repl_transfer_s);
|
||||||
server.repl_transfer_s = NULL;
|
server.repl_transfer_s = NULL;
|
||||||
return C_ERR;
|
return C_ERR;
|
||||||
@ -2868,7 +2868,7 @@ int connectWithMaster(void) {
|
|||||||
|
|
||||||
server.repl_transfer_lastio = server.unixtime;
|
server.repl_transfer_lastio = server.unixtime;
|
||||||
server.repl_state = REPL_STATE_CONNECTING;
|
server.repl_state = REPL_STATE_CONNECTING;
|
||||||
serverLog(LL_NOTICE, "MASTER <-> REPLICA sync started");
|
serverLog(LL_NOTICE, "PRIMARY <-> REPLICA sync started");
|
||||||
return C_OK;
|
return C_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2876,7 +2876,7 @@ int connectWithMaster(void) {
|
|||||||
* in progress to undo it.
|
* in progress to undo it.
|
||||||
* Never call this function directly, use cancelReplicationHandshake() instead.
|
* Never call this function directly, use cancelReplicationHandshake() instead.
|
||||||
*/
|
*/
|
||||||
void undoConnectWithMaster(void) {
|
void undoConnectWithPrimary(void) {
|
||||||
connClose(server.repl_transfer_s);
|
connClose(server.repl_transfer_s);
|
||||||
server.repl_transfer_s = NULL;
|
server.repl_transfer_s = NULL;
|
||||||
}
|
}
|
||||||
@ -2886,7 +2886,7 @@ void undoConnectWithMaster(void) {
|
|||||||
*/
|
*/
|
||||||
void replicationAbortSyncTransfer(void) {
|
void replicationAbortSyncTransfer(void) {
|
||||||
serverAssert(server.repl_state == REPL_STATE_TRANSFER);
|
serverAssert(server.repl_state == REPL_STATE_TRANSFER);
|
||||||
undoConnectWithMaster();
|
undoConnectWithPrimary();
|
||||||
if (server.repl_transfer_fd != -1) {
|
if (server.repl_transfer_fd != -1) {
|
||||||
close(server.repl_transfer_fd);
|
close(server.repl_transfer_fd);
|
||||||
bg_unlink(server.repl_transfer_tmpfile);
|
bg_unlink(server.repl_transfer_tmpfile);
|
||||||
@ -2909,7 +2909,7 @@ int cancelReplicationHandshake(int reconnect) {
|
|||||||
replicationAbortSyncTransfer();
|
replicationAbortSyncTransfer();
|
||||||
server.repl_state = REPL_STATE_CONNECT;
|
server.repl_state = REPL_STATE_CONNECT;
|
||||||
} else if (server.repl_state == REPL_STATE_CONNECTING || replicaIsInHandshakeState()) {
|
} else if (server.repl_state == REPL_STATE_CONNECTING || replicaIsInHandshakeState()) {
|
||||||
undoConnectWithMaster();
|
undoConnectWithPrimary();
|
||||||
server.repl_state = REPL_STATE_CONNECT;
|
server.repl_state = REPL_STATE_CONNECT;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
@ -2919,8 +2919,8 @@ int cancelReplicationHandshake(int reconnect) {
|
|||||||
|
|
||||||
/* try to re-connect without waiting for replicationCron, this is needed
|
/* try to re-connect without waiting for replicationCron, this is needed
|
||||||
* for the "diskless loading short read" test. */
|
* for the "diskless loading short read" test. */
|
||||||
serverLog(LL_NOTICE, "Reconnecting to MASTER %s:%d after failure", server.primary_host, server.primary_port);
|
serverLog(LL_NOTICE, "Reconnecting to PRIMARY %s:%d after failure", server.primary_host, server.primary_port);
|
||||||
connectWithMaster();
|
connectWithPrimary();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -2937,7 +2937,7 @@ void replicationSetPrimary(char *ip, int port) {
|
|||||||
disconnectAllBlockedClients(); /* Clients blocked in primary, now replica. */
|
disconnectAllBlockedClients(); /* Clients blocked in primary, now replica. */
|
||||||
|
|
||||||
/* Setting primary_host only after the call to freeClient since it calls
|
/* Setting primary_host only after the call to freeClient since it calls
|
||||||
* replicationHandleMasterDisconnection which can trigger a re-connect
|
* replicationHandlePrimaryDisconnection which can trigger a re-connect
|
||||||
* directly from within that call. */
|
* directly from within that call. */
|
||||||
server.primary_host = sdsnew(ip);
|
server.primary_host = sdsnew(ip);
|
||||||
server.primary_port = port;
|
server.primary_port = port;
|
||||||
@ -2955,7 +2955,7 @@ void replicationSetPrimary(char *ip, int port) {
|
|||||||
/* Before destroying our primary state, create a cached primary using
|
/* Before destroying our primary state, create a cached primary using
|
||||||
* our own parameters, to later PSYNC with the new primary. */
|
* our own parameters, to later PSYNC with the new primary. */
|
||||||
if (was_primary) {
|
if (was_primary) {
|
||||||
replicationDiscardCachedMaster();
|
replicationDiscardCachedPrimary();
|
||||||
replicationCachePrimaryUsingMyself();
|
replicationCachePrimaryUsingMyself();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2968,8 +2968,8 @@ void replicationSetPrimary(char *ip, int port) {
|
|||||||
moduleFireServerEvent(VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE, VALKEYMODULE_SUBEVENT_PRIMARY_LINK_DOWN, NULL);
|
moduleFireServerEvent(VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE, VALKEYMODULE_SUBEVENT_PRIMARY_LINK_DOWN, NULL);
|
||||||
|
|
||||||
server.repl_state = REPL_STATE_CONNECT;
|
server.repl_state = REPL_STATE_CONNECT;
|
||||||
serverLog(LL_NOTICE, "Connecting to MASTER %s:%d", server.primary_host, server.primary_port);
|
serverLog(LL_NOTICE, "Connecting to PRIMARY %s:%d", server.primary_host, server.primary_port);
|
||||||
connectWithMaster();
|
connectWithPrimary();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cancel replication, setting the instance as a primary itself. */
|
/* Cancel replication, setting the instance as a primary itself. */
|
||||||
@ -2981,11 +2981,11 @@ void replicationUnsetPrimary(void) {
|
|||||||
moduleFireServerEvent(VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE, VALKEYMODULE_SUBEVENT_PRIMARY_LINK_DOWN, NULL);
|
moduleFireServerEvent(VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE, VALKEYMODULE_SUBEVENT_PRIMARY_LINK_DOWN, NULL);
|
||||||
|
|
||||||
/* Clear primary_host first, since the freeClient calls
|
/* Clear primary_host first, since the freeClient calls
|
||||||
* replicationHandleMasterDisconnection which can attempt to re-connect. */
|
* replicationHandlePrimaryDisconnection which can attempt to re-connect. */
|
||||||
sdsfree(server.primary_host);
|
sdsfree(server.primary_host);
|
||||||
server.primary_host = NULL;
|
server.primary_host = NULL;
|
||||||
if (server.primary) freeClient(server.primary);
|
if (server.primary) freeClient(server.primary);
|
||||||
replicationDiscardCachedMaster();
|
replicationDiscardCachedPrimary();
|
||||||
cancelReplicationHandshake(0);
|
cancelReplicationHandshake(0);
|
||||||
/* When a replica is turned into a primary, the current replication ID
|
/* When a replica is turned into a primary, the current replication ID
|
||||||
* (that was inherited from the primary at synchronization time) is
|
* (that was inherited from the primary at synchronization time) is
|
||||||
@ -3043,8 +3043,8 @@ void replicationHandlePrimaryDisconnection(void) {
|
|||||||
/* Try to re-connect immediately rather than wait for replicationCron
|
/* Try to re-connect immediately rather than wait for replicationCron
|
||||||
* waiting 1 second may risk backlog being recycled. */
|
* waiting 1 second may risk backlog being recycled. */
|
||||||
if (server.primary_host) {
|
if (server.primary_host) {
|
||||||
serverLog(LL_NOTICE, "Reconnecting to MASTER %s:%d", server.primary_host, server.primary_port);
|
serverLog(LL_NOTICE, "Reconnecting to PRIMARY %s:%d", server.primary_host, server.primary_port);
|
||||||
connectWithMaster();
|
connectWithPrimary();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3067,7 +3067,7 @@ void replicaofCommand(client *c) {
|
|||||||
if (server.primary_host) {
|
if (server.primary_host) {
|
||||||
replicationUnsetPrimary();
|
replicationUnsetPrimary();
|
||||||
sds client = catClientInfoString(sdsempty(), c);
|
sds client = catClientInfoString(sdsempty(), c);
|
||||||
serverLog(LL_NOTICE, "MASTER MODE enabled (user request from '%s')", client);
|
serverLog(LL_NOTICE, "PRIMARY MODE enabled (user request from '%s')", client);
|
||||||
sdsfree(client);
|
sdsfree(client);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -3184,7 +3184,7 @@ void replicationSendAck(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------- MASTER CACHING FOR PSYNC -------------------------- */
|
/* ---------------------- PRIMARY CACHING FOR PSYNC -------------------------- */
|
||||||
|
|
||||||
/* In order to implement partial synchronization we need to be able to cache
|
/* In order to implement partial synchronization we need to be able to cache
|
||||||
* our primary's client structure after a transient disconnection.
|
* our primary's client structure after a transient disconnection.
|
||||||
@ -3198,10 +3198,10 @@ void replicationSendAck(void) {
|
|||||||
*
|
*
|
||||||
* The other functions that will deal with the cached primary are:
|
* The other functions that will deal with the cached primary are:
|
||||||
*
|
*
|
||||||
* replicationDiscardCachedMaster() that will make sure to kill the client
|
* replicationDiscardCachedPrimary() that will make sure to kill the client
|
||||||
* as for some reason we don't want to use it in the future.
|
* as for some reason we don't want to use it in the future.
|
||||||
*
|
*
|
||||||
* replicationResurrectCachedMaster() that is used after a successful PSYNC
|
* replicationResurrectCachedPrimary() that is used after a successful PSYNC
|
||||||
* handshake in order to reactivate the cached primary.
|
* handshake in order to reactivate the cached primary.
|
||||||
*/
|
*/
|
||||||
void replicationCachePrimary(client *c) {
|
void replicationCachePrimary(client *c) {
|
||||||
@ -3227,7 +3227,7 @@ void replicationCachePrimary(client *c) {
|
|||||||
resetClient(c);
|
resetClient(c);
|
||||||
|
|
||||||
/* Save the primary. Server.primary will be set to null later by
|
/* Save the primary. Server.primary will be set to null later by
|
||||||
* replicationHandleMasterDisconnection(). */
|
* replicationHandlePrimaryDisconnection(). */
|
||||||
server.cached_primary = server.primary;
|
server.cached_primary = server.primary;
|
||||||
|
|
||||||
/* Invalidate the Peer ID cache. */
|
/* Invalidate the Peer ID cache. */
|
||||||
@ -3262,14 +3262,14 @@ void replicationCachePrimaryUsingMyself(void) {
|
|||||||
"the new primary with just a partial transfer.");
|
"the new primary with just a partial transfer.");
|
||||||
|
|
||||||
/* This will be used to populate the field server.primary->reploff
|
/* This will be used to populate the field server.primary->reploff
|
||||||
* by replicationCreateMasterClient(). We'll later set the created
|
* by replicationCreatePrimaryClient(). We'll later set the created
|
||||||
* primary as server.cached_primary, so the replica will use such
|
* primary as server.cached_primary, so the replica will use such
|
||||||
* offset for PSYNC. */
|
* offset for PSYNC. */
|
||||||
server.primary_initial_offset = server.primary_repl_offset;
|
server.primary_initial_offset = server.primary_repl_offset;
|
||||||
|
|
||||||
/* The primary client we create can be set to any DBID, because
|
/* The primary client we create can be set to any DBID, because
|
||||||
* the new primary will start its replication stream with SELECT. */
|
* the new primary will start its replication stream with SELECT. */
|
||||||
replicationCreateMasterClient(NULL, -1);
|
replicationCreatePrimaryClient(NULL, -1);
|
||||||
|
|
||||||
/* Use our own ID / offset. */
|
/* Use our own ID / offset. */
|
||||||
memcpy(server.primary->replid, server.replid, sizeof(server.replid));
|
memcpy(server.primary->replid, server.replid, sizeof(server.replid));
|
||||||
@ -3282,7 +3282,7 @@ void replicationCachePrimaryUsingMyself(void) {
|
|||||||
|
|
||||||
/* Free a cached primary, called when there are no longer the conditions for
|
/* Free a cached primary, called when there are no longer the conditions for
|
||||||
* a partial resync on reconnection. */
|
* a partial resync on reconnection. */
|
||||||
void replicationDiscardCachedMaster(void) {
|
void replicationDiscardCachedPrimary(void) {
|
||||||
if (server.cached_primary == NULL) return;
|
if (server.cached_primary == NULL) return;
|
||||||
|
|
||||||
serverLog(LL_NOTICE, "Discarding previously cached primary state.");
|
serverLog(LL_NOTICE, "Discarding previously cached primary state.");
|
||||||
@ -3297,7 +3297,7 @@ void replicationDiscardCachedMaster(void) {
|
|||||||
* This function is called when successfully setup a partial resynchronization
|
* This function is called when successfully setup a partial resynchronization
|
||||||
* so the stream of data that we'll receive will start from where this
|
* so the stream of data that we'll receive will start from where this
|
||||||
* primary left. */
|
* primary left. */
|
||||||
void replicationResurrectCachedMaster(connection *conn) {
|
void replicationResurrectCachedPrimary(connection *conn) {
|
||||||
server.primary = server.cached_primary;
|
server.primary = server.cached_primary;
|
||||||
server.cached_primary = NULL;
|
server.cached_primary = NULL;
|
||||||
server.primary->conn = conn;
|
server.primary->conn = conn;
|
||||||
@ -3363,8 +3363,8 @@ int checkGoodReplicasStatus(void) {
|
|||||||
/* ----------------------- SYNCHRONOUS REPLICATION --------------------------
|
/* ----------------------- SYNCHRONOUS REPLICATION --------------------------
|
||||||
* Synchronous replication design can be summarized in points:
|
* Synchronous replication design can be summarized in points:
|
||||||
*
|
*
|
||||||
* - Masters have a global replication offset, used by PSYNC.
|
* - Primary have a global replication offset, used by PSYNC.
|
||||||
* - Master increment the offset every time new commands are sent to replicas.
|
* - Primary increment the offset every time new commands are sent to replicas.
|
||||||
* - Replicas ping back primary with the offset processed so far.
|
* - Replicas ping back primary with the offset processed so far.
|
||||||
*
|
*
|
||||||
* So synchronous replication adds a new WAIT command in the form:
|
* So synchronous replication adds a new WAIT command in the form:
|
||||||
@ -3620,14 +3620,14 @@ void replicationCron(void) {
|
|||||||
/* Non blocking connection timeout? */
|
/* Non blocking connection timeout? */
|
||||||
if (server.primary_host && (server.repl_state == REPL_STATE_CONNECTING || replicaIsInHandshakeState()) &&
|
if (server.primary_host && (server.repl_state == REPL_STATE_CONNECTING || replicaIsInHandshakeState()) &&
|
||||||
(time(NULL) - server.repl_transfer_lastio) > server.repl_timeout) {
|
(time(NULL) - server.repl_transfer_lastio) > server.repl_timeout) {
|
||||||
serverLog(LL_WARNING, "Timeout connecting to the MASTER...");
|
serverLog(LL_WARNING, "Timeout connecting to the PRIMARY...");
|
||||||
cancelReplicationHandshake(1);
|
cancelReplicationHandshake(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Bulk transfer I/O timeout? */
|
/* Bulk transfer I/O timeout? */
|
||||||
if (server.primary_host && server.repl_state == REPL_STATE_TRANSFER &&
|
if (server.primary_host && server.repl_state == REPL_STATE_TRANSFER &&
|
||||||
(time(NULL) - server.repl_transfer_lastio) > server.repl_timeout) {
|
(time(NULL) - server.repl_transfer_lastio) > server.repl_timeout) {
|
||||||
serverLog(LL_WARNING, "Timeout receiving bulk data from MASTER... If the problem persists try to set the "
|
serverLog(LL_WARNING, "Timeout receiving bulk data from PRIMARY... If the problem persists try to set the "
|
||||||
"'repl-timeout' parameter in redis.conf to a larger value.");
|
"'repl-timeout' parameter in redis.conf to a larger value.");
|
||||||
cancelReplicationHandshake(1);
|
cancelReplicationHandshake(1);
|
||||||
}
|
}
|
||||||
@ -3635,14 +3635,14 @@ void replicationCron(void) {
|
|||||||
/* Timed out primary when we are an already connected replica? */
|
/* Timed out primary when we are an already connected replica? */
|
||||||
if (server.primary_host && server.repl_state == REPL_STATE_CONNECTED &&
|
if (server.primary_host && server.repl_state == REPL_STATE_CONNECTED &&
|
||||||
(time(NULL) - server.primary->last_interaction) > server.repl_timeout) {
|
(time(NULL) - server.primary->last_interaction) > server.repl_timeout) {
|
||||||
serverLog(LL_WARNING, "MASTER timeout: no data nor PING received...");
|
serverLog(LL_WARNING, "PRIMARY timeout: no data nor PING received...");
|
||||||
freeClient(server.primary);
|
freeClient(server.primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if we should connect to a MASTER */
|
/* Check if we should connect to a PRIMARY */
|
||||||
if (server.repl_state == REPL_STATE_CONNECT) {
|
if (server.repl_state == REPL_STATE_CONNECT) {
|
||||||
serverLog(LL_NOTICE, "Connecting to MASTER %s:%d", server.primary_host, server.primary_port);
|
serverLog(LL_NOTICE, "Connecting to PRIMARY %s:%d", server.primary_host, server.primary_port);
|
||||||
connectWithMaster();
|
connectWithPrimary();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send ACK to primary from time to time.
|
/* Send ACK to primary from time to time.
|
||||||
@ -4039,7 +4039,7 @@ void failoverCommand(client *c) {
|
|||||||
|
|
||||||
/* Failover cron function, checks coordinated failover state.
|
/* Failover cron function, checks coordinated failover state.
|
||||||
*
|
*
|
||||||
* Implementation note: The current implementation calls replicationSetMaster()
|
* Implementation note: The current implementation calls replicationSetPrimary()
|
||||||
* to start the failover request, this has some unintended side effects if the
|
* to start the failover request, this has some unintended side effects if the
|
||||||
* failover doesn't work like blocked clients will be unblocked and replicas will
|
* failover doesn't work like blocked clients will be unblocked and replicas will
|
||||||
* be disconnected. This could be optimized further.
|
* be disconnected. This could be optimized further.
|
||||||
|
@ -309,7 +309,7 @@ void rioFreeConn(rio *r, sds *remaining) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------- File descriptor implementation ------------------
|
/* ------------------- File descriptor implementation ------------------
|
||||||
* This target is used to write the RDB file to pipe, when the master just
|
* This target is used to write the RDB file to pipe, when the primary just
|
||||||
* streams the data to the replicas without creating an RDB on-disk image
|
* streams the data to the replicas without creating an RDB on-disk image
|
||||||
* (diskless replication option).
|
* (diskless replication option).
|
||||||
* It only implements writes. */
|
* It only implements writes. */
|
||||||
|
@ -837,7 +837,7 @@ static void showLatencyReport(void) {
|
|||||||
printf(" %d bytes payload\n", config.datasize);
|
printf(" %d bytes payload\n", config.datasize);
|
||||||
printf(" keep alive: %d\n", config.keepalive);
|
printf(" keep alive: %d\n", config.keepalive);
|
||||||
if (config.cluster_mode) {
|
if (config.cluster_mode) {
|
||||||
printf(" cluster mode: yes (%d masters)\n", config.cluster_node_count);
|
printf(" cluster mode: yes (%d primaries)\n", config.cluster_node_count);
|
||||||
int m;
|
int m;
|
||||||
for (m = 0; m < config.cluster_node_count; m++) {
|
for (m = 0; m < config.cluster_node_count; m++) {
|
||||||
clusterNode *node = config.cluster_nodes[m];
|
clusterNode *node = config.cluster_nodes[m];
|
||||||
@ -1202,7 +1202,7 @@ static int fetchClusterConfiguration(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (node->slots_count == 0) {
|
if (node->slots_count == 0) {
|
||||||
fprintf(stderr, "WARNING: Master node %s:%d has no slots, skipping...\n", node->ip, node->port);
|
fprintf(stderr, "WARNING: Primary node %s:%d has no slots, skipping...\n", node->ip, node->port);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!addClusterNode(node)) {
|
if (!addClusterNode(node)) {
|
||||||
@ -1747,7 +1747,7 @@ int main(int argc, char **argv) {
|
|||||||
fprintf(stderr, "Invalid cluster: %d node(s).\n", config.cluster_node_count);
|
fprintf(stderr, "Invalid cluster: %d node(s).\n", config.cluster_node_count);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
printf("Cluster has %d master nodes:\n\n", config.cluster_node_count);
|
printf("Cluster has %d primary nodes:\n\n", config.cluster_node_count);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (; i < config.cluster_node_count; i++) {
|
for (; i < config.cluster_node_count; i++) {
|
||||||
clusterNode *node = config.cluster_nodes[i];
|
clusterNode *node = config.cluster_nodes[i];
|
||||||
@ -1755,7 +1755,7 @@ int main(int argc, char **argv) {
|
|||||||
fprintf(stderr, "Invalid cluster node #%d\n", i);
|
fprintf(stderr, "Invalid cluster node #%d\n", i);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
printf("Master %d: ", i);
|
printf("Primary %d: ", i);
|
||||||
if (node->name) printf("%s ", node->name);
|
if (node->name) printf("%s ", node->name);
|
||||||
printf("%s:%d\n", node->ip, node->port);
|
printf("%s:%d\n", node->ip, node->port);
|
||||||
node->redis_config = getServerConfig(node->ip, node->port, NULL);
|
node->redis_config = getServerConfig(node->ip, node->port, NULL);
|
||||||
|
@ -2603,9 +2603,7 @@ static int parseOptions(int argc, char **argv) {
|
|||||||
} else if (!strcmp(argv[i], "--lru-test") && !lastarg) {
|
} else if (!strcmp(argv[i], "--lru-test") && !lastarg) {
|
||||||
config.lru_test_mode = 1;
|
config.lru_test_mode = 1;
|
||||||
config.lru_test_sample_size = strtoll(argv[++i], NULL, 10);
|
config.lru_test_sample_size = strtoll(argv[++i], NULL, 10);
|
||||||
} else if (!strcmp(argv[i], "--slave")) {
|
} else if (!strcmp(argv[i], "--slave") || !strcmp(argv[i], "--replica")) {
|
||||||
config.replica_mode = 1;
|
|
||||||
} else if (!strcmp(argv[i], "--replica")) {
|
|
||||||
config.replica_mode = 1;
|
config.replica_mode = 1;
|
||||||
} else if (!strcmp(argv[i], "--stat")) {
|
} else if (!strcmp(argv[i], "--stat")) {
|
||||||
config.stat_mode = 1;
|
config.stat_mode = 1;
|
||||||
@ -3148,11 +3146,11 @@ void cliLoadPreferences(void) {
|
|||||||
* history file. Currently these commands are include:
|
* history file. Currently these commands are include:
|
||||||
* - AUTH
|
* - AUTH
|
||||||
* - ACL DELUSER, ACL SETUSER, ACL GETUSER
|
* - ACL DELUSER, ACL SETUSER, ACL GETUSER
|
||||||
* - CONFIG SET masterauth/masteruser/tls-key-file-pass/tls-client-key-file-pass/requirepass
|
* - CONFIG SET primaryauth/primaryuser/tls-key-file-pass/tls-client-key-file-pass/requirepass
|
||||||
* - HELLO with [AUTH username password]
|
* - HELLO with [AUTH username password]
|
||||||
* - MIGRATE with [AUTH password] or [AUTH2 username password]
|
* - MIGRATE with [AUTH password] or [AUTH2 username password]
|
||||||
* - SENTINEL CONFIG SET sentinel-pass password, SENTINEL CONFIG SET sentinel-user username
|
* - SENTINEL CONFIG SET sentinel-pass password, SENTINEL CONFIG SET sentinel-user username
|
||||||
* - SENTINEL SET <mastername> auth-pass password, SENTINEL SET <mastername> auth-user username */
|
* - SENTINEL SET <primaryname> auth-pass password, SENTINEL SET <primaryname> auth-user username */
|
||||||
static int isSensitiveCommand(int argc, char **argv) {
|
static int isSensitiveCommand(int argc, char **argv) {
|
||||||
if (!strcasecmp(argv[0], "auth")) {
|
if (!strcasecmp(argv[0], "auth")) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -3202,8 +3200,8 @@ static int isSensitiveCommand(int argc, char **argv) {
|
|||||||
(!strcasecmp(argv[3], "sentinel-pass") || !strcasecmp(argv[3], "sentinel-user"))) {
|
(!strcasecmp(argv[3], "sentinel-pass") || !strcasecmp(argv[3], "sentinel-user"))) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/* SENTINEL SET <mastername> auth-pass password
|
/* SENTINEL SET <primaryname> auth-pass password
|
||||||
* SENTINEL SET <mastername> auth-user username */
|
* SENTINEL SET <primaryname> auth-user username */
|
||||||
if (!strcasecmp(argv[1], "set") && (!strcasecmp(argv[3], "auth-pass") || !strcasecmp(argv[3], "auth-user"))) {
|
if (!strcasecmp(argv[1], "set") && (!strcasecmp(argv[3], "auth-pass") || !strcasecmp(argv[3], "auth-user"))) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -4165,7 +4163,7 @@ static void clusterManagerOptimizeAntiAffinity(clusterManagerNodeArray *ipnodes,
|
|||||||
clusterManagerNode **offenders = NULL;
|
clusterManagerNode **offenders = NULL;
|
||||||
int score = clusterManagerGetAntiAffinityScore(ipnodes, ip_count, NULL, NULL);
|
int score = clusterManagerGetAntiAffinityScore(ipnodes, ip_count, NULL, NULL);
|
||||||
if (score == 0) goto cleanup;
|
if (score == 0) goto cleanup;
|
||||||
clusterManagerLogInfo(">>> Trying to optimize slaves allocation "
|
clusterManagerLogInfo(">>> Trying to optimize replicas allocation "
|
||||||
"for anti-affinity\n");
|
"for anti-affinity\n");
|
||||||
int node_len = cluster_manager.nodes->len;
|
int node_len = cluster_manager.nodes->len;
|
||||||
int maxiter = 500 * node_len; // Effort is proportional to cluster size...
|
int maxiter = 500 * node_len; // Effort is proportional to cluster size...
|
||||||
@ -4219,9 +4217,9 @@ static void clusterManagerOptimizeAntiAffinity(clusterManagerNodeArray *ipnodes,
|
|||||||
if (perfect)
|
if (perfect)
|
||||||
msg = "[OK] Perfect anti-affinity obtained!";
|
msg = "[OK] Perfect anti-affinity obtained!";
|
||||||
else if (score >= 10000)
|
else if (score >= 10000)
|
||||||
msg = ("[WARNING] Some slaves are in the same host as their master");
|
msg = ("[WARNING] Some replicsa are in the same host as their primary");
|
||||||
else
|
else
|
||||||
msg = ("[WARNING] Some slaves of the same master are in the same host");
|
msg = ("[WARNING] Some replicas of the same primary are in the same host");
|
||||||
clusterManagerLog(log_level, "%s\n", msg);
|
clusterManagerLog(log_level, "%s\n", msg);
|
||||||
cleanup:
|
cleanup:
|
||||||
zfree(offenders);
|
zfree(offenders);
|
||||||
@ -4447,13 +4445,13 @@ static void clusterManagerShowClusterInfo(void) {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
if (reply != NULL) freeReplyObject(reply);
|
if (reply != NULL) freeReplyObject(reply);
|
||||||
printf("%s:%d (%s...) -> %lld keys | %d slots | %d slaves.\n", node->ip, node->port, name, dbsize,
|
printf("%s:%d (%s...) -> %lld keys | %d slots | %d replicas.\n", node->ip, node->port, name, dbsize,
|
||||||
node->slots_count, replicas);
|
node->slots_count, replicas);
|
||||||
primaries++;
|
primaries++;
|
||||||
keys += dbsize;
|
keys += dbsize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clusterManagerLogOk("[OK] %lld keys in %d masters.\n", keys, primaries);
|
clusterManagerLogOk("[OK] %lld keys in %d primaries.\n", keys, primaries);
|
||||||
float keys_per_slot = keys / (float)CLUSTER_MANAGER_SLOTS;
|
float keys_per_slot = keys / (float)CLUSTER_MANAGER_SLOTS;
|
||||||
printf("%.2f keys per slot on average.\n", keys_per_slot);
|
printf("%.2f keys per slot on average.\n", keys_per_slot);
|
||||||
}
|
}
|
||||||
@ -4993,7 +4991,8 @@ clusterManagerMoveSlot(clusterManagerNode *source, clusterManagerNode *target, i
|
|||||||
* unblocked with the role change error. */
|
* unblocked with the role change error. */
|
||||||
success = clusterManagerSetSlot(source, target, slot, "node", err);
|
success = clusterManagerSetSlot(source, target, slot, "node", err);
|
||||||
if (!success && err) {
|
if (!success && err) {
|
||||||
const char *acceptable[] = {"ERR Please use SETSLOT only with masters.", "UNBLOCKED"};
|
const char *acceptable[] = {"ERR Please use SETSLOT only with masters.",
|
||||||
|
"ERR Please use SETSLOT only with primaries.", "UNBLOCKED"};
|
||||||
for (size_t i = 0; i < sizeof(acceptable) / sizeof(acceptable[0]); i++) {
|
for (size_t i = 0; i < sizeof(acceptable) / sizeof(acceptable[0]); i++) {
|
||||||
if (!strncmp(*err, acceptable[i], strlen(acceptable[i]))) {
|
if (!strncmp(*err, acceptable[i], strlen(acceptable[i]))) {
|
||||||
zfree(*err);
|
zfree(*err);
|
||||||
@ -5264,7 +5263,7 @@ static int clusterManagerNodeLoadInfo(clusterManagerNode *node, int opts, char *
|
|||||||
currentNode->flags |= CLUSTER_MANAGER_FLAG_DISCONNECT;
|
currentNode->flags |= CLUSTER_MANAGER_FLAG_DISCONNECT;
|
||||||
else if (strcmp(flag, "fail") == 0)
|
else if (strcmp(flag, "fail") == 0)
|
||||||
currentNode->flags |= CLUSTER_MANAGER_FLAG_FAIL;
|
currentNode->flags |= CLUSTER_MANAGER_FLAG_FAIL;
|
||||||
else if (strcmp(flag, "slave") == 0) {
|
else if ((strcmp(flag, "slave") == 0) || (strcmp(flag, "replica") == 0)) {
|
||||||
currentNode->flags |= CLUSTER_MANAGER_FLAG_REPLICA;
|
currentNode->flags |= CLUSTER_MANAGER_FLAG_REPLICA;
|
||||||
if (primary_id != NULL) {
|
if (primary_id != NULL) {
|
||||||
if (currentNode->replicate) sdsfree(currentNode->replicate);
|
if (currentNode->replicate) sdsfree(currentNode->replicate);
|
||||||
@ -5352,7 +5351,7 @@ static int clusterManagerLoadInfoFromNode(clusterManagerNode *node) {
|
|||||||
clusterManagerNode *primary = clusterManagerNodeByName(n->replicate);
|
clusterManagerNode *primary = clusterManagerNodeByName(n->replicate);
|
||||||
if (primary == NULL) {
|
if (primary == NULL) {
|
||||||
clusterManagerLogWarn("*** WARNING: %s:%d claims to be "
|
clusterManagerLogWarn("*** WARNING: %s:%d claims to be "
|
||||||
"slave of unknown node ID %s.\n",
|
"replica of unknown node ID %s.\n",
|
||||||
n->ip, n->port, n->replicate);
|
n->ip, n->port, n->replicate);
|
||||||
} else
|
} else
|
||||||
primary->replicas_count++;
|
primary->replicas_count++;
|
||||||
@ -5712,10 +5711,10 @@ static int clusterManagerFixSlotsCoverage(char *all_slots) {
|
|||||||
|
|
||||||
if (cluster_manager.unreachable_primaries > 0 && !force_fix) {
|
if (cluster_manager.unreachable_primaries > 0 && !force_fix) {
|
||||||
clusterManagerLogWarn(
|
clusterManagerLogWarn(
|
||||||
"*** Fixing slots coverage with %d unreachable masters is dangerous: valkey-cli will assume that slots "
|
"*** Fixing slots coverage with %d unreachable primaries is dangerous: valkey-cli will assume that slots "
|
||||||
"about masters that are not reachable are not covered, and will try to reassign them to the reachable "
|
"about primaries that are not reachable are not covered, and will try to reassign them to the reachable "
|
||||||
"nodes. This can cause data loss and is rarely what you want to do. If you really want to proceed use the "
|
"nodes. This can cause data loss and is rarely what you want to do. If you really want to proceed use the "
|
||||||
"--cluster-fix-with-unreachable-masters option.\n",
|
"--cluster-fix-with-unreachable-primaries option.\n",
|
||||||
cluster_manager.unreachable_primaries);
|
cluster_manager.unreachable_primaries);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -5906,10 +5905,10 @@ static int clusterManagerFixOpenSlot(int slot) {
|
|||||||
|
|
||||||
if (cluster_manager.unreachable_primaries > 0 && !force_fix) {
|
if (cluster_manager.unreachable_primaries > 0 && !force_fix) {
|
||||||
clusterManagerLogWarn(
|
clusterManagerLogWarn(
|
||||||
"*** Fixing open slots with %d unreachable masters is dangerous: valkey-cli will assume that slots about "
|
"*** Fixing open slots with %d unreachable primaries is dangerous: valkey-cli will assume that slots about "
|
||||||
"masters that are not reachable are not covered, and will try to reassign them to the reachable nodes. "
|
"primaries that are not reachable are not covered, and will try to reassign them to the reachable nodes. "
|
||||||
"This can cause data loss and is rarely what you want to do. If you really want to proceed use the "
|
"This can cause data loss and is rarely what you want to do. If you really want to proceed use the "
|
||||||
"--cluster-fix-with-unreachable-masters option.\n",
|
"--cluster-fix-with-unreachable-primaries option.\n",
|
||||||
cluster_manager.unreachable_primaries);
|
cluster_manager.unreachable_primaries);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -6420,7 +6419,7 @@ static int clusterManagerCheckCluster(int quiet) {
|
|||||||
static clusterManagerNode *clusterNodeForResharding(char *id, clusterManagerNode *target, int *raise_err) {
|
static clusterManagerNode *clusterNodeForResharding(char *id, clusterManagerNode *target, int *raise_err) {
|
||||||
clusterManagerNode *node = NULL;
|
clusterManagerNode *node = NULL;
|
||||||
const char *invalid_node_msg = "*** The specified node (%s) is not known "
|
const char *invalid_node_msg = "*** The specified node (%s) is not known "
|
||||||
"or not a master, please retry.\n";
|
"or not a primary, please retry.\n";
|
||||||
node = clusterManagerNodeByName(id);
|
node = clusterManagerNodeByName(id);
|
||||||
*raise_err = 0;
|
*raise_err = 0;
|
||||||
if (!node || node->flags & CLUSTER_MANAGER_FLAG_REPLICA) {
|
if (!node || node->flags & CLUSTER_MANAGER_FLAG_REPLICA) {
|
||||||
@ -6642,7 +6641,7 @@ static int clusterManagerCommandCreate(int argc, char **argv) {
|
|||||||
int primaries_count = CLUSTER_MANAGER_PRIMARIES_COUNT(node_len, replicas);
|
int primaries_count = CLUSTER_MANAGER_PRIMARIES_COUNT(node_len, replicas);
|
||||||
if (primaries_count < 3) {
|
if (primaries_count < 3) {
|
||||||
clusterManagerLogErr("*** ERROR: Invalid configuration for cluster creation.\n"
|
clusterManagerLogErr("*** ERROR: Invalid configuration for cluster creation.\n"
|
||||||
"*** Valkey Cluster requires at least 3 master nodes.\n"
|
"*** Valkey Cluster requires at least 3 primary nodes.\n"
|
||||||
"*** This is not possible with %d nodes and %d replicas per node.",
|
"*** This is not possible with %d nodes and %d replicas per node.",
|
||||||
node_len, replicas);
|
node_len, replicas);
|
||||||
clusterManagerLogErr("\n*** At least %d nodes are required.\n", 3 * (replicas + 1));
|
clusterManagerLogErr("\n*** At least %d nodes are required.\n", 3 * (replicas + 1));
|
||||||
@ -6696,7 +6695,7 @@ static int clusterManagerCommandCreate(int argc, char **argv) {
|
|||||||
long last = lround(cursor + slots_per_node - 1);
|
long last = lround(cursor + slots_per_node - 1);
|
||||||
if (last > CLUSTER_MANAGER_SLOTS || i == (primaries_count - 1)) last = CLUSTER_MANAGER_SLOTS - 1;
|
if (last > CLUSTER_MANAGER_SLOTS || i == (primaries_count - 1)) last = CLUSTER_MANAGER_SLOTS - 1;
|
||||||
if (last < first) last = first;
|
if (last < first) last = first;
|
||||||
printf("Master[%d] -> Slots %ld - %ld\n", i, first, last);
|
printf("Primary[%d] -> Slots %ld - %ld\n", i, first, last);
|
||||||
primary->slots_count = 0;
|
primary->slots_count = 0;
|
||||||
for (j = first; j <= last; j++) {
|
for (j = first; j <= last; j++) {
|
||||||
primary->slots[j] = 1;
|
primary->slots[j] = 1;
|
||||||
@ -6907,13 +6906,13 @@ static int clusterManagerCommandAddNode(int argc, char **argv) {
|
|||||||
if (primary_id != NULL) {
|
if (primary_id != NULL) {
|
||||||
primary_node = clusterManagerNodeByName(primary_id);
|
primary_node = clusterManagerNodeByName(primary_id);
|
||||||
if (primary_node == NULL) {
|
if (primary_node == NULL) {
|
||||||
clusterManagerLogErr("[ERR] No such master ID %s\n", primary_id);
|
clusterManagerLogErr("[ERR] No such primary ID %s\n", primary_id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
primary_node = clusterManagerNodeWithLeastReplicas();
|
primary_node = clusterManagerNodeWithLeastReplicas();
|
||||||
assert(primary_node != NULL);
|
assert(primary_node != NULL);
|
||||||
printf("Automatically selected master %s:%d\n", primary_node->ip, primary_node->port);
|
printf("Automatically selected primary %s:%d\n", primary_node->ip, primary_node->port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7336,7 +7335,7 @@ static int clusterManagerCommandRebalance(int argc, char **argv) {
|
|||||||
float w = atof(++p);
|
float w = atof(++p);
|
||||||
clusterManagerNode *n = clusterManagerNodeByAbbreviatedName(name);
|
clusterManagerNode *n = clusterManagerNodeByAbbreviatedName(name);
|
||||||
if (n == NULL) {
|
if (n == NULL) {
|
||||||
clusterManagerLogErr("*** No such master node %s\n", name);
|
clusterManagerLogErr("*** No such primary node %s\n", name);
|
||||||
result = 0;
|
result = 0;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -8130,13 +8129,13 @@ unsigned long long sendSync(redisContext *c, int send_sync, char *out_eof, int *
|
|||||||
if (send_sync) {
|
if (send_sync) {
|
||||||
/* Send the SYNC command. */
|
/* Send the SYNC command. */
|
||||||
if (cliWriteConn(c, "SYNC\r\n", 6) != 6) {
|
if (cliWriteConn(c, "SYNC\r\n", 6) != 6) {
|
||||||
fprintf(stderr, "Error writing to master\n");
|
fprintf(stderr, "Error writing to primary\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* We have written the command into c->obuf before. */
|
/* We have written the command into c->obuf before. */
|
||||||
if (cliWriteConn(c, "", 0) != 0) {
|
if (cliWriteConn(c, "", 0) != 0) {
|
||||||
fprintf(stderr, "Error writing to master\n");
|
fprintf(stderr, "Error writing to primary\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8155,7 +8154,7 @@ unsigned long long sendSync(redisContext *c, int send_sync, char *out_eof, int *
|
|||||||
}
|
}
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
if (buf[0] == '-') {
|
if (buf[0] == '-') {
|
||||||
fprintf(stderr, "SYNC with master failed: %s\n", buf);
|
fprintf(stderr, "SYNC with primary failed: %s\n", buf);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8207,18 +8206,18 @@ static void replicaMode(int send_sync) {
|
|||||||
memset(lastbytes, 0, RDB_EOF_MARK_SIZE);
|
memset(lastbytes, 0, RDB_EOF_MARK_SIZE);
|
||||||
usemark = 1;
|
usemark = 1;
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s with master, discarding "
|
"%s with primary, discarding "
|
||||||
"bytes of bulk transfer until EOF marker...\n",
|
"bytes of bulk transfer until EOF marker...\n",
|
||||||
info);
|
info);
|
||||||
} else if (out_full_mode == 1 && payload != 0) {
|
} else if (out_full_mode == 1 && payload != 0) {
|
||||||
/* SYNC without EOF marker or PSYNC +FULLRESYNC. */
|
/* SYNC without EOF marker or PSYNC +FULLRESYNC. */
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s with master, discarding %llu "
|
"%s with primary, discarding %llu "
|
||||||
"bytes of bulk transfer...\n",
|
"bytes of bulk transfer...\n",
|
||||||
info, payload);
|
info, payload);
|
||||||
} else if (out_full_mode == 0 && payload == 0) {
|
} else if (out_full_mode == 0 && payload == 0) {
|
||||||
/* PSYNC +CONTINUE (no RDB payload). */
|
/* PSYNC +CONTINUE (no RDB payload). */
|
||||||
fprintf(stderr, "%s with master...\n", info);
|
fprintf(stderr, "%s with primary...\n", info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Discard the payload. */
|
/* Discard the payload. */
|
||||||
@ -8247,12 +8246,12 @@ static void replicaMode(int send_sync) {
|
|||||||
|
|
||||||
if (usemark) {
|
if (usemark) {
|
||||||
unsigned long long offset = ULLONG_MAX - payload;
|
unsigned long long offset = ULLONG_MAX - payload;
|
||||||
fprintf(stderr, "%s done after %llu bytes. Logging commands from master.\n", info, offset);
|
fprintf(stderr, "%s done after %llu bytes. Logging commands from primary.\n", info, offset);
|
||||||
/* put the replica online */
|
/* put the replica online */
|
||||||
sleep(1);
|
sleep(1);
|
||||||
sendReplconf("ACK", "0");
|
sendReplconf("ACK", "0");
|
||||||
} else
|
} else
|
||||||
fprintf(stderr, "%s done. Logging commands from master.\n", info);
|
fprintf(stderr, "%s done. Logging commands from primary.\n", info);
|
||||||
|
|
||||||
/* Now we can use hiredis to read the incoming protocol. */
|
/* Now we can use hiredis to read the incoming protocol. */
|
||||||
config.output = OUTPUT_CSV;
|
config.output = OUTPUT_CSV;
|
||||||
@ -8289,11 +8288,11 @@ static void getRDB(clusterManagerNode *node) {
|
|||||||
memset(lastbytes, 0, RDB_EOF_MARK_SIZE);
|
memset(lastbytes, 0, RDB_EOF_MARK_SIZE);
|
||||||
usemark = 1;
|
usemark = 1;
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"SYNC sent to master, writing bytes of bulk transfer "
|
"SYNC sent to primary, writing bytes of bulk transfer "
|
||||||
"until EOF marker to '%s'\n",
|
"until EOF marker to '%s'\n",
|
||||||
filename);
|
filename);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "SYNC sent to master, writing %llu bytes to '%s'\n", payload, filename);
|
fprintf(stderr, "SYNC sent to primary, writing %llu bytes to '%s'\n", payload, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
int write_to_stdout = !strcmp(filename, "-");
|
int write_to_stdout = !strcmp(filename, "-");
|
||||||
|
@ -1469,7 +1469,7 @@ VALKEYMODULE_API int (*ValkeyModule_SendClusterMessage)(ValkeyModuleCtx *ctx,
|
|||||||
VALKEYMODULE_API int (*ValkeyModule_GetClusterNodeInfo)(ValkeyModuleCtx *ctx,
|
VALKEYMODULE_API int (*ValkeyModule_GetClusterNodeInfo)(ValkeyModuleCtx *ctx,
|
||||||
const char *id,
|
const char *id,
|
||||||
char *ip,
|
char *ip,
|
||||||
char *master_id,
|
char *primary_id,
|
||||||
int *port,
|
int *port,
|
||||||
int *flags) VALKEYMODULE_ATTR;
|
int *flags) VALKEYMODULE_ATTR;
|
||||||
VALKEYMODULE_API char **(*ValkeyModule_GetClusterNodesList)(ValkeyModuleCtx *ctx, size_t *numnodes)VALKEYMODULE_ATTR;
|
VALKEYMODULE_API char **(*ValkeyModule_GetClusterNodesList)(ValkeyModuleCtx *ctx, size_t *numnodes)VALKEYMODULE_ATTR;
|
||||||
|
@ -51,7 +51,7 @@ start_server {tags {"repl network external:skip"}} {
|
|||||||
|
|
||||||
test {Slave is able to detect timeout during handshake} {
|
test {Slave is able to detect timeout during handshake} {
|
||||||
wait_for_condition 50 1000 {
|
wait_for_condition 50 1000 {
|
||||||
[log_file_matches $slave_log "*Timeout connecting to the MASTER*"]
|
[log_file_matches $slave_log "*Timeout connecting to the PRIMARY*"]
|
||||||
} else {
|
} else {
|
||||||
fail "Replica is not able to detect timeout"
|
fail "Replica is not able to detect timeout"
|
||||||
}
|
}
|
||||||
@ -1390,7 +1390,7 @@ start_server {tags {"repl" "external:skip"}} {
|
|||||||
|
|
||||||
# Check we got the warning logs about the GET command.
|
# Check we got the warning logs about the GET command.
|
||||||
verify_log_message 0 "*Replica generated a reply to command 'get', disconnecting it: *" $lines
|
verify_log_message 0 "*Replica generated a reply to command 'get', disconnecting it: *" $lines
|
||||||
verify_log_message 0 "*== CRITICAL == This master is sending an error to its replica: *" $lines
|
verify_log_message 0 "*== CRITICAL == This primary is sending an error to its replica: *" $lines
|
||||||
verify_log_message 0 "*Replica can't interact with the keyspace*" $lines
|
verify_log_message 0 "*Replica can't interact with the keyspace*" $lines
|
||||||
|
|
||||||
$rd close
|
$rd close
|
||||||
|
@ -74,7 +74,7 @@ start_server {tags {"auth_binary_password external:skip"}} {
|
|||||||
$slave slaveof $master_host $master_port
|
$slave slaveof $master_host $master_port
|
||||||
|
|
||||||
# Verify replica is not able to sync with master
|
# Verify replica is not able to sync with master
|
||||||
wait_for_log_messages 0 {"*Unable to AUTH to MASTER*"} $loglines 1000 10
|
wait_for_log_messages 0 {"*Unable to AUTH to PRIMARY*"} $loglines 1000 10
|
||||||
assert_equal {down} [s 0 master_link_status]
|
assert_equal {down} [s 0 master_link_status]
|
||||||
|
|
||||||
# Test replica with the correct primaryauth
|
# Test replica with the correct primaryauth
|
||||||
|
@ -827,9 +827,9 @@ start_server {tags {"introspection"}} {
|
|||||||
# Something like `valkey-server --some-config --config-value1 --config-value2 --loglevel debug` would break,
|
# Something like `valkey-server --some-config --config-value1 --config-value2 --loglevel debug` would break,
|
||||||
# because if you want to pass a value to a config starting with `--`, it can only be a single value.
|
# because if you want to pass a value to a config starting with `--`, it can only be a single value.
|
||||||
catch {exec src/valkey-server --replicaof 127.0.0.1 abc} err
|
catch {exec src/valkey-server --replicaof 127.0.0.1 abc} err
|
||||||
assert_match {*'replicaof "127.0.0.1" "abc"'*Invalid master port*} $err
|
assert_match {*'replicaof "127.0.0.1" "abc"'*Invalid primary port*} $err
|
||||||
catch {exec src/valkey-server --replicaof --127.0.0.1 abc} err
|
catch {exec src/valkey-server --replicaof --127.0.0.1 abc} err
|
||||||
assert_match {*'replicaof "--127.0.0.1" "abc"'*Invalid master port*} $err
|
assert_match {*'replicaof "--127.0.0.1" "abc"'*Invalid primary port*} $err
|
||||||
catch {exec src/valkey-server --replicaof --127.0.0.1 --abc} err
|
catch {exec src/valkey-server --replicaof --127.0.0.1 --abc} err
|
||||||
assert_match {*'replicaof "--127.0.0.1"'*wrong number of arguments*} $err
|
assert_match {*'replicaof "--127.0.0.1"'*wrong number of arguments*} $err
|
||||||
} {} {external:skip}
|
} {} {external:skip}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user