MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / rdbLoadProgressCallback

Function rdbLoadProgressCallback

src/rdb.cpp:3044–3090  ·  view source on GitHub ↗

Track loading progress in order to serve client's from time to time and if needed calculate rdb checksum */

Source from the content-addressed store, hash-verified

3042/* Track loading progress in order to serve client's from time to time
3043 and if needed calculate rdb checksum */
3044void rdbLoadProgressCallback(rio *r, const void *buf, size_t len) {
3045 if (g_pserver->rdb_checksum)
3046 rioGenericUpdateChecksum(r, buf, len);
3047
3048 if ((g_pserver->loading_process_events_interval_bytes &&
3049 (r->processed_bytes + len)/g_pserver->loading_process_events_interval_bytes > r->processed_bytes/g_pserver->loading_process_events_interval_bytes) ||
3050 (g_pserver->loading_process_events_interval_keys &&
3051 (r->keys_since_last_callback >= g_pserver->loading_process_events_interval_keys)))
3052 {
3053 rdbAsyncWorkThread *pwthread = reinterpret_cast<rdbAsyncWorkThread*>(r->chksum_arg);
3054 mstime_t mstime;
3055 __atomic_load(&g_pserver->mstime, &mstime, __ATOMIC_RELAXED);
3056 bool fUpdateReplication = (mstime - r->last_update) > 1000;
3057
3058 if (fUpdateReplication) {
3059 listIter li;
3060 listNode *ln;
3061 listRewind(g_pserver->masters, &li);
3062 while ((ln = listNext(&li)))
3063 {
3064 struct redisMaster *mi = (struct redisMaster*)listNodeValue(ln);
3065 if (mi->masterhost && mi->repl_state == REPL_STATE_TRANSFER)
3066 replicationSendNewlineToMaster(mi);
3067 }
3068 }
3069 loadingProgress(r->processed_bytes);
3070
3071 if (pwthread)
3072 pwthread->pauseExecution();
3073 processEventsWhileBlocked(serverTL - g_pserver->rgthreadvar);
3074 if (pwthread)
3075 pwthread->resumeExecution();
3076
3077 processModuleLoadingProgressEvent(0);
3078
3079 if (fUpdateReplication) {
3080 robj *ping_argv[1];
3081
3082 ping_argv[0] = createStringObject("PING",4);
3083 replicationFeedSlaves(g_pserver->slaves, g_pserver->replicaseldb, ping_argv, 1);
3084 decrRefCount(ping_argv[0]);
3085 }
3086
3087 if (fUpdateReplication) r->last_update = g_pserver->mstime;
3088 r->keys_since_last_callback = 0;
3089 }
3090}
3091
3092
3093/* Load an RDB file from the rio stream 'rdb'. On success C_OK is returned,

Callers

nothing calls this directly

Calls 12

rioGenericUpdateChecksumFunction · 0.85
listRewindFunction · 0.85
listNextFunction · 0.85
loadingProgressFunction · 0.85
replicationFeedSlavesFunction · 0.85
decrRefCountFunction · 0.85
pauseExecutionMethod · 0.80
resumeExecutionMethod · 0.80
createStringObjectFunction · 0.70

Tested by

no test coverage detected