• Binbin's avatar
    Fix race in slot dict resize test (#12942) · 131d95f2
    Binbin authored
    The test have a race:
    ```
    *** [err]: Redis can rewind and trigger smaller slot resizing in tests/unit/other.tcl
    Expected '[Dictionary HT]
    Hash table 0 stats (main hash table):
     table size: 12
     number of elements: 2
    [Expires HT]
    Hash table 0 stats (main hash table):
    No stats available for empty dictionaries
    ' to match '*table size: 8*' (context: type eval line 12 cmd {assert_match "*table size: 8*" [r debug HTSTATS 0]} proc ::test)
    ```
    
    When `r del "{alice}$j"` is executed in the loop, when the key is
    deleted to [9, 12], the load factor has meet HASHTABLE_MIN_FILL,
    if serverCron happens to trigger slot dict resize, then the test
    will fail. Because there is not way to meet HASHTABLE_MIN_FILL in
    the subsequent dels.
    
    The solution is to avoid triggering the resize in advance. We can
    use multi to delete them at once, or we can disable the resize.
    Since we disabled resize in the previous test, the fix also uses
    the method of disabling resize.
    
    The test is introduced in #12802.
    131d95f2
other.tcl 14.9 KB