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

Function rdbReportError

src/rdb.cpp:64–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62void rdbReportError(int corruption_error, int linenum, const char *reason, ...) __attribute__ ((format (printf, 3, 4)));
63#endif
64void rdbReportError(int corruption_error, int linenum, const char *reason, ...) {
65 va_list ap;
66 char msg[1024];
67 int len;
68
69 len = snprintf(msg,sizeof(msg),
70 "Internal error in RDB reading offset %llu, function at rdb.c:%d -> ",
71 (unsigned long long)g_pserver->loading_loaded_bytes, linenum);
72 va_start(ap,reason);
73 vsnprintf(msg+len,sizeof(msg)-len,reason,ap);
74 va_end(ap);
75
76 if (!g_pserver->loading) {
77 /* If we're in the context of a RESTORE command, just propagate the error. */
78 /* log in VERBOSE, and return (don't exit). */
79 serverLog(LL_VERBOSE, "%s", msg);
80 return;
81 } else if (rdbCheckMode) {
82 /* If we're inside the rdb checker, let it handle the error. */
83 rdbCheckError("%s",msg);
84 } else if (rdbFileBeingLoaded) {
85 /* If we're loading an rdb file form disk, run rdb check (and exit) */
86 serverLog(LL_WARNING, "%s", msg);
87 const char *argv[2] = {"",rdbFileBeingLoaded};
88 redis_check_rdb_main(2,argv,NULL);
89 } else if (corruption_error) {
90 /* In diskless loading, in case of corrupt file, log and exit. */
91 serverLog(LL_WARNING, "%s. Failure loading rdb format", msg);
92 } else {
93 /* In diskless loading, in case of a short read (not a corrupt
94 * file), log and proceed (don't exit). */
95 serverLog(LL_WARNING, "%s. Failure loading rdb format from socket, assuming connection error, resuming operation.", msg);
96 return;
97 }
98 serverLog(LL_WARNING, "Terminating server after rdb file reading failure.");
99 exit(1);
100}
101
102static ssize_t rdbWriteRaw(rio *rdb, void *p, size_t len) {
103 if (rdb && rioWrite(rdb,p,len) == 0)

Callers

nothing calls this directly

Calls 3

serverLogFunction · 0.85
rdbCheckErrorFunction · 0.85
redis_check_rdb_mainFunction · 0.85

Tested by

no test coverage detected