Unverified Commit 9a7d3118 authored by Binbin's avatar Binbin Committed by GitHub
Browse files

Fix dict resize allow test (#13016)

Ci report this failure:
```
*** [err]: Don't rehash if used memory exceeds maxmemory after rehash in tests/unit/maxmemory.tcl
Expected '4098' to equal or match '4002'

WARNING: the new maxmemory value set via CONFIG SET (1176088) is smaller than the current memory usage (1231083)
```

It can be seen from the log that used_memory changed before we set
maxmemory.
The reason is that in #12819, in cron, in addition to trying to shrink,
we will
also tyring to expand. The dict was expanded by cron before we set
maxmemory,
causing the test to fail.

Before setting maxmemory, we only add 4095 keys to avoid triggering
resize.
parent 6016973a
...@@ -421,11 +421,16 @@ start_server {tags {"maxmemory external:skip"}} { ...@@ -421,11 +421,16 @@ start_server {tags {"maxmemory external:skip"}} {
r config set maxmemory-policy allkeys-random r config set maxmemory-policy allkeys-random
# Next rehash size is 8192, that will eat 64k memory # Next rehash size is 8192, that will eat 64k memory
populate 4096 "" 1 populate 4095 "" 1
set used [s used_memory] set used [s used_memory]
set limit [expr {$used + 10*1024}] set limit [expr {$used + 10*1024}]
r config set maxmemory $limit r config set maxmemory $limit
# Adding a key to meet the 1:1 radio.
r set k0 v0
# The dict has reached 4096, it can be resized in tryResizeHashTables in cron,
# or we add a key to let it check whether it can be resized.
r set k1 v1 r set k1 v1
# Next writing command will trigger evicting some keys if last # Next writing command will trigger evicting some keys if last
# command trigger DB dict rehash # command trigger DB dict rehash
......
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