From 02fe0138fe5e76918e03bbb9a49f6cd679e0bc72 Mon Sep 17 00:00:00 2001 From: huangzhw Date: Mon, 4 Jan 2021 16:28:47 +0800 Subject: [PATCH] sort Command lookupKeyRead and lookupKeyWrite are used on the opposite (#8283) This is a recent problem, introduced by 9b2a426 (redis 6.0) The implications are: The sole difference between LookupKeyRead and LookupKeyWrite is for command executed on a replica, which are not received from its master client. (for the master, and for the master client on the replica, these two functions behave the same)! Since SORT is a write command, this bug only implicates a writable-replica. And these are its implications: - SORT STORE will behave as it did before the above mentioned commit (like before redis 6.0). on a writable-replica an already logically expired the key would have appeared missing. (store dest key would be deleted, instead of being populated with the data from the already logically expired key) - SORT (the non store variant, which in theory could have been executed on read-only-replica if it weren't for the write flag), will (in redis 6.0) have a new bug and return the data from the already logically expired key instead of empty response. (cherry picked from commit 6230ba081109beaf367d8fe3552bc848dc3896f4) --- src/sort.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sort.c b/src/sort.c index aeef53e6a..7fc5c634e 100644 --- a/src/sort.c +++ b/src/sort.c @@ -270,7 +270,7 @@ void sortCommand(client *c) { } /* Lookup the key to sort. It must be of the right types */ - if (storekey) + if (!storekey) sortval = lookupKeyRead(c->db,c->argv[1]); else sortval = lookupKeyWrite(c->db,c->argv[1]);