"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/rdb.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.

rdb.c  (redis-6.2-rc3):rdb.c  (redis-6.2.0)
skipping to change at line 1225 skipping to change at line 1225
* integer pointed by 'error' is set to the value of errno just after the I/O * integer pointed by 'error' is set to the value of errno just after the I/O
* error. */ * error. */
int rdbSaveRio(rio *rdb, int *error, int rdbflags, rdbSaveInfo *rsi) { int rdbSaveRio(rio *rdb, int *error, int rdbflags, rdbSaveInfo *rsi) {
dictIterator *di = NULL; dictIterator *di = NULL;
dictEntry *de; dictEntry *de;
char magic[10]; char magic[10];
uint64_t cksum; uint64_t cksum;
size_t processed = 0; size_t processed = 0;
int j; int j;
long key_count = 0; long key_count = 0;
long long cow_updated_time = 0; long long info_updated_time = 0;
char *pname = (rdbflags & RDBFLAGS_AOF_PREAMBLE) ? "AOF rewrite" : "RDB";
if (server.rdb_checksum) if (server.rdb_checksum)
rdb->update_cksum = rioGenericUpdateChecksum; rdb->update_cksum = rioGenericUpdateChecksum;
snprintf(magic,sizeof(magic),"REDIS%04d",RDB_VERSION); snprintf(magic,sizeof(magic),"REDIS%04d",RDB_VERSION);
if (rdbWriteRaw(rdb,magic,9) == -1) goto werr; if (rdbWriteRaw(rdb,magic,9) == -1) goto werr;
if (rdbSaveInfoAuxFields(rdb,rdbflags,rsi) == -1) goto werr; if (rdbSaveInfoAuxFields(rdb,rdbflags,rsi) == -1) goto werr;
if (rdbSaveModulesAux(rdb, REDISMODULE_AUX_BEFORE_RDB) == -1) goto werr; if (rdbSaveModulesAux(rdb, REDISMODULE_AUX_BEFORE_RDB) == -1) goto werr;
for (j = 0; j < server.dbnum; j++) { for (j = 0; j < server.dbnum; j++) {
redisDb *db = server.db+j; redisDb *db = server.db+j;
skipping to change at line 1272 skipping to change at line 1273
/* When this RDB is produced as part of an AOF rewrite, move /* When this RDB is produced as part of an AOF rewrite, move
* accumulated diff from parent to child while rewriting in * accumulated diff from parent to child while rewriting in
* order to have a smaller final write. */ * order to have a smaller final write. */
if (rdbflags & RDBFLAGS_AOF_PREAMBLE && if (rdbflags & RDBFLAGS_AOF_PREAMBLE &&
rdb->processed_bytes > processed+AOF_READ_DIFF_INTERVAL_BYTES) rdb->processed_bytes > processed+AOF_READ_DIFF_INTERVAL_BYTES)
{ {
processed = rdb->processed_bytes; processed = rdb->processed_bytes;
aofReadDiffFromParent(); aofReadDiffFromParent();
} }
/* Update COW info every 1 second (approximately). /* Update child info every 1 second (approximately).
* in order to avoid calling mstime() on each iteration, we will * in order to avoid calling mstime() on each iteration, we will
* check the diff every 1024 keys */ * check the diff every 1024 keys */
if ((key_count & 1023) == 0) { if ((key_count++ & 1023) == 0) {
key_count = 0;
long long now = mstime(); long long now = mstime();
if (now - cow_updated_time >= 1000) { if (now - info_updated_time >= 1000) {
if (rdbflags & RDBFLAGS_AOF_PREAMBLE) { sendChildInfo(CHILD_INFO_TYPE_CURRENT_INFO, key_count, pname
sendChildCOWInfo(CHILD_TYPE_AOF, 0, "AOF rewrite"); );
} else { info_updated_time = now;
sendChildCOWInfo(CHILD_TYPE_RDB, 0, "RDB");
}
cow_updated_time = now;
} }
} }
key_count++;
} }
dictReleaseIterator(di); dictReleaseIterator(di);
di = NULL; /* So that we don't release it again on error. */ di = NULL; /* So that we don't release it again on error. */
} }
/* If we are storing the replication information on disk, persist /* If we are storing the replication information on disk, persist
* the script cache as well: on successful PSYNC after a restart, we need * the script cache as well: on successful PSYNC after a restart, we need
* to be able to process any EVALSHA inside the replication backlog the * to be able to process any EVALSHA inside the replication backlog the
* master will send us. */ * master will send us. */
if (rsi && dictSize(server.lua_scripts)) { if (rsi && dictSize(server.lua_scripts)) {
skipping to change at line 1440 skipping to change at line 1435
server.lastbgsave_try = time(NULL); server.lastbgsave_try = time(NULL);
if ((childpid = redisFork(CHILD_TYPE_RDB)) == 0) { if ((childpid = redisFork(CHILD_TYPE_RDB)) == 0) {
int retval; int retval;
/* Child */ /* Child */
redisSetProcTitle("redis-rdb-bgsave"); redisSetProcTitle("redis-rdb-bgsave");
redisSetCpuAffinity(server.bgsave_cpulist); redisSetCpuAffinity(server.bgsave_cpulist);
retval = rdbSave(filename,rsi); retval = rdbSave(filename,rsi);
if (retval == C_OK) { if (retval == C_OK) {
sendChildCOWInfo(CHILD_TYPE_RDB, 1, "RDB"); sendChildCowInfo(CHILD_INFO_TYPE_RDB_COW_SIZE, "RDB");
} }
exitFromChild((retval == C_OK) ? 0 : 1); exitFromChild((retval == C_OK) ? 0 : 1);
} else { } else {
/* Parent */ /* Parent */
if (childpid == -1) { if (childpid == -1) {
server.lastbgsave_status = C_ERR; server.lastbgsave_status = C_ERR;
serverLog(LL_WARNING,"Can't save in background: fork: %s", serverLog(LL_WARNING,"Can't save in background: fork: %s",
strerror(errno)); strerror(errno));
return C_ERR; return C_ERR;
} }
skipping to change at line 2806 skipping to change at line 2801
rioInitWithFd(&rdb,rdb_pipe_write); rioInitWithFd(&rdb,rdb_pipe_write);
redisSetProcTitle("redis-rdb-to-slaves"); redisSetProcTitle("redis-rdb-to-slaves");
redisSetCpuAffinity(server.bgsave_cpulist); redisSetCpuAffinity(server.bgsave_cpulist);
retval = rdbSaveRioWithEOFMark(&rdb,NULL,rsi); retval = rdbSaveRioWithEOFMark(&rdb,NULL,rsi);
if (retval == C_OK && rioFlush(&rdb) == 0) if (retval == C_OK && rioFlush(&rdb) == 0)
retval = C_ERR; retval = C_ERR;
if (retval == C_OK) { if (retval == C_OK) {
sendChildCOWInfo(CHILD_TYPE_RDB, 1, "RDB"); sendChildCowInfo(CHILD_INFO_TYPE_RDB_COW_SIZE, "RDB");
} }
rioFreeFd(&rdb); rioFreeFd(&rdb);
/* wake up the reader, tell it we're done. */ /* wake up the reader, tell it we're done. */
close(rdb_pipe_write); close(rdb_pipe_write);
close(server.rdb_child_exit_pipe); /* close write end so that we can det ect the close on the parent. */ close(server.rdb_child_exit_pipe); /* close write end so that we can det ect the close on the parent. */
/* hold exit until the parent tells us it's safe. we're not expecting /* hold exit until the parent tells us it's safe. we're not expecting
* to read anything, just get the error when the pipe is closed. */ * to read anything, just get the error when the pipe is closed. */
dummy = read(safe_to_exit_pipe, pipefds, 1); dummy = read(safe_to_exit_pipe, pipefds, 1);
UNUSED(dummy); UNUSED(dummy);
 End of changes. 7 change blocks. 
14 lines changed or deleted 10 lines changed or added

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