Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle keyIsExpiredWithDictIndex to make it check for import mode #1368

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,7 @@ void propagateDeletion(serverDb *db, robj *key, int lazy) {
decrRefCount(argv[1]);
}

int keyIsExpiredWithDictIndex(serverDb *db, robj *key, int dict_index) {
static int keyIsExpiredWithDictIndexImpl(serverDb *db, robj *key, int dict_index) {
/* Don't expire anything while loading. It will be done later. */
if (server.loading) return 0;

Expand All @@ -1806,9 +1806,8 @@ int keyIsExpiredWithDictIndex(serverDb *db, robj *key, int dict_index) {
}

/* Check if the key is expired. */
int keyIsExpired(serverDb *db, robj *key) {
int dict_index = getKVStoreIndexForKey(key->ptr);
if (!keyIsExpiredWithDictIndex(db, key, dict_index)) return 0;
int keyIsExpiredWithDictIndex(serverDb *db, robj *key, int dict_index) {
if (!keyIsExpiredWithDictIndexImpl(db, key, dict_index)) return 0;

/* See expireIfNeededWithDictIndex for more details. */
if (server.primary_host == NULL && server.import_mode) {
Expand All @@ -1817,9 +1816,15 @@ int keyIsExpired(serverDb *db, robj *key) {
return 1;
}

/* Check if the key is expired. */
int keyIsExpired(serverDb *db, robj *key) {
int dict_index = getKVStoreIndexForKey(key->ptr);
return keyIsExpiredWithDictIndex(db, key, dict_index);
}

keyStatus expireIfNeededWithDictIndex(serverDb *db, robj *key, int flags, int dict_index) {
if (server.lazy_expire_disabled) return KEY_VALID;
if (!keyIsExpiredWithDictIndex(db, key, dict_index)) return KEY_VALID;
if (!keyIsExpiredWithDictIndexImpl(db, key, dict_index)) return KEY_VALID;

/* If we are running in the context of a replica, instead of
* evicting the expired key from the database, we return ASAP:
Expand Down
Loading