Skip to content
Browse files

Merge pull request #296 from pietern/2.4-expirefix

Don't expire keys when loading an RDB after a SYNC
  • Loading branch information...
2 parents 8b8261e + aa794ac commit 58bfbd1fa42ca7121a9dcff18d77b133ae5570c2 @antirez committed Jan 16, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/rdb.c
View
8 src/rdb.c
@@ -993,8 +993,12 @@ int rdbLoad(char *filename) {
if ((key = rdbLoadStringObject(fp)) == NULL) goto eoferr;
/* Read value */
if ((val = rdbLoadObject(type,fp)) == NULL) goto eoferr;
- /* Check if the key already expired */
- if (expiretime != -1 && expiretime < now) {
+ /* Check if the key already expired. This function is used when loading
+ * an RDB file from disk, either at startup, or when an RDB was
+ * 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) {
decrRefCount(key);
decrRefCount(val);
continue;

0 comments on commit 58bfbd1

Please sign in to comment.
Something went wrong with that request. Please try again.