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,
|
||||
* and will be processed when the client is unblocked. */
|
||||
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));
|
||||
|
||||
c->flags |= CLIENT_BLOCKED;
|
||||
@ -265,8 +265,8 @@ void replyToClientsBlockedOnShutdown(void) {
|
||||
|
||||
/* Mass-unblock clients because something changed in the instance that makes
|
||||
* 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
|
||||
* is called when a master turns into a replica.
|
||||
* in an instance which turns from primary to replica is unsafe, so this function
|
||||
* is called when a primary turns into a replica.
|
||||
*
|
||||
* The semantics is to send an -UNBLOCKED error to the client, disconnecting
|
||||
* it at the same time. */
|
||||
|
@ -813,12 +813,12 @@ void clusterCommandHelp(client *c) {
|
||||
" Return the node's shard id.",
|
||||
"NODES",
|
||||
" 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>",
|
||||
" Return <node-id> replicas.",
|
||||
"SLOTS",
|
||||
" 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",
|
||||
" Return information about slot range mappings and the nodes associated with them.",
|
||||
NULL};
|
||||
|
@ -533,9 +533,9 @@ int clusterLoadConfig(char *filename) {
|
||||
serverAssert(server.cluster->myself == NULL);
|
||||
myself = server.cluster->myself = n;
|
||||
n->flags |= CLUSTER_NODE_MYSELF;
|
||||
} else if (!strcasecmp(s, "master")) {
|
||||
} else if (!strcasecmp(s, "master") || !strcasecmp(s, "primary")) {
|
||||
n->flags |= CLUSTER_NODE_PRIMARY;
|
||||
} else if (!strcasecmp(s, "slave")) {
|
||||
} else if (!strcasecmp(s, "slave") || !strcasecmp(s, "replica")) {
|
||||
n->flags |= CLUSTER_NODE_REPLICA;
|
||||
} else if (!strcasecmp(s, "fail?")) {
|
||||
n->flags |= CLUSTER_NODE_PFAIL;
|
||||
@ -1903,7 +1903,7 @@ void clearNodeFailureIfNeeded(clusterNode *node) {
|
||||
* node again. */
|
||||
if (nodeIsReplica(node) || node->numslots == 0) {
|
||||
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;
|
||||
clusterDoBeforeSleep(CLUSTER_TODO_UPDATE_STATE | CLUSTER_TODO_SAVE_CONFIG);
|
||||
}
|
||||
@ -4154,7 +4154,7 @@ void clusterLogCantFailover(int reason) {
|
||||
|
||||
switch (reason) {
|
||||
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 "
|
||||
"option.";
|
||||
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("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("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("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},
|
||||
@ -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("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("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("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("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 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("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("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("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)},
|
||||
{0}
|
||||
};
|
||||
@ -1187,6 +1187,7 @@ commandHistory CLIENT_KILL_History[] = {
|
||||
{"5.0.0","Replaced `slave` `TYPE` with `replica`. `slave` still supported for backward compatibility."},
|
||||
{"6.2.0","`LADDR` option."},
|
||||
{"8.0.0","`MAXAGE` option."},
|
||||
{"8.0.0","Replaced `master` `TYPE` with `primary`. `master` still supported for backward compatibility."},
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -1204,6 +1205,7 @@ commandHistory CLIENT_KILL_History[] = {
|
||||
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("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("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)},
|
||||
@ -1218,7 +1220,7 @@ struct COMMAND_ARG CLIENT_KILL_filter_new_format_skipme_Subargs[] = {
|
||||
/* CLIENT KILL filter new_format argument table */
|
||||
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-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("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"},
|
||||
@ -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."},
|
||||
{"7.0.0","Added `resp`, `multi-mem`, `rbs` and `rbp` fields."},
|
||||
{"7.0.3","Added `ssub` field."},
|
||||
{"8.0.0","Replaced `master` `TYPE` with `primary`. `master` still supported for backward compatibility."},
|
||||
};
|
||||
#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("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("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("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("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,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-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},
|
||||
@ -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("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("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("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)},
|
||||
|
@ -31,6 +31,10 @@
|
||||
[
|
||||
"8.0.0",
|
||||
"`MAXAGE` option."
|
||||
],
|
||||
[
|
||||
"8.0.0",
|
||||
"Replaced `master` `TYPE` with `primary`. `master` still supported for backward compatibility."
|
||||
]
|
||||
],
|
||||
"command_flags": [
|
||||
@ -84,6 +88,12 @@
|
||||
"token": "master",
|
||||
"since": "3.2.0"
|
||||
},
|
||||
{
|
||||
"name": "primary",
|
||||
"type": "pure-token",
|
||||
"token": "primary",
|
||||
"since": "8.0.0"
|
||||
},
|
||||
{
|
||||
"name": "slave",
|
||||
"type": "pure-token",
|
||||
|
@ -31,6 +31,10 @@
|
||||
[
|
||||
"7.0.3",
|
||||
"Added `ssub` field."
|
||||
],
|
||||
[
|
||||
"8.0.0",
|
||||
"Replaced `master` `TYPE` with `primary`. `master` still supported for backward compatibility."
|
||||
]
|
||||
],
|
||||
"command_flags": [
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"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)",
|
||||
"group": "cluster",
|
||||
"since": "3.0.0",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"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.",
|
||||
"group": "cluster",
|
||||
"since": "5.0.0",
|
||||
@ -21,7 +21,7 @@
|
||||
}
|
||||
],
|
||||
"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",
|
||||
"items": {
|
||||
"type": "string",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"REPLICATE": {
|
||||
"summary": "Configure a node as replica of a master node.",
|
||||
"summary": "Configure a node as replica of a primary node.",
|
||||
"complexity": "O(1)",
|
||||
"group": "cluster",
|
||||
"since": "3.0.0",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"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.",
|
||||
"group": "cluster",
|
||||
"since": "3.0.0",
|
||||
@ -26,7 +26,7 @@
|
||||
}
|
||||
],
|
||||
"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",
|
||||
"items": {
|
||||
"type": "string",
|
||||
|
@ -42,7 +42,7 @@
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"description": "Master node for the slot range.",
|
||||
"description": "Primary node for the slot range.",
|
||||
"minItems": 4,
|
||||
"maxItems": 4,
|
||||
"items": [
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"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)",
|
||||
"group": "server",
|
||||
"since": "5.0.0",
|
||||
|
@ -28,7 +28,7 @@
|
||||
"const": "master"
|
||||
},
|
||||
{
|
||||
"description": "Current replication master offset.",
|
||||
"description": "Current replication primary offset.",
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
@ -65,18 +65,18 @@
|
||||
"const": "slave"
|
||||
},
|
||||
{
|
||||
"description": "IP of master.",
|
||||
"description": "IP of primary.",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "Port number of master.",
|
||||
"description": "Port number of primary.",
|
||||
"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": [
|
||||
{
|
||||
"description": "The instance is in handshake with its master.",
|
||||
"description": "The instance is in handshake with its primary.",
|
||||
"const": "handshake"
|
||||
},
|
||||
{
|
||||
@ -84,15 +84,15 @@
|
||||
"const": "none"
|
||||
},
|
||||
{
|
||||
"description": "The instance needs to connect to its master.",
|
||||
"description": "The instance needs to connect to its primary.",
|
||||
"const": "connect"
|
||||
},
|
||||
{
|
||||
"description": "The master-replica connection is in progress.",
|
||||
"description": "The primary-replica connection is in progress.",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
@ -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"
|
||||
}
|
||||
]
|
||||
@ -120,7 +120,7 @@
|
||||
"const": "sentinel"
|
||||
},
|
||||
{
|
||||
"description": "List of master names monitored by this sentinel instance.",
|
||||
"description": "List of primary names monitored by this sentinel instance.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
|
@ -2891,7 +2891,7 @@ static int setConfigReplicaOfOption(standardConfig *config, sds *argv, int argc,
|
||||
char *ptr;
|
||||
server.primary_port = strtol(argv[1], &ptr, 10);
|
||||
if (server.primary_port < 0 || server.primary_port > 65535 || *ptr != '\0') {
|
||||
*err = "Invalid master port";
|
||||
*err = "Invalid primary port";
|
||||
return 0;
|
||||
}
|
||||
server.primary_host = sdsnew(argv[0]);
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "script.h"
|
||||
#include "fpconv_dtoa.h"
|
||||
#include "fmtargs.h"
|
||||
#include <strings.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/uio.h>
|
||||
#include <math.h>
|
||||
@ -586,11 +587,11 @@ void afterErrorReply(client *c, const char *s, size_t len, int flags) {
|
||||
to = "AOF-loading-client";
|
||||
from = "server";
|
||||
} else if (ctype == CLIENT_TYPE_PRIMARY) {
|
||||
to = "master";
|
||||
to = "primary";
|
||||
from = "replica";
|
||||
} else {
|
||||
to = "replica";
|
||||
from = "master";
|
||||
from = "primary";
|
||||
}
|
||||
|
||||
if (len > 4096) len = 4096;
|
||||
@ -2232,7 +2233,7 @@ int processInlineBuffer(client *c) {
|
||||
sdsfreesplitres(argv, argc);
|
||||
serverLog(LL_WARNING, "WARNING: Receiving inline protocol from primary, primary stream corruption? Closing the "
|
||||
"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;
|
||||
}
|
||||
|
||||
@ -3075,7 +3076,7 @@ void clientCommand(client *c) {
|
||||
" Kill connections made from the specified address",
|
||||
" * LADDR (<ip:port>|<unixsocket>:0)",
|
||||
" Kill connections made to specified local address",
|
||||
" * TYPE (NORMAL|MASTER|REPLICA|PUBSUB)",
|
||||
" * TYPE (NORMAL|PRIMARY|REPLICA|PUBSUB)",
|
||||
" Kill connections by type.",
|
||||
" * USER <username>",
|
||||
" Kill connections authenticated by <username>.",
|
||||
@ -3087,7 +3088,7 @@ void clientCommand(client *c) {
|
||||
" Kill connections older than the specified age.",
|
||||
"LIST [options ...]",
|
||||
" Return information about client connections. Options:",
|
||||
" * TYPE (NORMAL|MASTER|REPLICA|PUBSUB)",
|
||||
" * TYPE (NORMAL|PRIMARY|REPLICA|PUBSUB)",
|
||||
" Return clients of specified type.",
|
||||
"UNPAUSE",
|
||||
" Stop the current client pause, resuming traffic.",
|
||||
@ -3898,7 +3899,7 @@ int getClientTypeByName(char *name) {
|
||||
return CLIENT_TYPE_REPLICA;
|
||||
else if (!strcasecmp(name, "pubsub"))
|
||||
return CLIENT_TYPE_PUBSUB;
|
||||
else if (!strcasecmp(name, "master"))
|
||||
else if (!strcasecmp(name, "master") || !strcasecmp(name, "primary"))
|
||||
return CLIENT_TYPE_PRIMARY;
|
||||
else
|
||||
return -1;
|
||||
|
@ -1385,7 +1385,7 @@ sds getMemoryDoctorReport(void) {
|
||||
" * 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 "
|
||||
"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 "
|
||||
"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/stat.h>
|
||||
|
||||
void replicationDiscardCachedMaster(void);
|
||||
void replicationResurrectCachedMaster(connection *conn);
|
||||
void replicationDiscardCachedPrimary(void);
|
||||
void replicationResurrectCachedPrimary(connection *conn);
|
||||
void replicationSendAck(void);
|
||||
int replicaPutOnline(client *replica);
|
||||
void replicaStartCommandStream(client *replica);
|
||||
@ -114,7 +114,7 @@ int bg_unlink(const char *filename) {
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------- MASTER -------------------------------- */
|
||||
/* ---------------------------------- PRIMARY -------------------------------- */
|
||||
|
||||
void createReplicationBacklog(void) {
|
||||
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
|
||||
* 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
|
||||
* replicationFeedStreamFromMasterStream() */
|
||||
* replicationFeedStreamFromPrimaryStream() */
|
||||
void replicationFeedReplicas(int dictid, robj **argv, int argc) {
|
||||
int j, len;
|
||||
char llstr[LONG_STR_SIZE];
|
||||
@ -925,7 +925,7 @@ void syncCommand(client *c) {
|
||||
replicationUnsetPrimary();
|
||||
}
|
||||
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);
|
||||
} else {
|
||||
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
|
||||
* performed, this function materializes the primary client we store
|
||||
* 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);
|
||||
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 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. */
|
||||
void replicationAttachToNewMaster(void) {
|
||||
void replicationAttachToNewPrimary(void) {
|
||||
/* Replica starts to apply data from new primary, we must discard the cached
|
||||
* primary structure. */
|
||||
serverAssert(server.primary == NULL);
|
||||
replicationDiscardCachedMaster();
|
||||
replicationDiscardCachedPrimary();
|
||||
|
||||
disconnectReplicas(); /* Force our replicas to resync with us as well. */
|
||||
freeReplicationBacklog(); /* Don't allow our chained replicas to PSYNC. */
|
||||
@ -1825,7 +1825,7 @@ void readSyncBulkPayload(connection *conn) {
|
||||
if (server.repl_transfer_size == -1) {
|
||||
nread = connSyncReadLine(conn, buf, 1024, server.repl_syncio_timeout * 1000);
|
||||
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;
|
||||
} else {
|
||||
/* nread here is returned by connSyncReadLine(), which calls syncReadLine() and
|
||||
@ -1834,7 +1834,7 @@ void readSyncBulkPayload(connection *conn) {
|
||||
}
|
||||
|
||||
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;
|
||||
} else if (buf[0] == '\0') {
|
||||
/* At this stage just a newline works as a PING in order to take
|
||||
@ -1844,7 +1844,7 @@ void readSyncBulkPayload(connection *conn) {
|
||||
return;
|
||||
} else if (buf[0] != '$') {
|
||||
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?",
|
||||
buf);
|
||||
goto error;
|
||||
@ -1867,12 +1867,12 @@ void readSyncBulkPayload(connection *conn) {
|
||||
/* Set any repl_transfer_size to avoid entering this code path
|
||||
* at the next call. */
|
||||
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");
|
||||
} else {
|
||||
usemark = 0;
|
||||
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");
|
||||
}
|
||||
return;
|
||||
@ -1894,7 +1894,7 @@ void readSyncBulkPayload(connection *conn) {
|
||||
/* equivalent to EAGAIN */
|
||||
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");
|
||||
cancelReplicationHandshake(1);
|
||||
return;
|
||||
@ -1925,7 +1925,7 @@ void readSyncBulkPayload(connection *conn) {
|
||||
if ((nwritten = write(server.repl_transfer_fd, buf, nread)) != nread) {
|
||||
serverLog(LL_WARNING,
|
||||
"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");
|
||||
goto error;
|
||||
}
|
||||
@ -1996,9 +1996,9 @@ void readSyncBulkPayload(connection *conn) {
|
||||
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_REPL_ASYNC_LOAD, VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED, NULL);
|
||||
} 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);
|
||||
}
|
||||
|
||||
@ -2008,7 +2008,7 @@ void readSyncBulkPayload(connection *conn) {
|
||||
* time for non blocking loading. */
|
||||
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;
|
||||
if (use_diskless_load) {
|
||||
rio rdb;
|
||||
@ -2045,7 +2045,7 @@ void readSyncBulkPayload(connection *conn) {
|
||||
rdbLoadingCtx loadingCtx = {.dbarray = dbarray, .functions_lib_ctx = functions_lib_ctx};
|
||||
if (rdbLoadRioWithLoadingCtx(&rdb, RDBFLAGS_REPLICATION, &rsi, &loadingCtx) != C_OK) {
|
||||
/* 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.");
|
||||
loadingFailed = 1;
|
||||
} else if (usemark) {
|
||||
@ -2068,7 +2068,7 @@ void readSyncBulkPayload(connection *conn) {
|
||||
|
||||
disklessLoadDiscardTempDb(diskless_load_tempDb);
|
||||
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 {
|
||||
/* Remove the half-loaded data in case we started with an empty replica. */
|
||||
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
|
||||
* to apply data from new primary, we must discard the cached
|
||||
* 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);
|
||||
|
||||
/* 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. */
|
||||
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. */
|
||||
@ -2117,7 +2117,7 @@ void readSyncBulkPayload(connection *conn) {
|
||||
if (fsync(server.repl_transfer_fd) == -1) {
|
||||
serverLog(LL_WARNING,
|
||||
"Failed trying to sync the temp DB to disk in "
|
||||
"MASTER <-> REPLICA synchronization: %s",
|
||||
"PRIMARY <-> REPLICA synchronization: %s",
|
||||
strerror(errno));
|
||||
cancelReplicationHandshake(1);
|
||||
return;
|
||||
@ -2128,7 +2128,7 @@ void readSyncBulkPayload(connection *conn) {
|
||||
if (rename(server.repl_transfer_tmpfile, server.rdb_filename) == -1) {
|
||||
serverLog(LL_WARNING,
|
||||
"Failed trying to rename the temp DB into %s in "
|
||||
"MASTER <-> REPLICA synchronization: %s",
|
||||
"PRIMARY <-> REPLICA synchronization: %s",
|
||||
server.rdb_filename, strerror(errno));
|
||||
cancelReplicationHandshake(1);
|
||||
if (old_rdb_fd != -1) close(old_rdb_fd);
|
||||
@ -2141,14 +2141,14 @@ void readSyncBulkPayload(connection *conn) {
|
||||
if (fsyncFileDir(server.rdb_filename) == -1) {
|
||||
serverLog(LL_WARNING,
|
||||
"Failed trying to sync DB directory %s in "
|
||||
"MASTER <-> REPLICA synchronization: %s",
|
||||
"PRIMARY <-> REPLICA synchronization: %s",
|
||||
server.rdb_filename, strerror(errno));
|
||||
cancelReplicationHandshake(1);
|
||||
return;
|
||||
}
|
||||
|
||||
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.");
|
||||
cancelReplicationHandshake(1);
|
||||
if (server.rdb_del_sync_files && allPersistenceDisabled()) {
|
||||
@ -2181,7 +2181,7 @@ void readSyncBulkPayload(connection *conn) {
|
||||
}
|
||||
|
||||
/* 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_down_since = 0;
|
||||
|
||||
@ -2200,11 +2200,11 @@ void readSyncBulkPayload(connection *conn) {
|
||||
* or not, in order to behave correctly if they are promoted to
|
||||
* primaries after a failover. */
|
||||
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) {
|
||||
serverCommunicateSystemd(
|
||||
"STATUS=MASTER <-> REPLICA sync: Finished with success. Ready to accept connections in read-write mode.\n");
|
||||
serverCommunicateSystemd("STATUS=PRIMARY <-> REPLICA sync: Finished with success. Ready to accept connections "
|
||||
"in read-write mode.\n");
|
||||
}
|
||||
|
||||
/* 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
|
||||
* 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:
|
||||
*
|
||||
* 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.
|
||||
* 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_TRY_LATER: Master is currently in a transient error condition.
|
||||
* PSYNC_TRY_LATER: Primary is currently in a transient error condition.
|
||||
*
|
||||
* Notable side effects:
|
||||
*
|
||||
@ -2406,10 +2406,10 @@ int replicaTryPartialResynchronization(connection *conn, int read_reply) {
|
||||
|
||||
/* Reading half */
|
||||
reply = receiveSynchronousResponse(conn);
|
||||
/* Master did not reply to PSYNC */
|
||||
/* Primary did not reply to PSYNC */
|
||||
if (reply == 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;
|
||||
}
|
||||
|
||||
@ -2434,7 +2434,7 @@ int replicaTryPartialResynchronization(connection *conn, int read_reply) {
|
||||
if (offset) offset++;
|
||||
}
|
||||
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
|
||||
* reply means that the primary supports PSYNC, but the reply
|
||||
* 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';
|
||||
|
||||
if (strcmp(new, server.cached_primary->replid)) {
|
||||
/* Master ID changed. */
|
||||
serverLog(LL_NOTICE, "Master replication ID changed to %s", new);
|
||||
/* Primary ID changed. */
|
||||
serverLog(LL_NOTICE, "Primary replication ID changed to %s", new);
|
||||
|
||||
/* Set the old ID as our ID2, up to the current offset+1. */
|
||||
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. */
|
||||
sdsfree(reply);
|
||||
replicationResurrectCachedMaster(conn);
|
||||
replicationResurrectCachedPrimary(conn);
|
||||
|
||||
/* If this instance was restarted and we read the metadata to
|
||||
* 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)) {
|
||||
serverLog(LL_NOTICE,
|
||||
"Master is currently unable to PSYNC "
|
||||
"Primary is currently unable to PSYNC "
|
||||
"but should be in the future: %s",
|
||||
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);
|
||||
} else {
|
||||
serverLog(LL_NOTICE,
|
||||
"Master does not support PSYNC or is in "
|
||||
"Primary does not support PSYNC or is in "
|
||||
"error state (reply: %s)",
|
||||
reply);
|
||||
}
|
||||
@ -2528,7 +2528,7 @@ int replicaTryPartialResynchronization(connection *conn, int read_reply) {
|
||||
|
||||
/* This handler fires when the non blocking connect was able to
|
||||
* establish a connection with the primary. */
|
||||
void syncWithMaster(connection *conn) {
|
||||
void syncWithPrimary(connection *conn) {
|
||||
char tmpfile[256], *err = NULL;
|
||||
int dfd = -1, maxtries = 5;
|
||||
int psync_result;
|
||||
@ -2552,7 +2552,7 @@ void syncWithMaster(connection *conn) {
|
||||
serverLog(LL_NOTICE, "Non blocking connect for SYNC fired the event.");
|
||||
/* Delete the writable event so that the readable event remains
|
||||
* registered and we can wait for the PONG reply. */
|
||||
connSetReadHandler(conn, syncWithMaster);
|
||||
connSetReadHandler(conn, syncWithPrimary);
|
||||
connSetWriteHandler(conn, NULL);
|
||||
server.repl_state = REPL_STATE_RECEIVE_PING_REPLY;
|
||||
/* Send the PING, don't check for errors at all, we have the timeout
|
||||
@ -2580,7 +2580,7 @@ void syncWithMaster(connection *conn) {
|
||||
sdsfree(err);
|
||||
goto error;
|
||||
} else {
|
||||
serverLog(LL_NOTICE, "Master replied to PING, replication can continue...");
|
||||
serverLog(LL_NOTICE, "Primary replied to PING, replication can continue...");
|
||||
}
|
||||
sdsfree(err);
|
||||
err = NULL;
|
||||
@ -2605,7 +2605,7 @@ void syncWithMaster(connection *conn) {
|
||||
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. */
|
||||
{
|
||||
int port;
|
||||
@ -2621,7 +2621,7 @@ void syncWithMaster(connection *conn) {
|
||||
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.
|
||||
* Skip REPLCONF ip-address if there is no replica-announce-ip option set. */
|
||||
if (server.replica_announce_ip) {
|
||||
@ -2654,7 +2654,7 @@ void syncWithMaster(connection *conn) {
|
||||
err = receiveSynchronousResponse(conn);
|
||||
if (err == NULL) goto no_response_error;
|
||||
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);
|
||||
goto error;
|
||||
}
|
||||
@ -2672,7 +2672,7 @@ void syncWithMaster(connection *conn) {
|
||||
* REPLCONF listening-port. */
|
||||
if (err[0] == '-') {
|
||||
serverLog(LL_NOTICE,
|
||||
"(Non critical) Master does not understand "
|
||||
"(Non critical) Primary does not understand "
|
||||
"REPLCONF listening-port: %s",
|
||||
err);
|
||||
}
|
||||
@ -2692,7 +2692,7 @@ void syncWithMaster(connection *conn) {
|
||||
* REPLCONF ip-address. */
|
||||
if (err[0] == '-') {
|
||||
serverLog(LL_NOTICE,
|
||||
"(Non critical) Master does not understand "
|
||||
"(Non critical) Primary does not understand "
|
||||
"REPLCONF ip-address: %s",
|
||||
err);
|
||||
}
|
||||
@ -2709,7 +2709,7 @@ void syncWithMaster(connection *conn) {
|
||||
* REPLCONF capa. */
|
||||
if (err[0] == '-') {
|
||||
serverLog(LL_NOTICE,
|
||||
"(Non critical) Master does not understand "
|
||||
"(Non critical) Primary does not understand "
|
||||
"REPLCONF capa: %s",
|
||||
err);
|
||||
}
|
||||
@ -2752,7 +2752,7 @@ void syncWithMaster(connection *conn) {
|
||||
/* If reached this point, we should be in REPL_STATE_RECEIVE_PSYNC_REPLY. */
|
||||
if (server.repl_state != REPL_STATE_RECEIVE_PSYNC_REPLY) {
|
||||
serverLog(LL_WARNING,
|
||||
"syncWithMaster(): state machine error, "
|
||||
"syncWithPrimary(): state machine error, "
|
||||
"state should be RECEIVE_PSYNC but is %d",
|
||||
server.repl_state);
|
||||
goto error;
|
||||
@ -2783,9 +2783,9 @@ void syncWithMaster(connection *conn) {
|
||||
* uninstalling the read handler from the file descriptor. */
|
||||
|
||||
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) {
|
||||
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");
|
||||
}
|
||||
return;
|
||||
@ -2797,7 +2797,7 @@ void syncWithMaster(connection *conn) {
|
||||
if (psync_result == PSYNC_NOT_SUPPORTED) {
|
||||
serverLog(LL_NOTICE, "Retrying with SYNC...");
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -2811,7 +2811,7 @@ void syncWithMaster(connection *conn) {
|
||||
sleep(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));
|
||||
goto error;
|
||||
}
|
||||
@ -2835,7 +2835,7 @@ void syncWithMaster(connection *conn) {
|
||||
return;
|
||||
|
||||
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 */
|
||||
|
||||
error:
|
||||
@ -2855,11 +2855,11 @@ write_error: /* Handle sendCommand() errors. */
|
||||
goto error;
|
||||
}
|
||||
|
||||
int connectWithMaster(void) {
|
||||
int connectWithPrimary(void) {
|
||||
server.repl_transfer_s = connCreate(connTypeOfReplication());
|
||||
if (connConnect(server.repl_transfer_s, server.primary_host, server.primary_port, server.bind_source_addr,
|
||||
syncWithMaster) == C_ERR) {
|
||||
serverLog(LL_WARNING, "Unable to connect to MASTER: %s", connGetLastError(server.repl_transfer_s));
|
||||
syncWithPrimary) == C_ERR) {
|
||||
serverLog(LL_WARNING, "Unable to connect to PRIMARY: %s", connGetLastError(server.repl_transfer_s));
|
||||
connClose(server.repl_transfer_s);
|
||||
server.repl_transfer_s = NULL;
|
||||
return C_ERR;
|
||||
@ -2868,7 +2868,7 @@ int connectWithMaster(void) {
|
||||
|
||||
server.repl_transfer_lastio = server.unixtime;
|
||||
server.repl_state = REPL_STATE_CONNECTING;
|
||||
serverLog(LL_NOTICE, "MASTER <-> REPLICA sync started");
|
||||
serverLog(LL_NOTICE, "PRIMARY <-> REPLICA sync started");
|
||||
return C_OK;
|
||||
}
|
||||
|
||||
@ -2876,7 +2876,7 @@ int connectWithMaster(void) {
|
||||
* in progress to undo it.
|
||||
* Never call this function directly, use cancelReplicationHandshake() instead.
|
||||
*/
|
||||
void undoConnectWithMaster(void) {
|
||||
void undoConnectWithPrimary(void) {
|
||||
connClose(server.repl_transfer_s);
|
||||
server.repl_transfer_s = NULL;
|
||||
}
|
||||
@ -2886,7 +2886,7 @@ void undoConnectWithMaster(void) {
|
||||
*/
|
||||
void replicationAbortSyncTransfer(void) {
|
||||
serverAssert(server.repl_state == REPL_STATE_TRANSFER);
|
||||
undoConnectWithMaster();
|
||||
undoConnectWithPrimary();
|
||||
if (server.repl_transfer_fd != -1) {
|
||||
close(server.repl_transfer_fd);
|
||||
bg_unlink(server.repl_transfer_tmpfile);
|
||||
@ -2909,7 +2909,7 @@ int cancelReplicationHandshake(int reconnect) {
|
||||
replicationAbortSyncTransfer();
|
||||
server.repl_state = REPL_STATE_CONNECT;
|
||||
} else if (server.repl_state == REPL_STATE_CONNECTING || replicaIsInHandshakeState()) {
|
||||
undoConnectWithMaster();
|
||||
undoConnectWithPrimary();
|
||||
server.repl_state = REPL_STATE_CONNECT;
|
||||
} else {
|
||||
return 0;
|
||||
@ -2919,8 +2919,8 @@ int cancelReplicationHandshake(int reconnect) {
|
||||
|
||||
/* try to re-connect without waiting for replicationCron, this is needed
|
||||
* for the "diskless loading short read" test. */
|
||||
serverLog(LL_NOTICE, "Reconnecting to MASTER %s:%d after failure", server.primary_host, server.primary_port);
|
||||
connectWithMaster();
|
||||
serverLog(LL_NOTICE, "Reconnecting to PRIMARY %s:%d after failure", server.primary_host, server.primary_port);
|
||||
connectWithPrimary();
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -2937,7 +2937,7 @@ void replicationSetPrimary(char *ip, int port) {
|
||||
disconnectAllBlockedClients(); /* Clients blocked in primary, now replica. */
|
||||
|
||||
/* 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. */
|
||||
server.primary_host = sdsnew(ip);
|
||||
server.primary_port = port;
|
||||
@ -2955,7 +2955,7 @@ void replicationSetPrimary(char *ip, int port) {
|
||||
/* Before destroying our primary state, create a cached primary using
|
||||
* our own parameters, to later PSYNC with the new primary. */
|
||||
if (was_primary) {
|
||||
replicationDiscardCachedMaster();
|
||||
replicationDiscardCachedPrimary();
|
||||
replicationCachePrimaryUsingMyself();
|
||||
}
|
||||
|
||||
@ -2968,8 +2968,8 @@ void replicationSetPrimary(char *ip, int port) {
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE, VALKEYMODULE_SUBEVENT_PRIMARY_LINK_DOWN, NULL);
|
||||
|
||||
server.repl_state = REPL_STATE_CONNECT;
|
||||
serverLog(LL_NOTICE, "Connecting to MASTER %s:%d", server.primary_host, server.primary_port);
|
||||
connectWithMaster();
|
||||
serverLog(LL_NOTICE, "Connecting to PRIMARY %s:%d", server.primary_host, server.primary_port);
|
||||
connectWithPrimary();
|
||||
}
|
||||
|
||||
/* 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);
|
||||
|
||||
/* 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);
|
||||
server.primary_host = NULL;
|
||||
if (server.primary) freeClient(server.primary);
|
||||
replicationDiscardCachedMaster();
|
||||
replicationDiscardCachedPrimary();
|
||||
cancelReplicationHandshake(0);
|
||||
/* When a replica is turned into a primary, the current replication ID
|
||||
* (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
|
||||
* waiting 1 second may risk backlog being recycled. */
|
||||
if (server.primary_host) {
|
||||
serverLog(LL_NOTICE, "Reconnecting to MASTER %s:%d", server.primary_host, server.primary_port);
|
||||
connectWithMaster();
|
||||
serverLog(LL_NOTICE, "Reconnecting to PRIMARY %s:%d", server.primary_host, server.primary_port);
|
||||
connectWithPrimary();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3067,7 +3067,7 @@ void replicaofCommand(client *c) {
|
||||
if (server.primary_host) {
|
||||
replicationUnsetPrimary();
|
||||
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);
|
||||
}
|
||||
} 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
|
||||
* 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:
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* replicationResurrectCachedMaster() that is used after a successful PSYNC
|
||||
* replicationResurrectCachedPrimary() that is used after a successful PSYNC
|
||||
* handshake in order to reactivate the cached primary.
|
||||
*/
|
||||
void replicationCachePrimary(client *c) {
|
||||
@ -3227,7 +3227,7 @@ void replicationCachePrimary(client *c) {
|
||||
resetClient(c);
|
||||
|
||||
/* Save the primary. Server.primary will be set to null later by
|
||||
* replicationHandleMasterDisconnection(). */
|
||||
* replicationHandlePrimaryDisconnection(). */
|
||||
server.cached_primary = server.primary;
|
||||
|
||||
/* Invalidate the Peer ID cache. */
|
||||
@ -3262,14 +3262,14 @@ void replicationCachePrimaryUsingMyself(void) {
|
||||
"the new primary with just a partial transfer.");
|
||||
|
||||
/* 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
|
||||
* offset for PSYNC. */
|
||||
server.primary_initial_offset = server.primary_repl_offset;
|
||||
|
||||
/* The primary client we create can be set to any DBID, because
|
||||
* the new primary will start its replication stream with SELECT. */
|
||||
replicationCreateMasterClient(NULL, -1);
|
||||
replicationCreatePrimaryClient(NULL, -1);
|
||||
|
||||
/* Use our own ID / offset. */
|
||||
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
|
||||
* a partial resync on reconnection. */
|
||||
void replicationDiscardCachedMaster(void) {
|
||||
void replicationDiscardCachedPrimary(void) {
|
||||
if (server.cached_primary == NULL) return;
|
||||
|
||||
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
|
||||
* so the stream of data that we'll receive will start from where this
|
||||
* primary left. */
|
||||
void replicationResurrectCachedMaster(connection *conn) {
|
||||
void replicationResurrectCachedPrimary(connection *conn) {
|
||||
server.primary = server.cached_primary;
|
||||
server.cached_primary = NULL;
|
||||
server.primary->conn = conn;
|
||||
@ -3363,8 +3363,8 @@ int checkGoodReplicasStatus(void) {
|
||||
/* ----------------------- SYNCHRONOUS REPLICATION --------------------------
|
||||
* Synchronous replication design can be summarized in points:
|
||||
*
|
||||
* - Masters have a global replication offset, used by PSYNC.
|
||||
* - Master increment the offset every time new commands are sent to replicas.
|
||||
* - Primary have a global replication offset, used by PSYNC.
|
||||
* - Primary increment the offset every time new commands are sent to replicas.
|
||||
* - Replicas ping back primary with the offset processed so far.
|
||||
*
|
||||
* So synchronous replication adds a new WAIT command in the form:
|
||||
@ -3620,14 +3620,14 @@ void replicationCron(void) {
|
||||
/* Non blocking connection timeout? */
|
||||
if (server.primary_host && (server.repl_state == REPL_STATE_CONNECTING || replicaIsInHandshakeState()) &&
|
||||
(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);
|
||||
}
|
||||
|
||||
/* Bulk transfer I/O timeout? */
|
||||
if (server.primary_host && server.repl_state == REPL_STATE_TRANSFER &&
|
||||
(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.");
|
||||
cancelReplicationHandshake(1);
|
||||
}
|
||||
@ -3635,14 +3635,14 @@ void replicationCron(void) {
|
||||
/* Timed out primary when we are an already connected replica? */
|
||||
if (server.primary_host && server.repl_state == REPL_STATE_CONNECTED &&
|
||||
(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);
|
||||
}
|
||||
|
||||
/* Check if we should connect to a MASTER */
|
||||
/* Check if we should connect to a PRIMARY */
|
||||
if (server.repl_state == REPL_STATE_CONNECT) {
|
||||
serverLog(LL_NOTICE, "Connecting to MASTER %s:%d", server.primary_host, server.primary_port);
|
||||
connectWithMaster();
|
||||
serverLog(LL_NOTICE, "Connecting to PRIMARY %s:%d", server.primary_host, server.primary_port);
|
||||
connectWithPrimary();
|
||||
}
|
||||
|
||||
/* Send ACK to primary from time to time.
|
||||
@ -4039,7 +4039,7 @@ void failoverCommand(client *c) {
|
||||
|
||||
/* 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
|
||||
* failover doesn't work like blocked clients will be unblocked and replicas will
|
||||
* be disconnected. This could be optimized further.
|
||||
|
@ -309,7 +309,7 @@ void rioFreeConn(rio *r, sds *remaining) {
|
||||
}
|
||||
|
||||
/* ------------------- 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
|
||||
* (diskless replication option).
|
||||
* It only implements writes. */
|
||||
|
@ -837,7 +837,7 @@ static void showLatencyReport(void) {
|
||||
printf(" %d bytes payload\n", config.datasize);
|
||||
printf(" keep alive: %d\n", config.keepalive);
|
||||
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;
|
||||
for (m = 0; m < config.cluster_node_count; m++) {
|
||||
clusterNode *node = config.cluster_nodes[m];
|
||||
@ -1202,7 +1202,7 @@ static int fetchClusterConfiguration(void) {
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
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);
|
||||
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;
|
||||
for (; i < config.cluster_node_count; 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);
|
||||
exit(1);
|
||||
}
|
||||
printf("Master %d: ", i);
|
||||
printf("Primary %d: ", i);
|
||||
if (node->name) printf("%s ", node->name);
|
||||
printf("%s:%d\n", node->ip, node->port);
|
||||
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) {
|
||||
config.lru_test_mode = 1;
|
||||
config.lru_test_sample_size = strtoll(argv[++i], NULL, 10);
|
||||
} else if (!strcmp(argv[i], "--slave")) {
|
||||
config.replica_mode = 1;
|
||||
} else if (!strcmp(argv[i], "--replica")) {
|
||||
} else if (!strcmp(argv[i], "--slave") || !strcmp(argv[i], "--replica")) {
|
||||
config.replica_mode = 1;
|
||||
} else if (!strcmp(argv[i], "--stat")) {
|
||||
config.stat_mode = 1;
|
||||
@ -3148,11 +3146,11 @@ void cliLoadPreferences(void) {
|
||||
* history file. Currently these commands are include:
|
||||
* - AUTH
|
||||
* - 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]
|
||||
* - MIGRATE with [AUTH password] or [AUTH2 username password]
|
||||
* - 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) {
|
||||
if (!strcasecmp(argv[0], "auth")) {
|
||||
return 1;
|
||||
@ -3202,8 +3200,8 @@ static int isSensitiveCommand(int argc, char **argv) {
|
||||
(!strcasecmp(argv[3], "sentinel-pass") || !strcasecmp(argv[3], "sentinel-user"))) {
|
||||
return 1;
|
||||
}
|
||||
/* SENTINEL SET <mastername> auth-pass password
|
||||
* SENTINEL SET <mastername> auth-user username */
|
||||
/* SENTINEL SET <primaryname> auth-pass password
|
||||
* SENTINEL SET <primaryname> auth-user username */
|
||||
if (!strcasecmp(argv[1], "set") && (!strcasecmp(argv[3], "auth-pass") || !strcasecmp(argv[3], "auth-user"))) {
|
||||
return 1;
|
||||
}
|
||||
@ -4165,7 +4163,7 @@ static void clusterManagerOptimizeAntiAffinity(clusterManagerNodeArray *ipnodes,
|
||||
clusterManagerNode **offenders = NULL;
|
||||
int score = clusterManagerGetAntiAffinityScore(ipnodes, ip_count, NULL, NULL);
|
||||
if (score == 0) goto cleanup;
|
||||
clusterManagerLogInfo(">>> Trying to optimize slaves allocation "
|
||||
clusterManagerLogInfo(">>> Trying to optimize replicas allocation "
|
||||
"for anti-affinity\n");
|
||||
int node_len = cluster_manager.nodes->len;
|
||||
int maxiter = 500 * node_len; // Effort is proportional to cluster size...
|
||||
@ -4219,9 +4217,9 @@ static void clusterManagerOptimizeAntiAffinity(clusterManagerNodeArray *ipnodes,
|
||||
if (perfect)
|
||||
msg = "[OK] Perfect anti-affinity obtained!";
|
||||
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
|
||||
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);
|
||||
cleanup:
|
||||
zfree(offenders);
|
||||
@ -4447,13 +4445,13 @@ static void clusterManagerShowClusterInfo(void) {
|
||||
return;
|
||||
};
|
||||
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);
|
||||
primaries++;
|
||||
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;
|
||||
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. */
|
||||
success = clusterManagerSetSlot(source, target, slot, "node", 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++) {
|
||||
if (!strncmp(*err, acceptable[i], strlen(acceptable[i]))) {
|
||||
zfree(*err);
|
||||
@ -5264,7 +5263,7 @@ static int clusterManagerNodeLoadInfo(clusterManagerNode *node, int opts, char *
|
||||
currentNode->flags |= CLUSTER_MANAGER_FLAG_DISCONNECT;
|
||||
else if (strcmp(flag, "fail") == 0)
|
||||
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;
|
||||
if (primary_id != NULL) {
|
||||
if (currentNode->replicate) sdsfree(currentNode->replicate);
|
||||
@ -5352,7 +5351,7 @@ static int clusterManagerLoadInfoFromNode(clusterManagerNode *node) {
|
||||
clusterManagerNode *primary = clusterManagerNodeByName(n->replicate);
|
||||
if (primary == NULL) {
|
||||
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);
|
||||
} else
|
||||
primary->replicas_count++;
|
||||
@ -5712,10 +5711,10 @@ static int clusterManagerFixSlotsCoverage(char *all_slots) {
|
||||
|
||||
if (cluster_manager.unreachable_primaries > 0 && !force_fix) {
|
||||
clusterManagerLogWarn(
|
||||
"*** Fixing slots coverage with %d unreachable masters 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 "
|
||||
"*** Fixing slots coverage with %d unreachable primaries is dangerous: valkey-cli will assume that slots "
|
||||
"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 "
|
||||
"--cluster-fix-with-unreachable-masters option.\n",
|
||||
"--cluster-fix-with-unreachable-primaries option.\n",
|
||||
cluster_manager.unreachable_primaries);
|
||||
exit(1);
|
||||
}
|
||||
@ -5906,10 +5905,10 @@ static int clusterManagerFixOpenSlot(int slot) {
|
||||
|
||||
if (cluster_manager.unreachable_primaries > 0 && !force_fix) {
|
||||
clusterManagerLogWarn(
|
||||
"*** Fixing open slots with %d unreachable masters 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. "
|
||||
"*** Fixing open slots with %d unreachable primaries is dangerous: valkey-cli will assume that slots 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 "
|
||||
"--cluster-fix-with-unreachable-masters option.\n",
|
||||
"--cluster-fix-with-unreachable-primaries option.\n",
|
||||
cluster_manager.unreachable_primaries);
|
||||
exit(1);
|
||||
}
|
||||
@ -6420,7 +6419,7 @@ static int clusterManagerCheckCluster(int quiet) {
|
||||
static clusterManagerNode *clusterNodeForResharding(char *id, clusterManagerNode *target, int *raise_err) {
|
||||
clusterManagerNode *node = NULL;
|
||||
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);
|
||||
*raise_err = 0;
|
||||
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);
|
||||
if (primaries_count < 3) {
|
||||
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.",
|
||||
node_len, replicas);
|
||||
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);
|
||||
if (last > CLUSTER_MANAGER_SLOTS || i == (primaries_count - 1)) last = CLUSTER_MANAGER_SLOTS - 1;
|
||||
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;
|
||||
for (j = first; j <= last; j++) {
|
||||
primary->slots[j] = 1;
|
||||
@ -6907,13 +6906,13 @@ static int clusterManagerCommandAddNode(int argc, char **argv) {
|
||||
if (primary_id != NULL) {
|
||||
primary_node = clusterManagerNodeByName(primary_id);
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
primary_node = clusterManagerNodeWithLeastReplicas();
|
||||
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);
|
||||
clusterManagerNode *n = clusterManagerNodeByAbbreviatedName(name);
|
||||
if (n == NULL) {
|
||||
clusterManagerLogErr("*** No such master node %s\n", name);
|
||||
clusterManagerLogErr("*** No such primary node %s\n", name);
|
||||
result = 0;
|
||||
goto cleanup;
|
||||
}
|
||||
@ -8130,13 +8129,13 @@ unsigned long long sendSync(redisContext *c, int send_sync, char *out_eof, int *
|
||||
if (send_sync) {
|
||||
/* Send the SYNC command. */
|
||||
if (cliWriteConn(c, "SYNC\r\n", 6) != 6) {
|
||||
fprintf(stderr, "Error writing to master\n");
|
||||
fprintf(stderr, "Error writing to primary\n");
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
/* We have written the command into c->obuf before. */
|
||||
if (cliWriteConn(c, "", 0) != 0) {
|
||||
fprintf(stderr, "Error writing to master\n");
|
||||
fprintf(stderr, "Error writing to primary\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@ -8155,7 +8154,7 @@ unsigned long long sendSync(redisContext *c, int send_sync, char *out_eof, int *
|
||||
}
|
||||
*p = '\0';
|
||||
if (buf[0] == '-') {
|
||||
fprintf(stderr, "SYNC with master failed: %s\n", buf);
|
||||
fprintf(stderr, "SYNC with primary failed: %s\n", buf);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -8207,18 +8206,18 @@ static void replicaMode(int send_sync) {
|
||||
memset(lastbytes, 0, RDB_EOF_MARK_SIZE);
|
||||
usemark = 1;
|
||||
fprintf(stderr,
|
||||
"%s with master, discarding "
|
||||
"%s with primary, discarding "
|
||||
"bytes of bulk transfer until EOF marker...\n",
|
||||
info);
|
||||
} else if (out_full_mode == 1 && payload != 0) {
|
||||
/* SYNC without EOF marker or PSYNC +FULLRESYNC. */
|
||||
fprintf(stderr,
|
||||
"%s with master, discarding %llu "
|
||||
"%s with primary, discarding %llu "
|
||||
"bytes of bulk transfer...\n",
|
||||
info, payload);
|
||||
} else if (out_full_mode == 0 && payload == 0) {
|
||||
/* PSYNC +CONTINUE (no RDB payload). */
|
||||
fprintf(stderr, "%s with master...\n", info);
|
||||
fprintf(stderr, "%s with primary...\n", info);
|
||||
}
|
||||
|
||||
/* Discard the payload. */
|
||||
@ -8247,12 +8246,12 @@ static void replicaMode(int send_sync) {
|
||||
|
||||
if (usemark) {
|
||||
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 */
|
||||
sleep(1);
|
||||
sendReplconf("ACK", "0");
|
||||
} 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. */
|
||||
config.output = OUTPUT_CSV;
|
||||
@ -8289,11 +8288,11 @@ static void getRDB(clusterManagerNode *node) {
|
||||
memset(lastbytes, 0, RDB_EOF_MARK_SIZE);
|
||||
usemark = 1;
|
||||
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",
|
||||
filename);
|
||||
} 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, "-");
|
||||
|
@ -1469,7 +1469,7 @@ VALKEYMODULE_API int (*ValkeyModule_SendClusterMessage)(ValkeyModuleCtx *ctx,
|
||||
VALKEYMODULE_API int (*ValkeyModule_GetClusterNodeInfo)(ValkeyModuleCtx *ctx,
|
||||
const char *id,
|
||||
char *ip,
|
||||
char *master_id,
|
||||
char *primary_id,
|
||||
int *port,
|
||||
int *flags) 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} {
|
||||
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 {
|
||||
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.
|
||||
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
|
||||
|
||||
$rd close
|
||||
|
@ -74,7 +74,7 @@ start_server {tags {"auth_binary_password external:skip"}} {
|
||||
$slave slaveof $master_host $master_port
|
||||
|
||||
# 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]
|
||||
|
||||
# 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,
|
||||
# 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
|
||||
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
|
||||
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
|
||||
assert_match {*'replicaof "--127.0.0.1"'*wrong number of arguments*} $err
|
||||
} {} {external:skip}
|
||||
|
Loading…
x
Reference in New Issue
Block a user