mirror of
https://github.com/redis/redis.git
synced 2026-06-09 08:55:06 -04:00
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 acf3495. 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.
This commit is contained in:
parent
cc97f4cf35
commit
6444214ce4
1 changed files with 1 additions and 1 deletions
2
src/db.c
2
src/db.c
|
|
@ -1708,7 +1708,7 @@ int expireIfNeeded(redisDb *db, robj *key, int flags) {
|
|||
* When replicating commands from the master, keys are never considered
|
||||
* expired. */
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue