summaryrefslogtreecommitdiff
path: root/src/rdb.c
diff options
context:
space:
mode:
authorWuYunlong <xzsyeb@126.com>2018-05-26 09:43:25 +0800
committerantirez <antirez@gmail.com>2018-05-29 12:35:15 +0200
commit2a887bd53f992b940c7c9838a5dbdc2de1e3720a (patch)
treef9c0d9ee3a121fa7b6d68e0a64a1dbaa55278edc /src/rdb.c
parent6536ce27a4b63ab44fbd209422b2ef7f9160721d (diff)
downloadredis-2a887bd53f992b940c7c9838a5dbdc2de1e3720a.tar.gz
Fix rdb save by allowing dumping of expire keys, so that when
we add a new slave, and do a failover, eighter by manual or not, other local slaves will delete the expired keys properly.
Diffstat (limited to 'src/rdb.c')
-rw-r--r--src/rdb.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/rdb.c b/src/rdb.c
index c5a397b27..eeb7f0ecc 100644
--- a/src/rdb.c
+++ b/src/rdb.c
@@ -988,16 +988,13 @@ size_t rdbSavedObjectLen(robj *o) {
* On error -1 is returned.
* On success if the key was actually saved 1 is returned, otherwise 0
* is returned (the key was already expired). */
-int rdbSaveKeyValuePair(rio *rdb, robj *key, robj *val,
- long long expiretime, long long now)
+int rdbSaveKeyValuePair(rio *rdb, robj *key, robj *val, long long expiretime)
{
int savelru = server.maxmemory_policy & MAXMEMORY_FLAG_LRU;
int savelfu = server.maxmemory_policy & MAXMEMORY_FLAG_LFU;
/* Save the expire time */
if (expiretime != -1) {
- /* If this key is already expired skip it */
- if (expiretime < now) return 0;
if (rdbSaveType(rdb,RDB_OPCODE_EXPIRETIME_MS) == -1) return -1;
if (rdbSaveMillisecondTime(rdb,expiretime) == -1) return -1;
}
@@ -1091,7 +1088,6 @@ int rdbSaveRio(rio *rdb, int *error, int flags, rdbSaveInfo *rsi) {
dictEntry *de;
char magic[10];
int j;
- long long now = mstime();
uint64_t cksum;
size_t processed = 0;
@@ -1134,7 +1130,7 @@ int rdbSaveRio(rio *rdb, int *error, int flags, rdbSaveInfo *rsi) {
initStaticStringObject(key,keystr);
expire = getExpire(db,&key);
- if (rdbSaveKeyValuePair(rdb,&key,o,expire,now) == -1) goto werr;
+ if (rdbSaveKeyValuePair(rdb,&key,o,expire) == -1) goto werr;
/* When this RDB is produced as part of an AOF rewrite, move
* accumulated diff from parent to child while rewriting in