summaryrefslogtreecommitdiff
path: root/src/t_hash.c
diff options
context:
space:
mode:
authorBinbin <binloveplay1314@qq.com>2023-05-17 02:32:21 +0800
committerGitHub <noreply@github.com>2023-05-16 11:32:21 -0700
commitfd566f405094c77f5b6b84195c93552b9e01d4a8 (patch)
treece0538deaa96cc18bea56d7cafb98e91fa63fc41 /src/t_hash.c
parente45272884e61f266662bcf0e8f3799c986236de6 (diff)
downloadredis-fd566f405094c77f5b6b84195c93552b9e01d4a8.tar.gz
Fix for set max entries edge case in setTypeCreate / setTypeMaybeConvert (#12183)
In the judgment in setTypeCreate, we should judge size_hint <= max_entries. This results in the following inconsistencies: ``` 127.0.0.1:6379> config set set-max-intset-entries 5 set-max-listpack-entries 5 OK 127.0.0.1:6379> sadd intset_set1 1 2 3 4 5 (integer) 5 127.0.0.1:6379> object encoding intset_set1 "hashtable" 127.0.0.1:6379> sadd intset_set2 1 2 3 4 (integer) 4 127.0.0.1:6379> sadd intset_set2 5 (integer) 1 127.0.0.1:6379> object encoding intset_set2 "intset" 127.0.0.1:6379> sadd listpack_set1 a 1 2 3 4 (integer) 5 127.0.0.1:6379> object encoding listpack_set1 "hashtable" 127.0.0.1:6379> sadd listpack_set2 a 1 2 3 (integer) 4 127.0.0.1:6379> sadd listpack_set2 4 (integer) 1 127.0.0.1:6379> object encoding listpack_set2 "listpack" ``` This was introduced in #12019, added corresponding tests.
Diffstat (limited to 'src/t_hash.c')
-rw-r--r--src/t_hash.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/t_hash.c b/src/t_hash.c
index f7d5af649..2d50ca304 100644
--- a/src/t_hash.c
+++ b/src/t_hash.c
@@ -45,7 +45,7 @@ void hashTypeTryConversion(robj *o, robj **argv, int start, int end) {
/* We guess that most of the values in the input are unique, so
* if there are enough arguments we create a pre-sized hash, which
- * might overallocate memory if their are duplicates. */
+ * might over allocate memory if there are duplicates. */
size_t new_fields = (end - start + 1) / 2;
if (new_fields > server.hash_max_listpack_entries) {
hashTypeConvert(o, OBJ_ENCODING_HT);