Skip to content

Commit

Permalink
Small comment fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
naglera committed Feb 6, 2024
1 parent 5fc0be9 commit 1e1f74f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ void debugCommand(client *c) {
" Enable or disable the reply buffer resize cron job",
"CLUSTERLINK KILL <to|from|all> <node-id>",
" Kills the link based on the direction to/from (both) with the provided node." ,
"SLEEP-AFTER-FORK <seconds>",
"SLEEP-AFTER-FORK <micro seconds>",
" Stop the server's main process for <seconds> after forking.",
NULL
};
Expand Down
14 changes: 6 additions & 8 deletions src/replication.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ int startBgsaveForReplication(int mincapa, int req) {
/* Keep the page cache since it'll get used soon */
retval = rdbSaveBackground(req,server.rdb_filename,rsiptr,RDBFLAGS_KEEP_CACHE);
}
if (server.debug_sleep_after_fork) sleep(server.debug_sleep_after_fork);
if (server.debug_sleep_after_fork) usleep(server.debug_sleep_after_fork);
} else {
serverLog(LL_WARNING,"BGSAVE for replication: replication information not available, can't generate the RDB file right now. Try later.");
retval = C_ERR;
Expand Down Expand Up @@ -1038,11 +1038,8 @@ void syncCommand(client *c) {
server.stat_sync_partial_ok++;
return; /* No full resync needed, return. */
} else if (isReplicaMainChannel(c)) {
char buf[128];
int buflen;
serverLog(LL_NOTICE,"Replica %s is marked as main-conn, and psync isn't possible. Full sync will continue with dedicated RDB connection.", replicationGetSlaveName(c));
buflen = snprintf(buf,sizeof(buf),"-FULLSYNCNEEDED\r\n");
if (connWrite(c->conn,buf,buflen) != buflen) {
if (connWrite(c->conn,"-FULLSYNCNEEDED\r\n",17) != 17) {
freeClientAsync(c);
}
return;
Expand Down Expand Up @@ -2712,12 +2709,12 @@ void replDataBufInit(void) {
void replStreamProgressCallback(size_t offset, int readlen, time_t *last_progress_callback) {
time_t now = mstime();
if (server.loading_process_events_interval_bytes &&
(offset + readlen)/server.loading_process_events_interval_bytes > offset/server.loading_process_events_interval_bytes &&
(offset + readlen) / server.loading_process_events_interval_bytes > offset / server.loading_process_events_interval_bytes &&
now - *last_progress_callback > server.loading_process_events_interval_ms)
{
replicationSendNewlineToMaster();
processEventsWhileBlocked();
last_progress_callback = &now;
*last_progress_callback = now;
}
}

Expand Down Expand Up @@ -2771,7 +2768,8 @@ void bufferReplData(connection *conn) {
break;
}
/* Create a new node, make sure it is allocated to at least PROTO_REPLY_CHUNK_BYTES.
* Use the same upper boundary as the shared replication buffer, as they share the same purpose */
* Use the same upper boundary as the shared replication buffer (feedReplicationBuffer),
* as they share the same purpose */
size_t usable_size;
size_t limit = max((size_t)server.repl_backlog_size / 16, (size_t)PROTO_REPLY_CHUNK_BYTES);
size_t size = min(max(readlen, (size_t)PROTO_REPLY_CHUNK_BYTES), limit);
Expand Down
26 changes: 11 additions & 15 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -5971,6 +5971,11 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) {
"master_sync_in_progress:%d\r\n"
"slave_read_repl_offset:%lld\r\n"
"slave_repl_offset:%lld\r\n"
"slave_priority:%d\r\n"
"slave_read_only:%d\r\n"
"replica_announced:%d\r\n"
"replicas_repl_buffer_size:%zu\r\n"
"replicas_repl_buffer_peak:%zu\r\n"
,server.masterhost,
server.masterport,
(server.repl_state == REPL_STATE_CONNECTED) ?
Expand All @@ -5979,8 +5984,12 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) {
((int)(server.unixtime-server.master->lastinteraction)) : -1,
server.repl_state == REPL_STATE_TRANSFER,
slave_read_repl_offset,
slave_repl_offset
);
slave_repl_offset,
server.slave_priority,
server.repl_slave_ro,
server.replica_announced,
server.pending_repl_data.len,
server.pending_repl_data.peak);

if (server.repl_state == REPL_STATE_TRANSFER) {
double perc = 0;
Expand All @@ -6007,19 +6016,6 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) {
server.repl_down_since ?
(intmax_t)(server.unixtime-server.repl_down_since) : -1);
}
info = sdscatprintf(info,
"slave_priority:%d\r\n"
"slave_read_only:%d\r\n"
"replica_announced:%d\r\n",
server.slave_priority,
server.repl_slave_ro,
server.replica_announced);

info = sdscatprintf(info,
"replicas_repl_buffer_size:%zu\r\n"
"replicas_repl_buffer_peak:%zu\r\n",
server.pending_repl_data.len,
server.pending_repl_data.peak);
}

info = sdscatprintf(info,
Expand Down
2 changes: 1 addition & 1 deletion src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,9 @@ typedef enum {
#define SLAVE_REQ_NONE 0
#define SLAVE_REQ_RDB_EXCLUDE_DATA (1 << 0) /* Exclude data from RDB */
#define SLAVE_REQ_RDB_EXCLUDE_FUNCTIONS (1 << 1) /* Exclude functions from RDB */
#define SLAVE_REQ_RDB_CHANNEL (1 << 2) /* Use rdb-channel sync */
/* Mask of all bits in the slave requirements bitfield that represent non-standard (filtered) RDB requirements */
#define SLAVE_REQ_RDB_MASK (SLAVE_REQ_RDB_EXCLUDE_DATA | SLAVE_REQ_RDB_EXCLUDE_FUNCTIONS)
#define SLAVE_REQ_RDB_CHANNEL (1 << 2) /* Use rdb-channel sync */

/* Synchronous read timeout - slave side */
#define CONFIG_REPL_SYNCIO_TIMEOUT 5
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/replication.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -1808,7 +1808,7 @@ start_server {tags {"repl rdb-channel external:skip"}} {
$master set key1 val1

$master config set repl-diskless-sync yes
$master debug sleep-after-fork 5;# Stop master after fork
$master debug sleep-after-fork [expr {5 * [expr {10 ** 6}]}];# Stop master after fork for 5 seconds
$master config set repl-rdb-channel yes

$replica config set repl-rdb-channel yes
Expand Down

0 comments on commit 1e1f74f

Please sign in to comment.