mirror of
https://github.com/fluencelabs/redis
synced 2025-04-01 15:21:03 +00:00
Make SORT BY <constant> STORE ... to always produce the same output by force sorting, so that we have deterministic replication of this command.
This commit is contained in:
parent
2c861050c1
commit
de79a2ee12
@ -203,6 +203,15 @@ void sortCommand(redisClient *c) {
|
|||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If we have STORE we need to force sorting for deterministic output
|
||||||
|
* and replication. We use alpha sorting since this is guaranteed to
|
||||||
|
* work with any input. */
|
||||||
|
if (storekey && dontsort) {
|
||||||
|
dontsort = 0;
|
||||||
|
alpha = 1;
|
||||||
|
sortby = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Destructively convert encoded sorted sets for SORT. */
|
/* Destructively convert encoded sorted sets for SORT. */
|
||||||
if (sortval->type == REDIS_ZSET)
|
if (sortval->type == REDIS_ZSET)
|
||||||
zsetConvert(sortval, REDIS_ENCODING_SKIPLIST);
|
zsetConvert(sortval, REDIS_ENCODING_SKIPLIST);
|
||||||
|
@ -157,6 +157,13 @@ start_server {
|
|||||||
r exists foo
|
r exists foo
|
||||||
} {0}
|
} {0}
|
||||||
|
|
||||||
|
test "SORT with BY <constant> and STORE should still order output" {
|
||||||
|
r del myset mylist
|
||||||
|
r sadd myset a b c d e f g h i l m n o p q r s t u v z
|
||||||
|
r sort myset alpha by _ store mylist
|
||||||
|
r lrange mylist 0 -1
|
||||||
|
} {a b c d e f g h i l m n o p q r s t u v z}
|
||||||
|
|
||||||
tags {"slow"} {
|
tags {"slow"} {
|
||||||
set num 100
|
set num 100
|
||||||
set res [create_random_dataset $num lpush]
|
set res [create_random_dataset $num lpush]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user