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

Function bgsaveCommand

src/rdb.cpp:3974–4008  ·  view source on GitHub ↗

BGSAVE [SCHEDULE] */

Source from the content-addressed store, hash-verified

3972
3973/* BGSAVE [SCHEDULE] */
3974void bgsaveCommand(client *c) {
3975 int schedule = 0;
3976
3977 /* The SCHEDULE option changes the behavior of BGSAVE when an AOF rewrite
3978 * is in progress. Instead of returning an error a BGSAVE gets scheduled. */
3979 if (c->argc > 1) {
3980 if (c->argc == 2 && !strcasecmp(szFromObj(c->argv[1]),"schedule")) {
3981 schedule = 1;
3982 } else {
3983 addReplyErrorObject(c,shared.syntaxerr);
3984 return;
3985 }
3986 }
3987
3988 rdbSaveInfo rsi, *rsiptr;
3989 rsiptr = rdbPopulateSaveInfo(&rsi);
3990
3991 if (g_pserver->FRdbSaveInProgress()) {
3992 addReplyError(c,"Background save already in progress");
3993 } else if (hasActiveChildProcess()) {
3994 if (schedule) {
3995 g_pserver->rdb_bgsave_scheduled = 1;
3996 addReplyStatus(c,"Background saving scheduled");
3997 } else {
3998 addReplyError(c,
3999 "Another child process is active (AOF?): can't BGSAVE right now. "
4000 "Use BGSAVE SCHEDULE in order to schedule a BGSAVE whenever "
4001 "possible.");
4002 }
4003 } else if (rdbSaveBackground(rsiptr) == C_OK) {
4004 addReplyStatus(c,"Background saving started");
4005 } else {
4006 addReplyErrorObject(c,shared.err);
4007 }
4008}
4009
4010/* Populate the rdbSaveInfo structure used to persist the replication
4011 * information inside the RDB file. Currently the structure explicitly

Callers

nothing calls this directly

Calls 8

szFromObjFunction · 0.85
addReplyErrorObjectFunction · 0.85
rdbPopulateSaveInfoFunction · 0.85
addReplyErrorFunction · 0.85
hasActiveChildProcessFunction · 0.85
addReplyStatusFunction · 0.85
rdbSaveBackgroundFunction · 0.85
FRdbSaveInProgressMethod · 0.80

Tested by

no test coverage detected