diff --git a/src/networking.c b/src/networking.c index 654149f672..c09343374b 100644 --- a/src/networking.c +++ b/src/networking.c @@ -1598,7 +1598,7 @@ void freeClient(client *c) { /* If a client is protected, yet we need to free it right now, make sure * to at least use asynchronous freeing. */ - if (c->flag.protected || c->flag.protected_rdb_chan) { + if (c->flag.protected || c->flag.protected_rdb_channel) { freeClientAsync(c); return; } @@ -1645,7 +1645,7 @@ void freeClient(client *c) { /* Log link disconnection with replica */ if (getClientType(c) == CLIENT_TYPE_REPLICA) { serverLog(LL_NOTICE, - c->flag.repl_rdb_chan ? "Replica %s rdb channel disconnected." : "Connection with replica %s lost.", + c->flag.repl_rdb_channel ? "Replica %s rdb channel disconnected." : "Connection with replica %s lost.", replicationGetReplicaName(c)); } @@ -1876,7 +1876,7 @@ int freeClientsInAsyncFreeQueue(void) { while ((ln = listNext(&li)) != NULL) { client *c = listNodeValue(ln); - if (c->flag.protected_rdb_chan) { + if (c->flag.protected_rdb_channel) { /* Check if it's safe to remove RDB connection protection during synchronization * The primary gives a grace period before freeing this client because * it serves as a reference to the first required replication data block for @@ -1892,7 +1892,7 @@ int freeClientsInAsyncFreeQueue(void) { "Replica main channel failed to establish PSYNC within the grace period (%ld seconds). " "Freeing RDB client %llu.", (long int)(server.unixtime - c->rdb_client_disconnect_time), (unsigned long long)c->id); - c->flag.protected_rdb_chan = 0; + c->flag.protected_rdb_channel = 0; } } @@ -4316,12 +4316,12 @@ int closeClientOnOutputBufferLimitReached(client *c, int async) { /* Note that c->reply_bytes is irrelevant for replica clients * (they use the global repl buffers). */ if ((c->reply_bytes == 0 && getClientType(c) != CLIENT_TYPE_REPLICA) || - (c->flag.close_asap && !(c->flag.protected_rdb_chan))) + (c->flag.close_asap && !(c->flag.protected_rdb_channel))) return 0; if (checkClientOutputBufferLimits(c)) { sds client = catClientInfoString(sdsempty(), c); /* Remove RDB connection protection on COB overrun */ - c->flag.protected_rdb_chan = 0; + c->flag.protected_rdb_channel = 0; if (async) { freeClientAsync(c); diff --git a/src/rdb.c b/src/rdb.c index 9bfac1a471..38a848a26a 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -3510,7 +3510,7 @@ int rdbSaveToReplicasSockets(int req, rdbSaveInfo *rsi) { listIter li; pid_t childpid; int pipefds[2], rdb_pipe_write, safe_to_exit_pipe; - int dual_channel = (req & REPLICA_REQ_RDB_CHAN); + int dual_channel = (req & REPLICA_REQ_RDB_CHANNEL); if (hasActiveChildProcess()) return C_ERR; serverAssert(server.rdb_pipe_read == -1 && server.rdb_child_exit_pipe == -1); diff --git a/src/replication.c b/src/replication.c index 5e49df3e42..f6fbbbf28b 100644 --- a/src/replication.c +++ b/src/replication.c @@ -230,7 +230,7 @@ void addRdbReplicaToPsyncWait(client *replica_rdb_client) { tail ? "tracking repl-backlog tail" : "no repl-backlog to track"); replica_rdb_client->ref_repl_buf_node = tail ? ln : NULL; /* Prevent rdb client from being freed before psync is established. */ - replica_rdb_client->flag.protected_rdb_chan = 1; + replica_rdb_client->flag.protected_rdb_channel = 1; uint64_t id = htonu64(replica_rdb_client->id); raxInsert(server.replicas_waiting_psync, (unsigned char *)&id, sizeof(id), replica_rdb_client, NULL); } @@ -268,7 +268,7 @@ void removeReplicaFromPsyncWait(client *replica_main_client) { o->refcount--; } replica_rdb_client->ref_repl_buf_node = NULL; - replica_rdb_client->flag.protected_rdb_chan = 0; + replica_rdb_client->flag.protected_rdb_channel = 0; serverLog(LL_DEBUG, "Remove psync waiting replica %s with cid %llu, repl buffer block %s", replicationGetReplicaName(replica_main_client), (long long unsigned int)replica_main_client->associated_rdb_client_id, @@ -386,7 +386,7 @@ void incrementalTrimReplicationBacklog(size_t max_blocks) { /* Free replication buffer blocks that are referenced by this client. */ void freeReplicaReferencedReplBuffer(client *replica) { - if (replica->flag.repl_rdb_chan) { + if (replica->flag.repl_rdb_channel) { uint64_t rdb_cid = htonu64(replica->id); if (raxRemove(server.replicas_waiting_psync, (unsigned char *)&rdb_cid, sizeof(rdb_cid), NULL)) { serverLog(LL_DEBUG, "Remove psync waiting replica %s with cid %llu from replicas rax.", @@ -479,7 +479,7 @@ void feedReplicationBuffer(char *s, size_t len) { listRewind(server.replicas, &li); while ((ln = listNext(&li))) { client *replica = ln->value; - if (!canFeedReplicaReplBuffer(replica) && !(replica->flag.protected_rdb_chan)) continue; + if (!canFeedReplicaReplBuffer(replica) && !(replica->flag.protected_rdb_channel)) continue; /* Update shared replication buffer start position. */ if (replica->ref_repl_buf_node == NULL) { replica->ref_repl_buf_node = start_node; @@ -1107,7 +1107,7 @@ void syncCommand(client *c) { "Replica %s is capable of dual channel synchronization, and partial sync isn't possible. " "Full sync will continue with dedicated RDB channel.", replicationGetReplicaName(c)); - const char *buf = "+DUALCHANNSYNC\r\n"; + const char *buf = "+DUALCHANNELSYNC\r\n"; if (connWrite(c->conn, buf, strlen(buf)) != (int)strlen(buf)) { freeClientAsync(c); } @@ -1251,7 +1251,7 @@ void syncCommand(client *c) { * - version * The replica reports its version. * - * - rdb-chan <1|0> + * - rdb-channel <1|0> * Used to identify the client as a replica's rdb connection in an dual channel * sync session. * */ @@ -1376,17 +1376,17 @@ void replconfCommand(client *c) { addReplyErrorFormat(c, "Unrecognized version format: %s", (char *)c->argv[j + 1]->ptr); return; } - } else if (!strcasecmp(c->argv[j]->ptr, "rdb-chan")) { + } else if (!strcasecmp(c->argv[j]->ptr, "rdb-channel")) { long start_with_offset = 0; if (getRangeLongFromObjectOrReply(c, c->argv[j + 1], 0, 1, &start_with_offset, NULL) != C_OK) { return; } if (start_with_offset == 1) { - c->flag.repl_rdb_chan = 1; - c->replica_req |= REPLICA_REQ_RDB_CHAN; + c->flag.repl_rdb_channel = 1; + c->replica_req |= REPLICA_REQ_RDB_CHANNEL; } else { - c->flag.repl_rdb_chan = 0; - c->replica_req &= ~REPLICA_REQ_RDB_CHAN; + c->flag.repl_rdb_channel = 0; + c->replica_req &= ~REPLICA_REQ_RDB_CHANNEL; } } else if (!strcasecmp(c->argv[j]->ptr, "set-rdb-client-id")) { /* REPLCONF identify is used to identify the current replica main channel with existing @@ -2514,7 +2514,7 @@ void freePendingReplDataBuf(void) { * Upon dual-channel sync failure, close rdb-connection, reset repl-state, reset * provisional primary struct, and free local replication buffer. */ void replicationAbortDualChannelSyncTransfer(void) { - serverAssert(server.repl_rdb_chan_state != REPL_DUAL_CHAN_STATE_NONE); + serverAssert(server.repl_rdb_channel_state != REPL_DUAL_CHANNEL_STATE_NONE); serverLog(LL_NOTICE, "Aborting dual channel sync"); if (server.repl_rdb_transfer_s) { connClose(server.repl_rdb_transfer_s); @@ -2526,7 +2526,7 @@ void replicationAbortDualChannelSyncTransfer(void) { close(server.repl_transfer_fd); server.repl_transfer_fd = -1; } - server.repl_rdb_chan_state = REPL_DUAL_CHAN_STATE_NONE; + server.repl_rdb_channel_state = REPL_DUAL_CHANNEL_STATE_NONE; server.repl_provisional_primary.read_reploff = 0; server.repl_provisional_primary.reploff = 0; server.repl_provisional_primary.conn = NULL; @@ -2573,7 +2573,7 @@ static void fullSyncWithPrimary(connection *conn) { goto error; } /* Send replica capabilities */ - if (server.repl_rdb_chan_state == REPL_DUAL_CHAN_SEND_HANDSHAKE) { + if (server.repl_rdb_channel_state == REPL_DUAL_CHANNEL_SEND_HANDSHAKE) { serverLog(LL_DEBUG, "Received first reply from primary using rdb connection."); /* AUTH with the primary if required. */ if (server.primary_auth) { @@ -2596,14 +2596,14 @@ static void fullSyncWithPrimary(connection *conn) { } /* Send replica lisening port to primary for clarification */ sds portstr = getReplicaPortString(); - err = sendCommand(conn, "REPLCONF", "capa", "eof", "rdb-only", "1", "rdb-chan", "1", "listening-port", portstr, + err = sendCommand(conn, "REPLCONF", "capa", "eof", "rdb-only", "1", "rdb-channel", "1", "listening-port", portstr, NULL); sdsfree(portstr); if (err) { serverLog(LL_WARNING, "Sending command to primary in dual channel replication handshake: %s", err); return; } - server.repl_rdb_chan_state = REPL_DUAL_CHAN_RECEIVE_AUTH_REPLY; + server.repl_rdb_channel_state = REPL_DUAL_CHANNEL_RECEIVE_AUTH_REPLY; if (connSetReadHandler(conn, fullSyncWithPrimary) == C_ERR) { char conninfo[CONN_INFO_LEN]; @@ -2613,11 +2613,11 @@ static void fullSyncWithPrimary(connection *conn) { } return; } - if (server.repl_rdb_chan_state == REPL_DUAL_CHAN_RECEIVE_AUTH_REPLY && !server.primary_auth) { - server.repl_rdb_chan_state = REPL_DUAL_CHAN_RECEIVE_REPLCONF_REPLY; + if (server.repl_rdb_channel_state == REPL_DUAL_CHANNEL_RECEIVE_AUTH_REPLY && !server.primary_auth) { + server.repl_rdb_channel_state = REPL_DUAL_CHANNEL_RECEIVE_REPLCONF_REPLY; } /* Receive AUTH reply. */ - if (server.repl_rdb_chan_state == REPL_DUAL_CHAN_RECEIVE_AUTH_REPLY) { + if (server.repl_rdb_channel_state == REPL_DUAL_CHANNEL_RECEIVE_AUTH_REPLY) { err = receiveSynchronousResponse(conn); if (err == NULL) { serverLog(LL_WARNING, "Primary did not respond to auth command during SYNC handshake"); @@ -2628,11 +2628,11 @@ static void fullSyncWithPrimary(connection *conn) { goto error; } sdsfree(err); - server.repl_rdb_chan_state = REPL_DUAL_CHAN_RECEIVE_REPLCONF_REPLY; + server.repl_rdb_channel_state = REPL_DUAL_CHANNEL_RECEIVE_REPLCONF_REPLY; return; } /* Receive replconf response */ - if (server.repl_rdb_chan_state == REPL_DUAL_CHAN_RECEIVE_REPLCONF_REPLY) { + if (server.repl_rdb_channel_state == REPL_DUAL_CHANNEL_RECEIVE_REPLCONF_REPLY) { err = receiveSynchronousResponse(conn); if (err == NULL) { serverLog(LL_WARNING, "Primary did not respond to replconf command during SYNC handshake"); @@ -2649,11 +2649,11 @@ static void fullSyncWithPrimary(connection *conn) { goto error; } sdsfree(err); - server.repl_rdb_chan_state = REPL_DUAL_CHAN_RECEIVE_ENDOFF; + server.repl_rdb_channel_state = REPL_DUAL_CHANNEL_RECEIVE_ENDOFF; return; } /* Receive end offset response */ - if (server.repl_rdb_chan_state == REPL_DUAL_CHAN_RECEIVE_ENDOFF) { + if (server.repl_rdb_channel_state == REPL_DUAL_CHANNEL_RECEIVE_ENDOFF) { int64_t rdb_client_id; err = receiveSynchronousResponse(conn); if (err == NULL) goto error; @@ -2697,7 +2697,7 @@ static void fullSyncWithPrimary(connection *conn) { server.repl_transfer_last_fsync_off = 0; server.repl_transfer_lastio = server.unixtime; - server.repl_rdb_chan_state = REPL_DUAL_CHAN_RDB_LOAD; + server.repl_rdb_channel_state = REPL_DUAL_CHANNEL_RDB_LOAD; return; } @@ -2870,7 +2870,7 @@ void dualChannelSyncSuccess(void) { replicationSteadyStateInit(); replicationSendAck(); /* Send ACK to notify primary that replica is synced */ server.rdb_client_id = -1; - server.repl_rdb_chan_state = REPL_DUAL_CHAN_STATE_NONE; + server.repl_rdb_channel_state = REPL_DUAL_CHANNEL_STATE_NONE; } /* Replication: Replica side. @@ -2878,7 +2878,7 @@ void dualChannelSyncSuccess(void) { * has completed its part and act accordingly. */ void dualChannelSyncHandlePsync(void) { serverAssert(server.repl_state == REPL_STATE_RECEIVE_PSYNC_REPLY); - if (server.repl_rdb_chan_state < REPL_DUAL_CHAN_RDB_LOADED) { + if (server.repl_rdb_channel_state < REPL_DUAL_CHANNEL_RDB_LOADED) { /* RDB is still loading */ if (connSetReadHandler(server.repl_provisional_primary.conn, bufferReplData) == C_ERR) { serverLog(LL_WARNING, "Error while setting readable handler: %s", strerror(errno)); @@ -2889,7 +2889,7 @@ void dualChannelSyncHandlePsync(void) { server.repl_state = REPL_STATE_TRANSFER; return; } - serverAssert(server.repl_rdb_chan_state == REPL_DUAL_CHAN_RDB_LOADED); + serverAssert(server.repl_rdb_channel_state == REPL_DUAL_CHANNEL_RDB_LOADED); /* RDB is loaded */ serverLog(LL_DEBUG, "Dual channel sync - psync established after rdb load"); dualChannelSyncSuccess(); @@ -2900,10 +2900,10 @@ void dualChannelSyncHandlePsync(void) { * RDB channel done loading the RDB. Check whether the main channel has completed its part * and act accordingly. */ void dualChannelSyncHandleRdbLoadCompletion(void) { - serverAssert(server.repl_rdb_chan_state == REPL_DUAL_CHAN_RDB_LOAD); + serverAssert(server.repl_rdb_channel_state == REPL_DUAL_CHANNEL_RDB_LOAD); if (server.repl_state < REPL_STATE_TRANSFER) { /* Main psync channel hasn't been established yet */ - server.repl_rdb_chan_state = REPL_DUAL_CHAN_RDB_LOADED; + server.repl_rdb_channel_state = REPL_DUAL_CHANNEL_RDB_LOADED; return; } serverAssert(server.repl_state == REPL_STATE_TRANSFER); @@ -2966,7 +2966,7 @@ void dualChannelSyncHandleRdbLoadCompletion(void) { #define PSYNC_FULLRESYNC 3 #define PSYNC_NOT_SUPPORTED 4 #define PSYNC_TRY_LATER 5 -#define PSYNC_FULLRESYNC_RDB_CHAN 6 +#define PSYNC_FULLRESYNC_RDB_CHANNEL 6 int replicaTryPartialResynchronization(connection *conn, int read_reply) { char *psync_replid; char psync_offset[32]; @@ -2981,7 +2981,7 @@ int replicaTryPartialResynchronization(connection *conn, int read_reply) { * client structure representing the primary into server.primary. */ server.primary_initial_offset = -1; - if (server.repl_rdb_chan_state != REPL_DUAL_CHAN_STATE_NONE) { + if (server.repl_rdb_channel_state != REPL_DUAL_CHANNEL_STATE_NONE) { /* While in dual channel replication, we should use our prepared repl id and offset. */ psync_replid = server.repl_provisional_primary.replid; snprintf(psync_offset, sizeof(psync_offset), "%lld", server.repl_provisional_primary.reploff + 1); @@ -3063,7 +3063,7 @@ int replicaTryPartialResynchronization(connection *conn, int read_reply) { } if (!strncmp(reply, "+CONTINUE", 9)) { - if (server.repl_rdb_chan_state != REPL_DUAL_CHAN_STATE_NONE) { + if (server.repl_rdb_channel_state != REPL_DUAL_CHANNEL_STATE_NONE) { /* During dual channel sync sesseion, primary struct is already initialized. */ sdsfree(reply); return PSYNC_CONTINUE; @@ -3129,13 +3129,13 @@ int replicaTryPartialResynchronization(connection *conn, int read_reply) { return PSYNC_TRY_LATER; } - if (!strncmp(reply, "+DUALCHANNSYNC", strlen("+DUALCHANNSYNC"))) { - /* A response of +DUALCHANNSYNC from the primary implies that partial + if (!strncmp(reply, "+DUALCHANNELSYNC", strlen("+DUALCHANNELSYNC"))) { + /* A response of +DUALCHANNELSYNC from the primary implies that partial * synchronization is not possible and that the primary supports full * sync using dedicated RDB channel. Full sync will continue that way. */ serverLog(LL_NOTICE, "PSYNC is not possible, initialize RDB channel."); sdsfree(reply); - return PSYNC_FULLRESYNC_RDB_CHAN; + return PSYNC_FULLRESYNC_RDB_CHANNEL; } if (strncmp(reply, "-ERR", 4)) { @@ -3229,7 +3229,7 @@ void setupMainConnForPsync(connection *conn) { * - Dual channel sync begins when the replica sends a REPLCONF capa dual-channel to the primary during initial * handshake. This allows the replica to verify whether the primary supports dual-channel-replication and, if * so, state that this is the replica's main channel, which is not used for snapshot transfer. - * - When replica lacks sufficient data for PSYNC, the primary will send +DUALCHANNSYNC response instead + * - When replica lacks sufficient data for PSYNC, the primary will send +DUALCHANNELSYNC response instead * of RDB data. As a next step, the replica creates a new channel (rdb-channel) and configures it against * the primary with the appropriate capabilities and requirements. The replica then requests a sync * using the RDB channel. @@ -3247,29 +3247,29 @@ void setupMainConnForPsync(connection *conn) { * │RECEIVE_PING_REPLY │ ┌──────────────────────────────────────────────────────────────┐ * └────────┬──────────┘ │ RDB channel states Main channel state │ * │+PONG │ ┌────────────────────────────┐ ┌───────────────────┐ │ - * ┌────────▼──────────┐ ┌─┼─────►DUAL_CHAN_SEND_HANDSHAKE │ ┌─►SEND_HANDSHAKE │ │ + * ┌────────▼──────────┐ ┌─┼─────►DUAL_CHANNEL_SEND_HANDSHAKE │ ┌─►SEND_HANDSHAKE │ │ * │SEND_HANDSHAKE │ │ │ └────┬───────────────────────┘ │ └──┬────────────────┘ │ * └────────┬──────────┘ │ │ │ │ │REPLCONF set-rdb-client-id * │ │ │ ┌───────▼───────────────────────┐ │ ┌──▼────────────────┐ │ - * ┌────────▼──────────┐ │ │ │DUAL_CHAN_RECEIVE_AUTH_REPLY │ │ │RECEIVE_CAPA_REPLY │ │ + * ┌────────▼──────────┐ │ │ │DUAL_CHANNEL_RECEIVE_AUTH_REPLY │ │ │RECEIVE_CAPA_REPLY │ │ * │RECEIVE_AUTH_REPLY │ │ │ └───────┬───────────────────────┘ │ └──┬────────────────┘ │ * └────────┬──────────┘ │ │ │+OK │ │+OK │ * │+OK │ │ ┌───────▼───────────────────────┐ │ ┌──▼────────────────┐ │ - * ┌────────▼──────────┐ │ │ │DUAL_CHAN_RECEIVE_REPLCONF_REP.│ │ │SEND_PSYNC │ │ + * ┌────────▼──────────┐ │ │ │DUAL_CHANNEL_RECEIVE_REPLCONF_REP.│ │ │SEND_PSYNC │ │ * │RECEIVE_PORT_REPLY │ │ │ └───────┬───────────────────────┘ │ └──┬────────────────┘ │ * └────────┬──────────┘ │ │ │+OK │ │PSYNC use snapshot │ * │+OK │ │ ┌───────▼────────────────┐ │ │end-offset provided │ - * ┌────────▼──────────┐ │ │ │DUAL_CHAN_RECEIVE_ENDOFF│ │ │by the primary │ + * ┌────────▼──────────┐ │ │ │DUAL_CHANNEL_RECEIVE_ENDOFF│ │ │by the primary │ * │RECEIVE_IP_REPLY │ │ │ └───────┬────────────────┘ │ ┌──▼────────────────┐ │ * └────────┬──────────┘ │ │ │$ENDOFF │ │RECEIVE_PSYNC_REPLY│ │ * │+OK │ │ ├─────────────────────────┘ └──┬────────────────┘ │ * ┌────────▼──────────┐ │ │ │ │+CONTINUE │ * │RECEIVE_IP_REPLY │ │ │ ┌───────▼───────────────┐ ┌──▼────────────────┐ │ - * └────────┬──────────┘ │ │ │DUAL_CHAN_RDB_LOAD │ │TRANSFER │ │ + * └────────┬──────────┘ │ │ │DUAL_CHANNEL_RDB_LOAD │ │TRANSFER │ │ * │+OK │ │ └───────┬───────────────┘ └─────┬─────────────┘ │ * ┌────────▼────────────────┐ │ │ │Done loading │ │ * │RECEIVE_DUAL_CHANNEL_REP.│ │ │ ┌───────▼───────────────┐ │ │ - * └─┬────┬──────────────────┘ │ │ │DUAL_CHAN_RDB_LOADED │ │ │ + * └─┬────┬──────────────────┘ │ │ │DUAL_CHANNEL_RDB_LOADED │ │ │ * │+OK │Unrecognized REPLCONF│ │ └───────┬───────────────┘ │ │ * ┌─▼────▼────────────┐ │ │ │ │ │ * │RECEIVE_CAPA_REPLY │ │ │ │Replica loads local replication │ │ @@ -3282,7 +3282,7 @@ void setupMainConnForPsync(connection *conn) { * ┌─▼─────────────────┐ │ │ * │RECEIVE_PSYNC_REPLY│ │ │ * └────────┬─┬────────┘ │ │ - * +CONTINUE│ │+DUALCHANNSYNC | │ + * +CONTINUE│ │+DUALCHANNELSYNC | │ * │ │ └─────────────────┘ │ * │ │+FULLRESYNC │ * │ ┌─▼─────────────────┐ ┌─────────▼─────────┐ @@ -3597,9 +3597,9 @@ void syncWithPrimary(connection *conn) { server.repl_transfer_fd = dfd; } - /* Using dual-channel-replication, the primary responded +DUALCHANNSYNC. We need to + /* Using dual-channel-replication, the primary responded +DUALCHANNELSYNC. We need to * initialize the RDB channel. */ - if (psync_result == PSYNC_FULLRESYNC_RDB_CHAN) { + if (psync_result == PSYNC_FULLRESYNC_RDB_CHANNEL) { /* Create RDB connection */ server.repl_rdb_transfer_s = connCreate(connTypeOfReplication()); if (connConnect(server.repl_rdb_transfer_s, server.primary_host, server.primary_port, server.bind_source_addr, @@ -3615,7 +3615,7 @@ void syncWithPrimary(connection *conn) { connGetInfo(conn, conninfo, sizeof(conninfo))); goto error; } - server.repl_rdb_chan_state = REPL_DUAL_CHAN_SEND_HANDSHAKE; + server.repl_rdb_channel_state = REPL_DUAL_CHANNEL_SEND_HANDSHAKE; return; } /* Setup the non blocking download of the bulk file. */ @@ -3708,7 +3708,7 @@ void replicationAbortSyncTransfer(void) { * * Otherwise zero is returned and no operation is performed at all. */ int cancelReplicationHandshake(int reconnect) { - if (server.repl_rdb_chan_state != REPL_DUAL_CHAN_STATE_NONE) { + if (server.repl_rdb_channel_state != REPL_DUAL_CHANNEL_STATE_NONE) { replicationAbortDualChannelSyncTransfer(); } if (server.repl_state == REPL_STATE_TRANSFER) { diff --git a/src/server.c b/src/server.c index 38a7f5a5ba..4e02dca67d 100644 --- a/src/server.c +++ b/src/server.c @@ -2045,7 +2045,7 @@ void initServerConfig(void) { server.cached_primary = NULL; server.primary_initial_offset = -1; server.repl_state = REPL_STATE_NONE; - server.repl_rdb_chan_state = REPL_DUAL_CHAN_STATE_NONE; + server.repl_rdb_channel_state = REPL_DUAL_CHANNEL_STATE_NONE; server.repl_transfer_tmpfile = NULL; server.repl_transfer_fd = -1; server.repl_transfer_s = NULL; @@ -5813,8 +5813,8 @@ sds genValkeyInfoString(dict *section_dict, int all_sections, int everything) { "offset=%lld,lag=%ld,type=%s\r\n", replica_id, replica_ip, replica->replica_listening_port, state, replica->repl_ack_off, lag, - replica->flag.repl_rdb_chan ? "rdb-chan" - : replica->repl_state == REPLICA_STATE_BG_RDB_LOAD ? "main-chan" + replica->flag.repl_rdb_channel ? "rdb-channel" + : replica->repl_state == REPLICA_STATE_BG_RDB_LOAD ? "main-channel" : "replica"); replica_id++; } diff --git a/src/server.h b/src/server.h index 6c367112e3..9290c4ac1a 100644 --- a/src/server.h +++ b/src/server.h @@ -403,17 +403,17 @@ typedef enum { REPL_STATE_CONNECTED, /* Connected to primary */ } repl_state; -/* Replica rdb-channel replication state. Used in server.repl_rdb_chan_state for +/* Replica rdb-channel replication state. Used in server.repl_rdb_channel_state for * replicas to remember what to do next. */ typedef enum { - REPL_DUAL_CHAN_STATE_NONE = 0, /* No active rdb channel sync */ - REPL_DUAL_CHAN_SEND_HANDSHAKE, /* Send handshake sequence to primary */ - REPL_DUAL_CHAN_RECEIVE_AUTH_REPLY, /* Wait for AUTH reply */ - REPL_DUAL_CHAN_RECEIVE_REPLCONF_REPLY, /* Wait for REPLCONF reply */ - REPL_DUAL_CHAN_RECEIVE_ENDOFF, /* Wait for $ENDOFF reply */ - REPL_DUAL_CHAN_RDB_LOAD, /* Loading rdb using rdb channel */ - REPL_DUAL_CHAN_RDB_LOADED, -} repl_rdb_chan_state; + REPL_DUAL_CHANNEL_STATE_NONE = 0, /* No active rdb channel sync */ + REPL_DUAL_CHANNEL_SEND_HANDSHAKE, /* Send handshake sequence to primary */ + REPL_DUAL_CHANNEL_RECEIVE_AUTH_REPLY, /* Wait for AUTH reply */ + REPL_DUAL_CHANNEL_RECEIVE_REPLCONF_REPLY, /* Wait for REPLCONF reply */ + REPL_DUAL_CHANNEL_RECEIVE_ENDOFF, /* Wait for $ENDOFF reply */ + REPL_DUAL_CHANNEL_RDB_LOAD, /* Loading rdb using rdb channel */ + REPL_DUAL_CHANNEL_RDB_LOADED, +} repl_rdb_channel_state; /* The state of an in progress coordinated failover */ typedef enum { @@ -446,7 +446,7 @@ typedef enum { #define REPLICA_REQ_NONE 0 #define REPLICA_REQ_RDB_EXCLUDE_DATA (1 << 0) /* Exclude data from RDB */ #define REPLICA_REQ_RDB_EXCLUDE_FUNCTIONS (1 << 1) /* Exclude functions from RDB */ -#define REPLICA_REQ_RDB_CHAN (1 << 2) /* Use dual-channel-replication */ +#define REPLICA_REQ_RDB_CHANNEL (1 << 2) /* Use dual-channel-replication */ /* Mask of all bits in the replica requirements bitfield that represent non-standard (filtered) RDB requirements */ #define REPLICA_REQ_RDB_MASK (REPLICA_REQ_RDB_EXCLUDE_DATA | REPLICA_REQ_RDB_EXCLUDE_FUNCTIONS) @@ -1207,7 +1207,7 @@ typedef struct ClientFlags { uint64_t replication_done : 1; /* Indicate that replication has been done on the client */ uint64_t authenticated : 1; /* Indicate a client has successfully authenticated */ uint64_t - protected_rdb_chan : 1; /* Dual channel replication sync: Protects the RDB client from premature \ + protected_rdb_channel : 1; /* Dual channel replication sync: Protects the RDB client from premature \ * release during full sync. This flag is used to ensure that the RDB client, which \ * references the first replication data block required by the replica, is not \ * released prematurely. Protecting the client is crucial for prevention of \ @@ -1219,7 +1219,7 @@ typedef struct ClientFlags { * the replica only needs an additional 4KB beyond the minimum size of the repl_backlog. * By using this flag, we ensure that the RDB client remains intact until the replica \ * has successfully initiated PSYNC. */ - uint64_t repl_rdb_chan : 1; /* Dual channel replication sync: track a connection which is used for rdb snapshot */ + uint64_t repl_rdb_channel : 1; /* Dual channel replication sync: track a connection which is used for rdb snapshot */ uint64_t reserved : 7; /* Reserved for future use */ } ClientFlags; @@ -2020,7 +2020,7 @@ struct valkeyServer { client *cached_primary; /* Cached primary to be reused for PSYNC. */ int repl_syncio_timeout; /* Timeout for synchronous I/O calls */ int repl_state; /* Replication status if the instance is a replica */ - int repl_rdb_chan_state; /* State of the replica's rdb channel during dual-channel-replication */ + int repl_rdb_channel_state; /* State of the replica's rdb channel during dual-channel-replication */ off_t repl_transfer_size; /* Size of RDB to read from primary during sync. */ off_t repl_transfer_read; /* Amount of RDB read from primary during sync. */ off_t repl_transfer_last_fsync_off; /* Offset when we fsync-ed last time. */ diff --git a/tests/integration/dual-channel-replication.tcl b/tests/integration/dual-channel-replication.tcl index 077ac98733..7344d0d3b1 100644 --- a/tests/integration/dual-channel-replication.tcl +++ b/tests/integration/dual-channel-replication.tcl @@ -343,7 +343,7 @@ start_server {tags {"dual-channel-replication external:skip"}} { $replica1 replicaof $primary_host $primary_port # Wait for replica to establish psync using main channel wait_for_condition 500 1000 { - [string match "*slave*,state=bg_transfer*,type=main-chan*" [$primary info replication]] + [string match "*slave*,state=bg_transfer*,type=main-channel*" [$primary info replication]] } else { fail "replica didn't start sync session in time" } @@ -734,7 +734,7 @@ start_server {tags {"dual-channel-replication external:skip"}} { } } -foreach dualchan {yes no} { +foreach dualchannel {yes no} { start_server {tags {"dual-channel-replication external:skip"}} { set primary [srv 0 client] set primary_host [srv 0 host] @@ -750,20 +750,20 @@ start_server {tags {"dual-channel-replication external:skip"}} { $primary debug populate 10000 primary 1 $primary config set rdb-key-save-delay 500 - $primary config set dual-channel-replication-enabled $dualchan + $primary config set dual-channel-replication-enabled $dualchannel start_server {} { set replica1 [srv 0 client] - $replica1 config set dual-channel-replication-enabled $dualchan + $replica1 config set dual-channel-replication-enabled $dualchannel $replica1 config set loglevel debug start_server {} { set replica2 [srv 0 client] - $replica2 config set dual-channel-replication-enabled $dualchan + $replica2 config set dual-channel-replication-enabled $dualchannel $replica2 config set loglevel debug $replica2 config set repl-timeout 60 set load_handle [start_one_key_write_load $primary_host $primary_port 100 "mykey1"] - test "Sync should continue if not all slaves dropped dual-channel-replication $dualchan" { + test "Sync should continue if not all slaves dropped dual-channel-replication $dualchannel" { $replica1 replicaof $primary_host $primary_port $replica2 replicaof $primary_host $primary_port @@ -772,7 +772,7 @@ start_server {tags {"dual-channel-replication external:skip"}} { } else { fail "Sync did not start" } - if {$dualchan == "yes"} { + if {$dualchannel == "yes"} { # Wait for both replicas main conns to establish psync wait_for_condition 50 1000 { [status $primary sync_partial_ok] == 2 @@ -785,7 +785,7 @@ start_server {tags {"dual-channel-replication external:skip"}} { wait_for_condition 50 2000 { [status $replica2 master_link_status] == "up" && [status $primary sync_full] == 2 && - (($dualchan == "yes" && [status $primary sync_partial_ok] == 2) || $dualchan == "no") + (($dualchannel == "yes" && [status $primary sync_partial_ok] == 2) || $dualchannel == "no") } else { fail "Sync session interapted\n sync_full:[status $primary sync_full]\n @@ -799,7 +799,7 @@ start_server {tags {"dual-channel-replication external:skip"}} { $primary debug populate 1000000 primary 1 $primary config set rdb-key-save-delay 100 - test "Primary abort sync if all slaves dropped dual-channel-replication $dualchan" { + test "Primary abort sync if all slaves dropped dual-channel-replication $dualchannel" { set cur_psync [status $primary sync_partial_ok] $replica2 replicaof $primary_host $primary_port @@ -808,7 +808,7 @@ start_server {tags {"dual-channel-replication external:skip"}} { } else { fail "Sync did not start" } - if {$dualchan == "yes"} { + if {$dualchannel == "yes"} { # Wait for both replicas main conns to establish psync wait_for_condition 50 1000 { [status $primary sync_partial_ok] == $cur_psync + 1 @@ -860,8 +860,8 @@ start_server {tags {"dual-channel-replication external:skip"}} { $replica replicaof $primary_host $primary_port # Wait for sync session to start wait_for_condition 500 1000 { - [string match "*slave*,state=wait_bgsave*,type=rdb-chan*" [$primary info replication]] && - [string match "*slave*,state=bg_transfer*,type=main-chan*" [$primary info replication]] && + [string match "*slave*,state=wait_bgsave*,type=rdb-channel*" [$primary info replication]] && + [string match "*slave*,state=bg_transfer*,type=main-channel*" [$primary info replication]] && [s -1 rdb_bgsave_in_progress] eq 1 } else { fail "replica didn't start sync session in time" @@ -897,17 +897,17 @@ start_server {tags {"dual-channel-replication external:skip"}} { $replica replicaof $primary_host $primary_port # Wait for sync session to start wait_for_condition 500 1000 { - [string match "*slave*,state=wait_bgsave*,type=rdb-chan*" [$primary info replication]] && - [string match "*slave*,state=bg_transfer*,type=main-chan*" [$primary info replication]] && + [string match "*slave*,state=wait_bgsave*,type=rdb-channel*" [$primary info replication]] && + [string match "*slave*,state=bg_transfer*,type=main-channel*" [$primary info replication]] && [s -1 rdb_bgsave_in_progress] eq 1 } else { fail "replica didn't start sync session in time" } $primary debug log "killing replica rdb connection" - set replica_rdb_chan_id [get_client_id_by_last_cmd $primary "sync"] - assert {$replica_rdb_chan_id != ""} - $primary client kill id $replica_rdb_chan_id + set replica_rdb_channel_id [get_client_id_by_last_cmd $primary "sync"] + assert {$replica_rdb_channel_id != ""} + $primary client kill id $replica_rdb_channel_id # Wait for primary to abort the sync wait_for_condition 1000 10 { [s -1 rdb_bgsave_in_progress] eq 0 && @@ -932,16 +932,16 @@ start_server {tags {"dual-channel-replication external:skip"}} { $replica replicaof $primary_host $primary_port # Wait for sync session to start wait_for_condition 500 1000 { - [string match "*slave*,state=wait_bgsave*,type=rdb-chan*" [$primary info replication]] && + [string match "*slave*,state=wait_bgsave*,type=rdb-channel*" [$primary info replication]] && [s -1 rdb_bgsave_in_progress] eq 1 } else { fail "replica didn't start sync session in time" } - set replica_rdb_chan_id [get_client_id_by_last_cmd $primary "sync"] - assert {$replica_rdb_chan_id != ""} - $primary debug log "killing replica rdb connection $replica_rdb_chan_id" - $primary client kill id $replica_rdb_chan_id + set replica_rdb_channel_id [get_client_id_by_last_cmd $primary "sync"] + assert {$replica_rdb_channel_id != ""} + $primary debug log "killing replica rdb connection $replica_rdb_channel_id" + $primary client kill id $replica_rdb_channel_id # Wait for primary to abort the sync wait_for_condition 10000000 10 { [s -1 rdb_bgsave_in_progress] eq 0 @@ -949,7 +949,7 @@ start_server {tags {"dual-channel-replication external:skip"}} { fail "Primary should abort sync" } # Verify primary reject replconf set-rdb-client-id - set res [catch {$primary replconf set-rdb-client-id $replica_rdb_chan_id} err] + set res [catch {$primary replconf set-rdb-client-id $replica_rdb_channel_id} err] assert [string match *ERR* $err] } stop_write_load $load_handle @@ -1041,17 +1041,17 @@ start_server {tags {"dual-channel-replication external:skip"}} { $replica replicaof $primary_host $primary_port # Wait for sync session to start wait_for_condition 500 1000 { - [string match "*slave*,state=wait_bgsave*,type=rdb-chan*" [$primary info replication]] && - [string match "*slave*,state=bg_transfer*,type=main-chan*" [$primary info replication]] && + [string match "*slave*,state=wait_bgsave*,type=rdb-channel*" [$primary info replication]] && + [string match "*slave*,state=bg_transfer*,type=main-channel*" [$primary info replication]] && [s -1 rdb_bgsave_in_progress] eq 1 } else { fail "replica didn't start sync session in time" } $primary debug log "killing replica rdb connection" - set replica_rdb_chan_id [get_client_id_by_last_cmd $primary "sync"] - assert {$replica_rdb_chan_id != ""} - $primary client kill id $replica_rdb_chan_id + set replica_rdb_channel_id [get_client_id_by_last_cmd $primary "sync"] + assert {$replica_rdb_channel_id != ""} + $primary client kill id $replica_rdb_channel_id # Wait for primary to abort the sync wait_for_condition 50 1000 { [string match {*replicas_waiting_psync:0*} [$primary info replication]] @@ -1079,8 +1079,8 @@ start_server {tags {"dual-channel-replication external:skip"}} { $replica replicaof $primary_host $primary_port # Wait for sync session to start wait_for_condition 500 1000 { - [string match "*slave*,state=wait_bgsave*,type=rdb-chan*" [$primary info replication]] && - [string match "*slave*,state=bg_transfer*,type=main-chan*" [$primary info replication]] && + [string match "*slave*,state=wait_bgsave*,type=rdb-channel*" [$primary info replication]] && + [string match "*slave*,state=bg_transfer*,type=main-channel*" [$primary info replication]] && [s -1 rdb_bgsave_in_progress] eq 1 } else { fail "replica didn't start sync session in time" diff --git a/tests/integration/psync2-master-restart.tcl b/tests/integration/psync2-master-restart.tcl index 5db652603d..34319e66a3 100644 --- a/tests/integration/psync2-master-restart.tcl +++ b/tests/integration/psync2-master-restart.tcl @@ -203,9 +203,9 @@ start_server {} { } else { fail "Replicas didn't sync after master restart" } - set dualchan [lindex [r config get dual-channel-replication-enabled] 1] + set dualchannel [lindex [r config get dual-channel-replication-enabled] 1] set psync_count 0 - if {$dualchan == "yes"} { + if {$dualchannel == "yes"} { # Expect one fake psync set psync_count 1 } diff --git a/tests/integration/replication-buffer.tcl b/tests/integration/replication-buffer.tcl index 598f15cad6..2303d01273 100644 --- a/tests/integration/replication-buffer.tcl +++ b/tests/integration/replication-buffer.tcl @@ -1,7 +1,7 @@ # This test group aims to test that all replicas share one global replication buffer, # two replicas don't make replication buffer size double, and when there is no replica, # replica buffer will shrink. -foreach dualchan {"yes" "no"} { +foreach dualchannel {"yes" "no"} { start_server {tags {"repl external:skip"}} { start_server {} { start_server {} { @@ -9,9 +9,9 @@ start_server {} { set replica1 [srv -3 client] set replica2 [srv -2 client] set replica3 [srv -1 client] - $replica1 config set dual-channel-replication-enabled $dualchan - $replica2 config set dual-channel-replication-enabled $dualchan - $replica3 config set dual-channel-replication-enabled $dualchan + $replica1 config set dual-channel-replication-enabled $dualchannel + $replica2 config set dual-channel-replication-enabled $dualchannel + $replica3 config set dual-channel-replication-enabled $dualchannel set master [srv 0 client] set master_host [srv 0 host] @@ -22,7 +22,7 @@ start_server {} { $master config set repl-diskless-sync-delay 5 $master config set repl-diskless-sync-max-replicas 1 $master config set client-output-buffer-limit "replica 0 0 0" - $master config set dual-channel-replication-enabled $dualchan + $master config set dual-channel-replication-enabled $dualchannel # Make sure replica3 is synchronized with master $replica3 replicaof $master_host $master_port @@ -44,7 +44,7 @@ start_server {} { fail "fail to sync with replicas" } - test "All replicas share one global replication buffer dualchan $dualchan" { + test "All replicas share one global replication buffer dualchannel $dualchannel" { set before_used [s used_memory] populate 1024 "" 1024 ; # Write extra 1M data # New data uses 1M memory, but all replicas use only one @@ -52,7 +52,7 @@ start_server {} { # more than double of replication buffer. set repl_buf_mem [s mem_total_replication_buffers] set extra_mem [expr {[s used_memory]-$before_used-1024*1024}] - if {$dualchan == "yes"} { + if {$dualchannel == "yes"} { # master's replication buffers should not grow during dual channel replication assert {$extra_mem < 1024*1024} assert {$repl_buf_mem < 1024*1024} @@ -62,7 +62,7 @@ start_server {} { # Kill replica1, replication_buffer will not become smaller catch {$replica1 shutdown nosave} set cur_slave_count 2 - if {$dualchan == "yes"} { + if {$dualchannel == "yes"} { # slave3 is connected, slave2 is syncing (has two connection) set cur_slave_count 3 } @@ -74,7 +74,7 @@ start_server {} { assert_equal $repl_buf_mem [s mem_total_replication_buffers] } - test "Replication buffer will become smaller when no replica uses dualchan $dualchan" { + test "Replication buffer will become smaller when no replica uses dualchannel $dualchannel" { # Make sure replica3 catch up with the master wait_for_ofs_sync $master $replica3 @@ -86,7 +86,7 @@ start_server {} { } else { fail "replica2 doesn't disconnect with master" } - if {$dualchan == "yes"} { + if {$dualchannel == "yes"} { # master's replication buffers should not grow during dual channel replication assert {1024*512 > [s mem_total_replication_buffers]} } else { @@ -105,7 +105,7 @@ start_server {} { # partial re-synchronization. Of course, replication backlog memory also can # become smaller when master disconnects with slow replicas since output buffer # limit is reached. -foreach dualchan {yes no} { +foreach dualchannel {yes no} { start_server {tags {"repl external:skip"}} { start_server {} { start_server {} { @@ -113,7 +113,7 @@ start_server {} { set replica1_pid [s -2 process_id] set replica2 [srv -1 client] set replica2_pid [s -1 process_id] - $replica1 config set dual-channel-replication-enabled $dualchan + $replica1 config set dual-channel-replication-enabled $dualchannel set master [srv 0 client] set master_host [srv 0 host] @@ -122,7 +122,7 @@ start_server {} { $master config set save "" $master config set repl-backlog-size 16384 $master config set client-output-buffer-limit "replica 0 0 0" - $master config set dual-channel-replication-enabled $dualchan + $master config set dual-channel-replication-enabled $dualchannel # Executing 'debug digest' on master which has many keys costs much time # (especially in valgrind), this causes that replica1 and replica2 disconnect @@ -131,12 +131,12 @@ start_server {} { $replica1 config set repl-timeout 1000 $replica2 config set repl-timeout 1000 $replica2 config set client-output-buffer-limit "replica 0 0 0" - $replica2 config set dual-channel-replication-enabled $dualchan + $replica2 config set dual-channel-replication-enabled $dualchannel $replica1 replicaof $master_host $master_port wait_for_sync $replica1 - test "Replication backlog size can outgrow the backlog limit config dualchan $dualchan" { + test "Replication backlog size can outgrow the backlog limit config dualchannel $dualchannel" { # Generating RDB will take 1000 seconds $master config set rdb-key-save-delay 1000000 populate 1000 master 10000 @@ -161,7 +161,7 @@ start_server {} { fail "Replica offset didn't catch up with the master after too long time" } - test "Replica could use replication buffer (beyond backlog config) for partial resynchronization dualchan $dualchan" { + test "Replica could use replication buffer (beyond backlog config) for partial resynchronization dualchannel $dualchannel" { # replica1 disconnects with master $replica1 replicaof [srv -1 host] [srv -1 port] # Write a mass of data that exceeds repl-backlog-size @@ -177,7 +177,7 @@ start_server {} { # replica2 still waits for bgsave ending assert {[s rdb_bgsave_in_progress] eq {1} && [lindex [$replica2 role] 3] eq {sync}} # master accepted replica1 partial resync - if { $dualchan == "yes" } { + if { $dualchannel == "yes" } { # 2 psync using main channel # +1 "real" psync assert_equal [s sync_partial_ok] {3} @@ -187,9 +187,9 @@ start_server {} { assert_equal [$master debug digest] [$replica1 debug digest] } - test "Replication backlog memory will become smaller if disconnecting with replica dualchan $dualchan" { + test "Replication backlog memory will become smaller if disconnecting with replica dualchannel $dualchannel" { assert {[s repl_backlog_histlen] > [expr 2*10000*10000]} - if {$dualchan == "yes"} { + if {$dualchannel == "yes"} { # 1 connection of replica1 # +2 connections during sync of replica2 assert_equal [s connected_slaves] {3} @@ -206,7 +206,7 @@ start_server {} { wait_for_condition 100 100 { [s connected_slaves] eq {1} || ([s connected_slaves] eq {2} && - [string match {*slave*state=wait_bgsave*type=rdb-chan*} [$master info]]) + [string match {*slave*state=wait_bgsave*type=rdb-channel*} [$master info]]) } else { fail "master didn't disconnect with replica2" } @@ -227,17 +227,17 @@ start_server {} { } } -foreach dualchan {"yes" "no"} { -test "Partial resynchronization is successful even client-output-buffer-limit is less than repl-backlog-size. dualchan $dualchan" { +foreach dualchannel {"yes" "no"} { +test "Partial resynchronization is successful even client-output-buffer-limit is less than repl-backlog-size. dualchannel $dualchannel" { start_server {tags {"repl external:skip"}} { start_server {} { r config set save "" r config set repl-backlog-size 100mb r config set client-output-buffer-limit "replica 512k 0 0" - r config set dual-channel-replication-enabled $dualchan + r config set dual-channel-replication-enabled $dualchannel set replica [srv -1 client] - $replica config set dual-channel-replication-enabled $dualchan + $replica config set dual-channel-replication-enabled $dualchannel $replica replicaof [srv 0 host] [srv 0 port] wait_for_sync $replica @@ -255,7 +255,7 @@ test "Partial resynchronization is successful even client-output-buffer-limit is wait_for_ofs_sync r $replica # master accepted replica partial resync set psync_count 1 - if {$dualchan == "yes"} { + if {$dualchannel == "yes"} { # One fake and one real psync set psync_count 2 } @@ -280,7 +280,7 @@ test "Partial resynchronization is successful even client-output-buffer-limit is } # This test was added to make sure big keys added to the backlog do not trigger psync loop. -test "Replica client-output-buffer size is limited to backlog_limit/16 when no replication data is pending. dualchan $dualchan" { +test "Replica client-output-buffer size is limited to backlog_limit/16 when no replication data is pending. dualchannel $dualchannel" { proc client_field {r type f} { set client [$r client list type $type] if {![regexp $f=(\[a-zA-Z0-9-\]+) $client - res]} { @@ -301,8 +301,8 @@ test "Replica client-output-buffer size is limited to backlog_limit/16 when no r $master config set repl-backlog-size 16384 $master config set client-output-buffer-limit "replica 32768 32768 60" - $master config set dual-channel-replication-enabled $dualchan - $replica config set dual-channel-replication-enabled $dualchan + $master config set dual-channel-replication-enabled $dualchannel + $replica config set dual-channel-replication-enabled $dualchannel # Key has has to be larger than replica client-output-buffer limit. set keysize [expr 256*1024] @@ -341,7 +341,7 @@ test "Replica client-output-buffer size is limited to backlog_limit/16 when no r # now we expect the replica to re-connect but fail partial sync (it doesn't have large # enough COB limit and must result in a full-sync) - if {$dualchan == "yes"} { + if {$dualchannel == "yes"} { assert {[status $master sync_partial_ok] == [status $master sync_full]} } else { assert {[status $master sync_partial_ok] == 0} diff --git a/tests/integration/replication-psync.tcl b/tests/integration/replication-psync.tcl index 616e6898c2..4c305ebff4 100644 --- a/tests/integration/replication-psync.tcl +++ b/tests/integration/replication-psync.tcl @@ -8,7 +8,7 @@ # If reconnect is > 0, the test actually try to break the connection and # reconnect with the master, otherwise just the initial synchronization is # checked for consistency. -proc test_psync {descr duration backlog_size backlog_ttl delay cond mdl sdl dualchan reconnect} { +proc test_psync {descr duration backlog_size backlog_ttl delay cond mdl sdl dualchannel reconnect} { start_server {tags {"repl"} overrides {save {}}} { start_server {overrides {save {}}} { @@ -21,9 +21,9 @@ proc test_psync {descr duration backlog_size backlog_ttl delay cond mdl sdl dual $master config set repl-backlog-ttl $backlog_ttl $master config set repl-diskless-sync $mdl $master config set repl-diskless-sync-delay 1 - $master config set dual-channel-replication-enabled $dualchan + $master config set dual-channel-replication-enabled $dualchannel $slave config set repl-diskless-load $sdl - $slave config set dual-channel-replication-enabled $dualchan + $slave config set dual-channel-replication-enabled $dualchannel set load_handle0 [start_bg_complex_data $master_host $master_port 9 100000] set load_handle1 [start_bg_complex_data $master_host $master_port 11 100000] @@ -48,7 +48,7 @@ proc test_psync {descr duration backlog_size backlog_ttl delay cond mdl sdl dual } } - test "Test replication partial resync: $descr (diskless: $mdl, $sdl, dual-channel: $dualchan, reconnect: $reconnect)" { + test "Test replication partial resync: $descr (diskless: $mdl, $sdl, dual-channel: $dualchannel, reconnect: $reconnect)" { # Now while the clients are writing data, break the master-slave # link multiple times. if ($reconnect) { @@ -114,25 +114,25 @@ proc test_psync {descr duration backlog_size backlog_ttl delay cond mdl sdl dual tags {"external:skip"} { foreach mdl {no yes} { foreach sdl {disabled swapdb} { - foreach dualchan {yes no} { + foreach dualchannel {yes no} { test_psync {no reconnection, just sync} 6 1000000 3600 0 { - } $mdl $sdl $dualchan 0 + } $mdl $sdl $dualchannel 0 test_psync {ok psync} 6 100000000 3600 0 { assert {[s -1 sync_partial_ok] > 0} - } $mdl $sdl $dualchan 1 + } $mdl $sdl $dualchannel 1 test_psync {no backlog} 6 100 3600 0.5 { assert {[s -1 sync_partial_err] > 0} - } $mdl $sdl $dualchan 1 + } $mdl $sdl $dualchannel 1 test_psync {ok after delay} 3 100000000 3600 3 { assert {[s -1 sync_partial_ok] > 0} - } $mdl $sdl $dualchan 1 + } $mdl $sdl $dualchannel 1 test_psync {backlog expired} 3 100000000 1 3 { assert {[s -1 sync_partial_err] > 0} - } $mdl $sdl $dualchan 1 + } $mdl $sdl $dualchannel 1 } } } diff --git a/tests/integration/replication.tcl b/tests/integration/replication.tcl index f5c55bff28..b175f4ff34 100644 --- a/tests/integration/replication.tcl +++ b/tests/integration/replication.tcl @@ -301,7 +301,7 @@ start_server {tags {"repl external:skip"}} { } } -foreach mdl {no yes} dualchan {no yes} { +foreach mdl {no yes} dualchannel {no yes} { foreach sdl {disabled swapdb} { start_server {tags {"repl external:skip"} overrides {save {}}} { set master [srv 0 client] @@ -317,7 +317,7 @@ foreach mdl {no yes} dualchan {no yes} { lappend slaves [srv 0 client] start_server {overrides {save {}}} { lappend slaves [srv 0 client] - test "Connect multiple replicas at the same time (issue #141), master diskless=$mdl, replica diskless=$sdl dual-channel-replication-enabled=$dualchan" { + test "Connect multiple replicas at the same time (issue #141), master diskless=$mdl, replica diskless=$sdl dual-channel-replication-enabled=$dualchannel" { # start load handles only inside the test, so that the test can be skipped set load_handle0 [start_bg_complex_data $master_host $master_port 9 100000000] set load_handle1 [start_bg_complex_data $master_host $master_port 11 100000000] @@ -326,11 +326,11 @@ foreach mdl {no yes} dualchan {no yes} { set load_handle4 [start_write_load $master_host $master_port 4] after 5000 ;# wait for some data to accumulate so that we have RDB part for the fork - $master config set dual-channel-replication-enabled $dualchan + $master config set dual-channel-replication-enabled $dualchannel # Send SLAVEOF commands to slaves - [lindex $slaves 0] config set dual-channel-replication-enabled $dualchan - [lindex $slaves 1] config set dual-channel-replication-enabled $dualchan - [lindex $slaves 2] config set dual-channel-replication-enabled $dualchan + [lindex $slaves 0] config set dual-channel-replication-enabled $dualchannel + [lindex $slaves 1] config set dual-channel-replication-enabled $dualchannel + [lindex $slaves 2] config set dual-channel-replication-enabled $dualchannel [lindex $slaves 0] config set repl-diskless-load $sdl [lindex $slaves 1] config set repl-diskless-load $sdl [lindex $slaves 2] config set repl-diskless-load $sdl @@ -442,7 +442,7 @@ start_server {tags {"repl external:skip"} overrides {save {}}} { } # Diskless load swapdb when NOT async_loading (different master replid) -foreach testType {Successful Aborted} dualchan {yes no} { +foreach testType {Successful Aborted} dualchannel {yes no} { start_server {tags {"repl external:skip"}} { set replica [srv 0 client] set replica_host [srv 0 host] @@ -457,10 +457,10 @@ foreach testType {Successful Aborted} dualchan {yes no} { $master config set repl-diskless-sync yes $master config set repl-diskless-sync-delay 0 $master config set save "" - $master config set dual-channel-replication-enabled $dualchan + $master config set dual-channel-replication-enabled $dualchannel $replica config set repl-diskless-load swapdb $replica config set save "" - $replica config set dual-channel-replication-enabled $dualchan + $replica config set dual-channel-replication-enabled $dualchannel # Put different data sets on the master and replica # We need to put large keys on the master since the replica replies to info only once in 2mb @@ -480,7 +480,7 @@ foreach testType {Successful Aborted} dualchan {yes no} { # Start the replication process $replica replicaof $master_host $master_port - test "Diskless load swapdb (different replid): replica enter loading dual-channel-replication-enabled=$dualchan" { + test "Diskless load swapdb (different replid): replica enter loading dual-channel-replication-enabled=$dualchannel" { # Wait for the replica to start reading the rdb wait_for_condition 100 100 { [s -1 loading] eq 1 @@ -504,7 +504,7 @@ foreach testType {Successful Aborted} dualchan {yes no} { fail "Replica didn't disconnect" } - test "Diskless load swapdb (different replid): old database is exposed after replication fails dual-channel=$dualchan" { + test "Diskless load swapdb (different replid): old database is exposed after replication fails dual-channel=$dualchannel" { # Ensure we see old values from replica assert_equal [$replica get mykey] "myvalue" @@ -526,7 +526,7 @@ foreach testType {Successful Aborted} dualchan {yes no} { fail "Master <-> Replica didn't finish sync" } - test "Diskless load swapdb (different replid): new database is exposed after swapping dual-channel=$dualchan" { + test "Diskless load swapdb (different replid): new database is exposed after swapping dual-channel=$dualchannel" { # Ensure we don't see anymore the key that was stored only to replica and also that we don't get LOADING status assert_equal [$replica GET mykey] "" @@ -1052,8 +1052,8 @@ test "diskless replication child being killed is collected" { } } {} {external:skip} -foreach mdl {yes no} dualchan {yes no} { - test "replication child dies when parent is killed - diskless: $mdl dual-channel-replication-enabled: $dualchan" { +foreach mdl {yes no} dualchannel {yes no} { + test "replication child dies when parent is killed - diskless: $mdl dual-channel-replication-enabled: $dualchannel" { # when master is killed, make sure the fork child can detect that and exit start_server {tags {"repl"} overrides {save ""}} { set master [srv 0 client] @@ -1067,7 +1067,7 @@ foreach mdl {yes no} dualchan {yes no} { $master debug populate 10000 start_server {overrides {save ""}} { set replica [srv 0 client] - $replica config set dual-channel-replication-enabled $dualchan + $replica config set dual-channel-replication-enabled $dualchannel $replica replicaof $master_host $master_port # wait for rdb child to start @@ -1247,12 +1247,12 @@ test {Kill rdb child process if its dumping RDB is not useful} { } } } {} {external:skip} -foreach dualchan {yes no} { +foreach dualchannel {yes no} { start_server {tags {"repl external:skip"}} { set master1 [srv 0 client] set master1_host [srv 0 host] set master1_port [srv 0 port] - $master1 config set dual-channel-replication-enabled $dualchan + $master1 config set dual-channel-replication-enabled $dualchannel r set a b start_server {} { @@ -1262,16 +1262,16 @@ foreach dualchan {yes no} { # Take 10s for dumping RDB $master2 debug populate 10 master2 10 $master2 config set rdb-key-save-delay 1000000 - $master2 config set dual-channel-replication-enabled $dualchan + $master2 config set dual-channel-replication-enabled $dualchannel start_server {} { set sub_replica [srv 0 client] - $sub_replica config set dual-channel-replication-enabled $dualchan + $sub_replica config set dual-channel-replication-enabled $dualchannel start_server {} { # Full sync with master1 set replica [srv 0 client] - $replica config set dual-channel-replication-enabled $dualchan + $replica config set dual-channel-replication-enabled $dualchannel r slaveof $master1_host $master1_port wait_for_sync r assert_equal "b" [r get a] @@ -1291,14 +1291,14 @@ foreach dualchan {yes no} { } catch {$master2 shutdown nosave} - test "Don't disconnect with replicas before loading transferred RDB when full sync with dual-channel-replication $dualchan" { + test "Don't disconnect with replicas before loading transferred RDB when full sync with dual-channel-replication $dualchannel" { assert ![log_file_matches [srv -1 stdout] "*Connection with master lost*"] # The replication id is not changed in entire replication chain assert_equal [s master_replid] [s -3 master_replid] assert_equal [s master_replid] [s -1 master_replid] } - test "Discard cache master before loading transferred RDB when full sync with dual-channel-replication $dualchan" { + test "Discard cache master before loading transferred RDB when full sync with dual-channel-replication $dualchannel" { set full_sync [s -3 sync_full] set partial_sync [s -3 sync_partial_ok] # Partial sync with master1 @@ -1315,7 +1315,7 @@ foreach dualchan {yes no} { assert ![log_file_matches [srv -1 stdout] "*Connection with master lost*"] # Sub replica just has one full sync, no partial resync. assert_equal 1 [s sync_full] - if {$dualchan == "yes"} { + if {$dualchannel == "yes"} { assert_equal 1 [s sync_partial_ok] } else { assert_equal 0 [s sync_partial_ok] diff --git a/tests/unit/auth.tcl b/tests/unit/auth.tcl index 5bd4617648..5654bf7763 100644 --- a/tests/unit/auth.tcl +++ b/tests/unit/auth.tcl @@ -47,7 +47,7 @@ start_server {tags {"auth external:skip"} overrides {requirepass foobar}} { } } -foreach dualchan {yes no} { +foreach dualchannel {yes no} { start_server {tags {"auth_binary_password external:skip"}} { test {AUTH fails when binary password is wrong} { r config set requirepass "abc\x00def" @@ -66,13 +66,13 @@ start_server {tags {"auth_binary_password external:skip"}} { set master_port [srv -1 port] set slave [srv 0 client] - test "primaryauth test with binary password dualchan = $dualchan" { + test "primaryauth test with binary password dualchannel = $dualchannel" { $master config set requirepass "abc\x00def" - $master config set dual-channel-replication-enabled $dualchan + $master config set dual-channel-replication-enabled $dualchannel # Configure the replica with primaryauth set loglines [count_log_lines 0] $slave config set primaryauth "abc" - $slave config set dual-channel-replication-enabled $dualchan + $slave config set dual-channel-replication-enabled $dualchannel $slave slaveof $master_host $master_port # Verify replica is not able to sync with master