"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/server.c" between
redis-6.2-rc3.tar.gz and redis-6.2.0.tar.gz

About: redis is an advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.

server.c  (redis-6.2-rc3):server.c  (redis-6.2.0)
skipping to change at line 1624 skipping to change at line 1624
/* Return true if there are active children processes doing RDB saving, /* Return true if there are active children processes doing RDB saving,
* AOF rewriting, or some side process spawned by a loaded module. */ * AOF rewriting, or some side process spawned by a loaded module. */
int hasActiveChildProcess() { int hasActiveChildProcess() {
return server.child_pid != -1; return server.child_pid != -1;
} }
void resetChildState() { void resetChildState() {
server.child_type = CHILD_TYPE_NONE; server.child_type = CHILD_TYPE_NONE;
server.child_pid = -1; server.child_pid = -1;
server.stat_current_cow_bytes = 0; server.stat_current_cow_bytes = 0;
server.stat_current_save_keys_processed = 0;
server.stat_module_progress = 0;
server.stat_current_save_keys_total = 0;
updateDictResizePolicy(); updateDictResizePolicy();
closeChildInfoPipe(); closeChildInfoPipe();
moduleFireServerEvent(REDISMODULE_EVENT_FORK_CHILD, moduleFireServerEvent(REDISMODULE_EVENT_FORK_CHILD,
REDISMODULE_SUBEVENT_FORK_CHILD_DIED, REDISMODULE_SUBEVENT_FORK_CHILD_DIED,
NULL); NULL);
} }
/* Return if child type is mutual exclusive with other fork children */ /* Return if child type is mutual exclusive with other fork children */
int isMutuallyExclusiveChildType(int type) { int isMutuallyExclusiveChildType(int type) {
return type == CHILD_TYPE_RDB || type == CHILD_TYPE_AOF || type == CHILD_TYP E_MODULE; return type == CHILD_TYPE_RDB || type == CHILD_TYPE_AOF || type == CHILD_TYP E_MODULE;
skipping to change at line 2419 skipping to change at line 2422
* processUnblockedClients(), so if there are multiple pipelined WAITs * processUnblockedClients(), so if there are multiple pipelined WAITs
* and the just unblocked WAIT gets blocked again, we don't have to wait * and the just unblocked WAIT gets blocked again, we don't have to wait
* a server cron cycle in absence of other event loop events. See #6623. * a server cron cycle in absence of other event loop events. See #6623.
* *
* We also don't send the ACKs while clients are paused, since it can * We also don't send the ACKs while clients are paused, since it can
* increment the replication backlog, they'll be sent after the pause * increment the replication backlog, they'll be sent after the pause
* if we are still the master. */ * if we are still the master. */
if (server.get_ack_from_slaves && !checkClientPauseTimeoutAndReturnIfPaused( )) { if (server.get_ack_from_slaves && !checkClientPauseTimeoutAndReturnIfPaused( )) {
robj *argv[3]; robj *argv[3];
argv[0] = createStringObject("REPLCONF",8); argv[0] = shared.replconf;
argv[1] = createStringObject("GETACK",6); argv[1] = shared.getack;
argv[2] = createStringObject("*",1); /* Not used argument. */ argv[2] = shared.special_asterick; /* Not used argument. */
replicationFeedSlaves(server.slaves, server.slaveseldb, argv, 3); replicationFeedSlaves(server.slaves, server.slaveseldb, argv, 3);
decrRefCount(argv[0]);
decrRefCount(argv[1]);
decrRefCount(argv[2]);
server.get_ack_from_slaves = 0; server.get_ack_from_slaves = 0;
} }
/* We may have recieved updates from clients about their current offset. NOT E: /* We may have recieved updates from clients about their current offset. NOT E:
* this can't be done where the ACK is recieved since failover will disconne ct * this can't be done where the ACK is recieved since failover will disconne ct
* our clients. */ * our clients. */
updateFailoverStatus(); updateFailoverStatus();
/* Send the invalidation messages to clients participating to the /* Send the invalidation messages to clients participating to the
* client side caching protocol in broadcasting (BCAST) mode. */ * client side caching protocol in broadcasting (BCAST) mode. */
skipping to change at line 2566 skipping to change at line 2566
sdscatprintf(sdsempty(), sdscatprintf(sdsempty(),
"*2\r\n$6\r\nSELECT\r\n$%d\r\n%s\r\n", "*2\r\n$6\r\nSELECT\r\n$%d\r\n%s\r\n",
dictid_len, dictid_str)); dictid_len, dictid_str));
} }
shared.messagebulk = createStringObject("$7\r\nmessage\r\n",13); shared.messagebulk = createStringObject("$7\r\nmessage\r\n",13);
shared.pmessagebulk = createStringObject("$8\r\npmessage\r\n",14); shared.pmessagebulk = createStringObject("$8\r\npmessage\r\n",14);
shared.subscribebulk = createStringObject("$9\r\nsubscribe\r\n",15); shared.subscribebulk = createStringObject("$9\r\nsubscribe\r\n",15);
shared.unsubscribebulk = createStringObject("$11\r\nunsubscribe\r\n",18); shared.unsubscribebulk = createStringObject("$11\r\nunsubscribe\r\n",18);
shared.psubscribebulk = createStringObject("$10\r\npsubscribe\r\n",17); shared.psubscribebulk = createStringObject("$10\r\npsubscribe\r\n",17);
shared.punsubscribebulk = createStringObject("$12\r\npunsubscribe\r\n",19); shared.punsubscribebulk = createStringObject("$12\r\npunsubscribe\r\n",19);
/* Shared command names */
shared.del = createStringObject("DEL",3); shared.del = createStringObject("DEL",3);
shared.unlink = createStringObject("UNLINK",6); shared.unlink = createStringObject("UNLINK",6);
shared.rpop = createStringObject("RPOP",4); shared.rpop = createStringObject("RPOP",4);
shared.lpop = createStringObject("LPOP",4); shared.lpop = createStringObject("LPOP",4);
shared.lpush = createStringObject("LPUSH",5); shared.lpush = createStringObject("LPUSH",5);
shared.rpoplpush = createStringObject("RPOPLPUSH",9); shared.rpoplpush = createStringObject("RPOPLPUSH",9);
shared.lmove = createStringObject("LMOVE",5); shared.lmove = createStringObject("LMOVE",5);
shared.blmove = createStringObject("BLMOVE",6); shared.blmove = createStringObject("BLMOVE",6);
shared.zpopmin = createStringObject("ZPOPMIN",7); shared.zpopmin = createStringObject("ZPOPMIN",7);
shared.zpopmax = createStringObject("ZPOPMAX",7); shared.zpopmax = createStringObject("ZPOPMAX",7);
shared.multi = createStringObject("MULTI",5); shared.multi = createStringObject("MULTI",5);
shared.exec = createStringObject("EXEC",4); shared.exec = createStringObject("EXEC",4);
/* Used in the LMOVE/BLMOVE commands */ shared.hset = createStringObject("HSET",4);
shared.left = createStringObject("left",4); shared.srem = createStringObject("SREM",4);
shared.right = createStringObject("right",5); shared.xgroup = createStringObject("XGROUP",6);
shared.xclaim = createStringObject("XCLAIM",6);
shared.script = createStringObject("SCRIPT",6);
shared.replconf = createStringObject("REPLCONF",8);
shared.pexpireat = createStringObject("PEXPIREAT",9); shared.pexpireat = createStringObject("PEXPIREAT",9);
shared.pexpire = createStringObject("PEXPIRE",7); shared.pexpire = createStringObject("PEXPIRE",7);
shared.persist = createStringObject("PERSIST",7); shared.persist = createStringObject("PERSIST",7);
shared.set = createStringObject("SET",3); shared.set = createStringObject("SET",3);
shared.eval = createStringObject("EVAL",4);
/* Shared command argument */
shared.left = createStringObject("left",4);
shared.right = createStringObject("right",5);
shared.pxat = createStringObject("PXAT", 4); shared.pxat = createStringObject("PXAT", 4);
shared.px = createStringObject("PX",2); shared.px = createStringObject("PX",2);
shared.time = createStringObject("TIME",4);
shared.retrycount = createStringObject("RETRYCOUNT",10);
shared.force = createStringObject("FORCE",5);
shared.justid = createStringObject("JUSTID",6);
shared.lastid = createStringObject("LASTID",6);
shared.default_username = createStringObject("default",7);
shared.ping = createStringObject("ping",4);
shared.setid = createStringObject("SETID",5);
shared.keepttl = createStringObject("KEEPTTL",7);
shared.load = createStringObject("LOAD",4);
shared.createconsumer = createStringObject("CREATECONSUMER",14);
shared.getack = createStringObject("GETACK",6);
shared.special_asterick = createStringObject("*",1);
shared.special_equals = createStringObject("=",1);
for (j = 0; j < OBJ_SHARED_INTEGERS; j++) { for (j = 0; j < OBJ_SHARED_INTEGERS; j++) {
shared.integers[j] = shared.integers[j] =
makeObjectShared(createObject(OBJ_STRING,(void*)(long)j)); makeObjectShared(createObject(OBJ_STRING,(void*)(long)j));
shared.integers[j]->encoding = OBJ_ENCODING_INT; shared.integers[j]->encoding = OBJ_ENCODING_INT;
} }
for (j = 0; j < OBJ_SHARED_BULKHDR_LEN; j++) { for (j = 0; j < OBJ_SHARED_BULKHDR_LEN; j++) {
shared.mbulkhdr[j] = createObject(OBJ_STRING, shared.mbulkhdr[j] = createObject(OBJ_STRING,
sdscatprintf(sdsempty(),"*%d\r\n",j)); sdscatprintf(sdsempty(),"*%d\r\n",j));
shared.bulkhdr[j] = createObject(OBJ_STRING, shared.bulkhdr[j] = createObject(OBJ_STRING,
sdscatprintf(sdsempty(),"$%d\r\n",j)); sdscatprintf(sdsempty(),"$%d\r\n",j));
skipping to change at line 3182 skipping to change at line 3207
server.db[j].blocking_keys = dictCreate(&keylistDictType,NULL); server.db[j].blocking_keys = dictCreate(&keylistDictType,NULL);
server.db[j].ready_keys = dictCreate(&objectKeyPointerValueDictType,NULL ); server.db[j].ready_keys = dictCreate(&objectKeyPointerValueDictType,NULL );
server.db[j].watched_keys = dictCreate(&keylistDictType,NULL); server.db[j].watched_keys = dictCreate(&keylistDictType,NULL);
server.db[j].id = j; server.db[j].id = j;
server.db[j].avg_ttl = 0; server.db[j].avg_ttl = 0;
server.db[j].defrag_later = listCreate(); server.db[j].defrag_later = listCreate();
listSetFreeMethod(server.db[j].defrag_later,(void (*)(void*))sdsfree); listSetFreeMethod(server.db[j].defrag_later,(void (*)(void*))sdsfree);
} }
evictionPoolAlloc(); /* Initialize the LRU keys pool. */ evictionPoolAlloc(); /* Initialize the LRU keys pool. */
server.pubsub_channels = dictCreate(&keylistDictType,NULL); server.pubsub_channels = dictCreate(&keylistDictType,NULL);
server.pubsub_patterns = listCreate(); server.pubsub_patterns = dictCreate(&keylistDictType,NULL);
server.pubsub_patterns_dict = dictCreate(&keylistDictType,NULL);
listSetFreeMethod(server.pubsub_patterns,freePubsubPattern);
listSetMatchMethod(server.pubsub_patterns,listMatchPubsubPattern);
server.cronloops = 0; server.cronloops = 0;
server.in_eval = 0; server.in_eval = 0;
server.in_exec = 0; server.in_exec = 0;
server.propagate_in_transaction = 0; server.propagate_in_transaction = 0;
server.client_pause_in_transaction = 0; server.client_pause_in_transaction = 0;
server.child_pid = -1; server.child_pid = -1;
server.child_type = CHILD_TYPE_NONE; server.child_type = CHILD_TYPE_NONE;
server.rdb_child_type = RDB_CHILD_TYPE_NONE; server.rdb_child_type = RDB_CHILD_TYPE_NONE;
server.rdb_pipe_conns = NULL; server.rdb_pipe_conns = NULL;
server.rdb_pipe_numconns = 0; server.rdb_pipe_numconns = 0;
skipping to change at line 3215 skipping to change at line 3237
server.lastsave = time(NULL); /* At startup we consider the DB saved. */ server.lastsave = time(NULL); /* At startup we consider the DB saved. */
server.lastbgsave_try = 0; /* At startup we never tried to BGSAVE. */ server.lastbgsave_try = 0; /* At startup we never tried to BGSAVE. */
server.rdb_save_time_last = -1; server.rdb_save_time_last = -1;
server.rdb_save_time_start = -1; server.rdb_save_time_start = -1;
server.dirty = 0; server.dirty = 0;
resetServerStats(); resetServerStats();
/* A few stats we don't want to reset: server startup time, and peak mem. */ /* A few stats we don't want to reset: server startup time, and peak mem. */
server.stat_starttime = time(NULL); server.stat_starttime = time(NULL);
server.stat_peak_memory = 0; server.stat_peak_memory = 0;
server.stat_current_cow_bytes = 0; server.stat_current_cow_bytes = 0;
server.stat_current_save_keys_processed = 0;
server.stat_current_save_keys_total = 0;
server.stat_rdb_cow_bytes = 0; server.stat_rdb_cow_bytes = 0;
server.stat_aof_cow_bytes = 0; server.stat_aof_cow_bytes = 0;
server.stat_module_cow_bytes = 0; server.stat_module_cow_bytes = 0;
server.stat_module_progress = 0;
for (int j = 0; j < CLIENT_TYPE_COUNT; j++) for (int j = 0; j < CLIENT_TYPE_COUNT; j++)
server.stat_clients_type_memory[j] = 0; server.stat_clients_type_memory[j] = 0;
server.cron_malloc_stats.zmalloc_used = 0; server.cron_malloc_stats.zmalloc_used = 0;
server.cron_malloc_stats.process_rss = 0; server.cron_malloc_stats.process_rss = 0;
server.cron_malloc_stats.allocator_allocated = 0; server.cron_malloc_stats.allocator_allocated = 0;
server.cron_malloc_stats.allocator_active = 0; server.cron_malloc_stats.allocator_active = 0;
server.cron_malloc_stats.allocator_resident = 0; server.cron_malloc_stats.allocator_resident = 0;
server.lastbgsave_status = C_OK; server.lastbgsave_status = C_OK;
server.aof_last_write_status = C_OK; server.aof_last_write_status = C_OK;
server.aof_last_write_errno = 0; server.aof_last_write_errno = 0;
skipping to change at line 4479 skipping to change at line 4504
sprintf(s,"%.2fT",d); sprintf(s,"%.2fT",d);
} else if (n < (1024LL*1024*1024*1024*1024*1024)) { } else if (n < (1024LL*1024*1024*1024*1024*1024)) {
d = (double)n/(1024LL*1024*1024*1024*1024); d = (double)n/(1024LL*1024*1024*1024*1024);
sprintf(s,"%.2fP",d); sprintf(s,"%.2fP",d);
} else { } else {
/* Let's hope we never need this */ /* Let's hope we never need this */
sprintf(s,"%lluB",n); sprintf(s,"%lluB",n);
} }
} }
/* Characters we sanitize on INFO output to maintain expected format. */
static char unsafe_info_chars[] = "#:\n\r";
static char unsafe_info_chars_substs[] = "____"; /* Must be same length as abo
ve */
/* Returns a sanitized version of s that contains no unsafe info string chars.
* If no unsafe characters are found, simply returns s. Caller needs to
* free tmp if it is non-null on return.
*/
const char *getSafeInfoString(const char *s, size_t len, char **tmp) {
*tmp = NULL;
if (mempbrk(s, len, unsafe_info_chars,sizeof(unsafe_info_chars)-1)
== NULL) return s;
char *new = *tmp = zmalloc(len + 1);
memcpy(new, s, len);
new[len] = '\0';
return memmapchars(new, len, unsafe_info_chars, unsafe_info_chars_substs,
sizeof(unsafe_info_chars)-1);
}
/* Create the string returned by the INFO command. This is decoupled /* Create the string returned by the INFO command. This is decoupled
* by the INFO command itself as we need to report the same information * by the INFO command itself as we need to report the same information
* on memory corruption problems. */ * on memory corruption problems. */
sds genRedisInfoString(const char *section) { sds genRedisInfoString(const char *section) {
sds info = sdsempty(); sds info = sdsempty();
time_t uptime = server.unixtime-server.stat_starttime; time_t uptime = server.unixtime-server.stat_starttime;
int j; int j;
int allsections = 0, defsections = 0, everything = 0, modules = 0; int allsections = 0, defsections = 0, everything = 0, modules = 0;
int sections = 0; int sections = 0;
skipping to change at line 4728 skipping to change at line 4772
server.active_defrag_running, server.active_defrag_running,
lazyfreeGetPendingObjectsCount(), lazyfreeGetPendingObjectsCount(),
lazyfreeGetFreedObjectsCount() lazyfreeGetFreedObjectsCount()
); );
freeMemoryOverheadData(mh); freeMemoryOverheadData(mh);
} }
/* Persistence */ /* Persistence */
if (allsections || defsections || !strcasecmp(section,"persistence")) { if (allsections || defsections || !strcasecmp(section,"persistence")) {
if (sections++) info = sdscat(info,"\r\n"); if (sections++) info = sdscat(info,"\r\n");
double fork_perc = 0;
if (server.stat_module_progress) {
fork_perc = server.stat_module_progress * 100;
} else if (server.stat_current_save_keys_total) {
fork_perc = ((double)server.stat_current_save_keys_processed / serve
r.stat_current_save_keys_total) * 100;
}
info = sdscatprintf(info, info = sdscatprintf(info,
"# Persistence\r\n" "# Persistence\r\n"
"loading:%d\r\n" "loading:%d\r\n"
"current_cow_size:%zu\r\n" "current_cow_size:%zu\r\n"
"current_fork_perc:%.2f%%\r\n"
"current_save_keys_processed:%zu\r\n"
"current_save_keys_total:%zu\r\n"
"rdb_changes_since_last_save:%lld\r\n" "rdb_changes_since_last_save:%lld\r\n"
"rdb_bgsave_in_progress:%d\r\n" "rdb_bgsave_in_progress:%d\r\n"
"rdb_last_save_time:%jd\r\n" "rdb_last_save_time:%jd\r\n"
"rdb_last_bgsave_status:%s\r\n" "rdb_last_bgsave_status:%s\r\n"
"rdb_last_bgsave_time_sec:%jd\r\n" "rdb_last_bgsave_time_sec:%jd\r\n"
"rdb_current_bgsave_time_sec:%jd\r\n" "rdb_current_bgsave_time_sec:%jd\r\n"
"rdb_last_cow_size:%zu\r\n" "rdb_last_cow_size:%zu\r\n"
"aof_enabled:%d\r\n" "aof_enabled:%d\r\n"
"aof_rewrite_in_progress:%d\r\n" "aof_rewrite_in_progress:%d\r\n"
"aof_rewrite_scheduled:%d\r\n" "aof_rewrite_scheduled:%d\r\n"
"aof_last_rewrite_time_sec:%jd\r\n" "aof_last_rewrite_time_sec:%jd\r\n"
"aof_current_rewrite_time_sec:%jd\r\n" "aof_current_rewrite_time_sec:%jd\r\n"
"aof_last_bgrewrite_status:%s\r\n" "aof_last_bgrewrite_status:%s\r\n"
"aof_last_write_status:%s\r\n" "aof_last_write_status:%s\r\n"
"aof_last_cow_size:%zu\r\n" "aof_last_cow_size:%zu\r\n"
"module_fork_in_progress:%d\r\n" "module_fork_in_progress:%d\r\n"
"module_fork_last_cow_size:%zu\r\n", "module_fork_last_cow_size:%zu\r\n",
(int)server.loading, (int)server.loading,
server.stat_current_cow_bytes, server.stat_current_cow_bytes,
fork_perc,
server.stat_current_save_keys_processed,
server.stat_current_save_keys_total,
server.dirty, server.dirty,
server.child_type == CHILD_TYPE_RDB, server.child_type == CHILD_TYPE_RDB,
(intmax_t)server.lastsave, (intmax_t)server.lastsave,
(server.lastbgsave_status == C_OK) ? "ok" : "err", (server.lastbgsave_status == C_OK) ? "ok" : "err",
(intmax_t)server.rdb_save_time_last, (intmax_t)server.rdb_save_time_last,
(intmax_t)((server.child_type != CHILD_TYPE_RDB) ? (intmax_t)((server.child_type != CHILD_TYPE_RDB) ?
-1 : time(NULL)-server.rdb_save_time_start), -1 : time(NULL)-server.rdb_save_time_start),
server.stat_rdb_cow_bytes, server.stat_rdb_cow_bytes,
server.aof_state != AOF_OFF, server.aof_state != AOF_OFF,
server.child_type == CHILD_TYPE_AOF, server.child_type == CHILD_TYPE_AOF,
skipping to change at line 4899 skipping to change at line 4956
server.stat_sync_partial_ok, server.stat_sync_partial_ok,
server.stat_sync_partial_err, server.stat_sync_partial_err,
server.stat_expiredkeys, server.stat_expiredkeys,
server.stat_expired_stale_perc*100, server.stat_expired_stale_perc*100,
server.stat_expired_time_cap_reached_count, server.stat_expired_time_cap_reached_count,
server.stat_expire_cycle_time_used/1000, server.stat_expire_cycle_time_used/1000,
server.stat_evictedkeys, server.stat_evictedkeys,
server.stat_keyspace_hits, server.stat_keyspace_hits,
server.stat_keyspace_misses, server.stat_keyspace_misses,
dictSize(server.pubsub_channels), dictSize(server.pubsub_channels),
listLength(server.pubsub_patterns), dictSize(server.pubsub_patterns),
server.stat_fork_time, server.stat_fork_time,
server.stat_total_forks, server.stat_total_forks,
dictSize(server.migrate_cached_sockets), dictSize(server.migrate_cached_sockets),
getSlaveKeyWithExpireCount(), getSlaveKeyWithExpireCount(),
server.stat_active_defrag_hits, server.stat_active_defrag_hits,
server.stat_active_defrag_misses, server.stat_active_defrag_misses,
server.stat_active_defrag_key_hits, server.stat_active_defrag_key_hits,
server.stat_active_defrag_key_misses, server.stat_active_defrag_key_misses,
(unsigned long long) trackingGetTotalKeys(), (unsigned long long) trackingGetTotalKeys(),
(unsigned long long) trackingGetTotalItems(), (unsigned long long) trackingGetTotalItems(),
skipping to change at line 5005 skipping to change at line 5062
if (listLength(server.slaves)) { if (listLength(server.slaves)) {
int slaveid = 0; int slaveid = 0;
listNode *ln; listNode *ln;
listIter li; listIter li;
listRewind(server.slaves,&li); listRewind(server.slaves,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
client *slave = listNodeValue(ln); client *slave = listNodeValue(ln);
char *state = NULL; char *state = NULL;
char ip[NET_IP_STR_LEN], *slaveip = slave->slave_ip; char ip[NET_IP_STR_LEN], *slaveip = slave->slave_addr;
int port; int port;
long lag = 0; long lag = 0;
if (slaveip[0] == '\0') { if (!slaveip) {
if (connPeerToString(slave->conn,ip,sizeof(ip),&port) == -1) if (connPeerToString(slave->conn,ip,sizeof(ip),&port) == -1)
continue; continue;
slaveip = ip; slaveip = ip;
} }
switch(slave->replstate) { switch(slave->replstate) {
case SLAVE_STATE_WAIT_BGSAVE_START: case SLAVE_STATE_WAIT_BGSAVE_START:
case SLAVE_STATE_WAIT_BGSAVE_END: case SLAVE_STATE_WAIT_BGSAVE_END:
state = "wait_bgsave"; state = "wait_bgsave";
break; break;
case SLAVE_STATE_SEND_BULK: case SLAVE_STATE_SEND_BULK:
skipping to change at line 5104 skipping to change at line 5161
/* Command statistics */ /* Command statistics */
if (allsections || !strcasecmp(section,"commandstats")) { if (allsections || !strcasecmp(section,"commandstats")) {
if (sections++) info = sdscat(info,"\r\n"); if (sections++) info = sdscat(info,"\r\n");
info = sdscatprintf(info, "# Commandstats\r\n"); info = sdscatprintf(info, "# Commandstats\r\n");
struct redisCommand *c; struct redisCommand *c;
dictEntry *de; dictEntry *de;
dictIterator *di; dictIterator *di;
di = dictGetSafeIterator(server.commands); di = dictGetSafeIterator(server.commands);
while((de = dictNext(di)) != NULL) { while((de = dictNext(di)) != NULL) {
char *tmpsafe;
c = (struct redisCommand *) dictGetVal(de); c = (struct redisCommand *) dictGetVal(de);
if (!c->calls && !c->failed_calls && !c->rejected_calls) if (!c->calls && !c->failed_calls && !c->rejected_calls)
continue; continue;
info = sdscatprintf(info, info = sdscatprintf(info,
"cmdstat_%s:calls=%lld,usec=%lld,usec_per_call=%.2f" "cmdstat_%s:calls=%lld,usec=%lld,usec_per_call=%.2f"
",rejected_calls=%lld,failed_calls=%lld\r\n", ",rejected_calls=%lld,failed_calls=%lld\r\n",
c->name, c->calls, c->microseconds, getSafeInfoString(c->name, strlen(c->name), &tmpsafe), c->calls, c->microseconds,
(c->calls == 0) ? 0 : ((float)c->microseconds/c->calls), (c->calls == 0) ? 0 : ((float)c->microseconds/c->calls),
c->rejected_calls, c->failed_calls); c->rejected_calls, c->failed_calls);
if (tmpsafe != NULL) zfree(tmpsafe);
} }
dictReleaseIterator(di); dictReleaseIterator(di);
} }
/* Error statistics */ /* Error statistics */
if (allsections || defsections || !strcasecmp(section,"errorstats")) { if (allsections || defsections || !strcasecmp(section,"errorstats")) {
if (sections++) info = sdscat(info,"\r\n"); if (sections++) info = sdscat(info,"\r\n");
info = sdscat(info, "# Errorstats\r\n"); info = sdscat(info, "# Errorstats\r\n");
raxIterator ri; raxIterator ri;
raxStart(&ri,server.errors); raxStart(&ri,server.errors);
raxSeek(&ri,"^",NULL,0); raxSeek(&ri,"^",NULL,0);
struct redisError *e; struct redisError *e;
while(raxNext(&ri)) { while(raxNext(&ri)) {
char *tmpsafe;
e = (struct redisError *) ri.data; e = (struct redisError *) ri.data;
info = sdscatprintf(info, info = sdscatprintf(info,
"errorstat_%.*s:count=%lld\r\n", "errorstat_%.*s:count=%lld\r\n",
(int)ri.key_len, ri.key, e->count); (int)ri.key_len, getSafeInfoString((char *) ri.key, ri.key_len,
&tmpsafe), e->count);
if (tmpsafe != NULL) zfree(tmpsafe);
} }
raxStop(&ri); raxStop(&ri);
} }
/* Cluster */ /* Cluster */
if (allsections || defsections || !strcasecmp(section,"cluster")) { if (allsections || defsections || !strcasecmp(section,"cluster")) {
if (sections++) info = sdscat(info,"\r\n"); if (sections++) info = sdscat(info,"\r\n");
info = sdscatprintf(info, info = sdscatprintf(info,
"# Cluster\r\n" "# Cluster\r\n"
"cluster_enabled:%d\r\n", "cluster_enabled:%d\r\n",
skipping to change at line 5617 skipping to change at line 5678
* other child types should handle and store their pid's in dedicated va riables. * other child types should handle and store their pid's in dedicated va riables.
* *
* Today, we allows CHILD_TYPE_LDB to run in parallel with the other for k types: * Today, we allows CHILD_TYPE_LDB to run in parallel with the other for k types:
* - it isn't used for production, so it will not make the server be les s efficient * - it isn't used for production, so it will not make the server be les s efficient
* - used for debugging, and we don't want to block it from running whil e other * - used for debugging, and we don't want to block it from running whil e other
* forks are running (like RDB and AOF) */ * forks are running (like RDB and AOF) */
if (isMutuallyExclusiveChildType(purpose)) { if (isMutuallyExclusiveChildType(purpose)) {
server.child_pid = childpid; server.child_pid = childpid;
server.child_type = purpose; server.child_type = purpose;
server.stat_current_cow_bytes = 0; server.stat_current_cow_bytes = 0;
server.stat_current_save_keys_processed = 0;
server.stat_module_progress = 0;
server.stat_current_save_keys_total = dbTotalServerKeyCount();
} }
updateDictResizePolicy(); updateDictResizePolicy();
moduleFireServerEvent(REDISMODULE_EVENT_FORK_CHILD, moduleFireServerEvent(REDISMODULE_EVENT_FORK_CHILD,
REDISMODULE_SUBEVENT_FORK_CHILD_BORN, REDISMODULE_SUBEVENT_FORK_CHILD_BORN,
NULL); NULL);
} }
return childpid; return childpid;
} }
void sendChildCOWInfo(int ptype, int on_exit, char *pname) { void sendChildCowInfo(childInfoType info_type, char *pname) {
size_t private_dirty = zmalloc_get_private_dirty(-1); sendChildInfoGeneric(info_type, 0, -1, pname);
}
if (private_dirty) {
serverLog(on_exit ? LL_NOTICE : LL_VERBOSE,
"%s: %zu MB of memory used by copy-on-write",
pname, private_dirty/(1024*1024));
}
sendChildInfo(ptype, on_exit, private_dirty); void sendChildInfo(childInfoType info_type, size_t keys, char *pname) {
sendChildInfoGeneric(info_type, keys, -1, pname);
} }
void memtest(size_t megabytes, int passes); void memtest(size_t megabytes, int passes);
/* Returns 1 if there is --sentinel among the arguments or if /* Returns 1 if there is --sentinel among the arguments or if
* argv[0] contains "redis-sentinel". */ * argv[0] contains "redis-sentinel". */
int checkForSentinelMode(int argc, char **argv) { int checkForSentinelMode(int argc, char **argv) {
int j; int j;
if (strstr(argv[0],"redis-sentinel") != NULL) return 1; if (strstr(argv[0],"redis-sentinel") != NULL) return 1;
 End of changes. 25 change blocks. 
27 lines changed or deleted 90 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)