Unverified Commit 6444214c authored by Qu Chen's avatar Qu Chen Committed by GitHub
Browse files

Fix master client check in expireIfNeeded() for read only replica (#11761)

Redis 7.0 introduced new logic in expireIfNeeded() where a read-only replica would never consider a key as expired when replicating commands from the master. See acf3495e. This was done by checking server.current_client with server.master. However, we should instead check for CLIENT_MASTER flag for this logic to be more robust and consistent with the rest of the Redis code base.
parent cc97f4cf
...@@ -1708,7 +1708,7 @@ int expireIfNeeded(redisDb *db, robj *key, int flags) { ...@@ -1708,7 +1708,7 @@ int expireIfNeeded(redisDb *db, robj *key, int flags) {
* When replicating commands from the master, keys are never considered * When replicating commands from the master, keys are never considered
* expired. */ * expired. */
if (server.masterhost != NULL) { if (server.masterhost != NULL) {
if (server.current_client == server.master) return 0; if (server.current_client && (server.current_client->flags & CLIENT_MASTER)) return 0;
if (!(flags & EXPIRE_FORCE_DELETE_EXPIRED)) return 1; if (!(flags & EXPIRE_FORCE_DELETE_EXPIRED)) return 1;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment