MCPcopy Create free account
hub / github.com/F-Stack/f-stack / bgsaveCommand

Function bgsaveCommand

app/redis-6.2.6/src/rdb.c:2988–3022  ·  view source on GitHub ↗

BGSAVE [SCHEDULE] */

Source from the content-addressed store, hash-verified

2986
2987/* BGSAVE [SCHEDULE] */
2988void bgsaveCommand(client *c) {
2989 int schedule = 0;
2990
2991 /* The SCHEDULE option changes the behavior of BGSAVE when an AOF rewrite
2992 * is in progress. Instead of returning an error a BGSAVE gets scheduled. */
2993 if (c->argc > 1) {
2994 if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"schedule")) {
2995 schedule = 1;
2996 } else {
2997 addReplyErrorObject(c,shared.syntaxerr);
2998 return;
2999 }
3000 }
3001
3002 rdbSaveInfo rsi, *rsiptr;
3003 rsiptr = rdbPopulateSaveInfo(&rsi);
3004
3005 if (server.child_type == CHILD_TYPE_RDB) {
3006 addReplyError(c,"Background save already in progress");
3007 } else if (hasActiveChildProcess()) {
3008 if (schedule) {
3009 server.rdb_bgsave_scheduled = 1;
3010 addReplyStatus(c,"Background saving scheduled");
3011 } else {
3012 addReplyError(c,
3013 "Another child process is active (AOF?): can't BGSAVE right now. "
3014 "Use BGSAVE SCHEDULE in order to schedule a BGSAVE whenever "
3015 "possible.");
3016 }
3017 } else if (rdbSaveBackground(server.rdb_filename,rsiptr) == C_OK) {
3018 addReplyStatus(c,"Background saving started");
3019 } else {
3020 addReplyErrorObject(c,shared.err);
3021 }
3022}
3023
3024/* Populate the rdbSaveInfo structure used to persist the replication
3025 * information inside the RDB file. Currently the structure explicitly

Callers

nothing calls this directly

Calls 7

strcasecmpFunction · 0.85
addReplyErrorObjectFunction · 0.85
rdbPopulateSaveInfoFunction · 0.85
addReplyErrorFunction · 0.85
hasActiveChildProcessFunction · 0.85
addReplyStatusFunction · 0.85
rdbSaveBackgroundFunction · 0.85

Tested by

no test coverage detected