diff --git a/src/aof.c b/src/aof.c index 486749f11711f4cf1b81ba852321e360822b1809..262c780a409c6d79c111e8eb30c3365fd36c2483 100644 --- a/src/aof.c +++ b/src/aof.c @@ -713,7 +713,7 @@ int loadAppendOnlyFile(char *filename) { serverLog(LL_NOTICE,"Reading RDB preamble from AOF file..."); if (fseek(fp,0,SEEK_SET) == -1) goto readerr; rioInitWithFile(&rdb,fp); - if (rdbLoadRio(&rdb,NULL) != C_OK) { + if (rdbLoadRio(&rdb,NULL,1) != C_OK) { serverLog(LL_WARNING,"Error reading the RDB preamble of the AOF file, AOF loading aborted"); goto readerr; } else { diff --git a/src/rdb.c b/src/rdb.c index 5bfb52f80674bfdafa9bd9d24103ce34586dd0f6..be3927ff0a18391c7616a969ba47dbca1da88ce0 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -1503,7 +1503,7 @@ void rdbLoadProgressCallback(rio *r, const void *buf, size_t len) { /* Load an RDB file from the rio stream 'rdb'. On success C_OK is returned, * otherwise C_ERR is returned and 'errno' is set accordingly. */ -int rdbLoadRio(rio *rdb, rdbSaveInfo *rsi) { +int rdbLoadRio(rio *rdb, rdbSaveInfo *rsi, int loading_aof) { uint64_t dbid; int type, rdbver; redisDb *db = server.db+0; @@ -1631,7 +1631,7 @@ int rdbLoadRio(rio *rdb, rdbSaveInfo *rsi) { * received from the master. In the latter case, the master is * responsible for key expiry. If we would expire keys here, the * snapshot taken by the master may not be reflected on the slave. */ - if (server.masterhost == NULL && expiretime != -1 && expiretime < now) { + if (server.masterhost == NULL && !loading_aof && expiretime != -1 && expiretime < now) { decrRefCount(key); decrRefCount(val); continue; @@ -1682,7 +1682,7 @@ int rdbLoad(char *filename, rdbSaveInfo *rsi) { if ((fp = fopen(filename,"r")) == NULL) return C_ERR; startLoading(fp); rioInitWithFile(&rdb,fp); - retval = rdbLoadRio(&rdb,rsi); + retval = rdbLoadRio(&rdb,rsi,0); fclose(fp); stopLoading(); return retval; diff --git a/src/rdb.h b/src/rdb.h index 593284a5d805e2227e90cd39ccf4641c5ac4b67f..0b8e40e915a924f1ea4c3d01ca932cc6cb1884e8 100644 --- a/src/rdb.h +++ b/src/rdb.h @@ -146,7 +146,7 @@ int rdbSaveBinaryDoubleValue(rio *rdb, double val); int rdbLoadBinaryDoubleValue(rio *rdb, double *val); int rdbSaveBinaryFloatValue(rio *rdb, float val); int rdbLoadBinaryFloatValue(rio *rdb, float *val); -int rdbLoadRio(rio *rdb, rdbSaveInfo *rsi); +int rdbLoadRio(rio *rdb, rdbSaveInfo *rsi, int loading_aof); rdbSaveInfo *rdbPopulateSaveInfo(rdbSaveInfo *rsi); #endif