Skip to content

Commit

Permalink
Replace all accurances of chan/chann with channel
Browse files Browse the repository at this point in the history
Signed-off-by: naglera <[email protected]>
  • Loading branch information
naglera committed Jul 17, 2024
1 parent 34ca95c commit ebd7776
Show file tree
Hide file tree
Showing 11 changed files with 168 additions and 168 deletions.
12 changes: 6 additions & 6 deletions src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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));
}

Expand Down Expand Up @@ -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
Expand All @@ -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;
}
}

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/rdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
94 changes: 47 additions & 47 deletions src/replication.c

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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++;
}
Expand Down
26 changes: 13 additions & 13 deletions src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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 \
Expand All @@ -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;

Expand Down Expand Up @@ -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. */
Expand Down
60 changes: 30 additions & 30 deletions tests/integration/dual-channel-replication.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down Expand Up @@ -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]
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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 &&
Expand All @@ -932,24 +932,24 @@ 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
} else {
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
Expand Down Expand Up @@ -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]]
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/psync2-master-restart.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Loading

0 comments on commit ebd7776

Please sign in to comment.