summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmer Shadmi <76992134+oshadmi@users.noreply.github.com>2021-07-06 08:21:17 +0300
committerOran Agra <oran@redislabs.com>2021-07-21 21:07:02 +0300
commit518fd2dcc453fda573d8ef1b4d3c22975d8e8c3f (patch)
treefcf695c22cc72ae5ff568c7102551e2141d72920
parentd80c87111b2dc1eea043240fcd5b88381bb747fd (diff)
downloadredis-518fd2dcc453fda573d8ef1b4d3c22975d8e8c3f.tar.gz
Avoid exiting to allow diskless loading to recover from RDB short read on module AUX data (#9199)
Currently a replica is able to recover from a short read (when diskless loading is enabled) and avoid crashing/exiting, replying to the master and then the rdb could be sent again by the master for another load attempt by the replica. There were a few scenarios that were not behaving similarly, such as when there is no end-of-file marker, or when module aux data failed to load, which should be allowed to occur due to a short read. (cherry picked from commit f06d782f5abcb30efb0117841232828ed3e129bf)
-rw-r--r--src/rdb.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/rdb.c b/src/rdb.c
index bd287bc6f..82b4cf506 100644
--- a/src/rdb.c
+++ b/src/rdb.c
@@ -2263,8 +2263,10 @@ int rdbLoadRio(rio *rdb, int rdbflags, rdbSaveInfo *rsi) {
int when_opcode = rdbLoadLen(rdb,NULL);
int when = rdbLoadLen(rdb,NULL);
if (rioGetReadError(rdb)) goto eoferr;
- if (when_opcode != RDB_MODULE_OPCODE_UINT)
+ if (when_opcode != RDB_MODULE_OPCODE_UINT) {
rdbReportReadError("bad when_opcode");
+ goto eoferr;
+ }
moduleType *mt = moduleTypeLookupModuleByID(moduleid);
char name[10];
moduleTypeNameByID(name,moduleid);
@@ -2288,7 +2290,7 @@ int rdbLoadRio(rio *rdb, int rdbflags, rdbSaveInfo *rsi) {
if (mt->aux_load(&io,moduleid&1023, when) != REDISMODULE_OK || io.error) {
moduleTypeNameByID(name,moduleid);
serverLog(LL_WARNING,"The RDB file contains module AUX data for the module type '%s', that the responsible module is not able to load. Check for modules log above for additional clues.", name);
- exit(1);
+ goto eoferr;
}
if (io.ctx) {
moduleFreeContext(io.ctx);
@@ -2297,7 +2299,7 @@ int rdbLoadRio(rio *rdb, int rdbflags, rdbSaveInfo *rsi) {
uint64_t eof = rdbLoadLen(rdb,NULL);
if (eof != RDB_MODULE_OPCODE_EOF) {
serverLog(LL_WARNING,"The RDB file contains module AUX data for the module '%s' that is not terminated by the proper module value EOF marker", name);
- exit(1);
+ goto eoferr;
}
continue;
} else {