redis/tests/unit/type
sundb b00a235186
Use Reservoir Sampling for random sampling of dict, and fix hang during fork (#12276)
## Issue:
When a dict has a long chain or the length of the chain is longer than
the number of samples, we will never be able to sample the elements
at the end of the chain using dictGetSomeKeys().
This could mean that SRANDMEMBER can be hang in and endless loop.
The most severe case, is the pathological case of when someone uses SCAN+DEL
or SSCAN+SREM creating an unevenly distributed dict.
This was amplified by the recent change in #11692 which prevented a
down-sizing rehashing while there is a fork.

## Solution
1. Before, we will stop sampling when we reach the maximum number
  of samples, even if there is more data after the current chain.
  Now when we reach the maximum we use the Reservoir Sampling
  algorithm to fairly sample the end of the chain that cannot be sampled
2. Fix the rehashing code, so that the same as it allows rehashing for up-sizing
  during fork when the ratio is extreme, it will allow it for down-sizing as well.

Issue was introduced (or became more severe) by #11692

Co-authored-by: Oran Agra <oran@redislabs.com>
2023-06-16 19:13:07 +03:00
..
hash.tcl Adding test case for hvals, hkeys, hexists against wrong type (#12198) 2023-05-24 09:34:13 +03:00
incr.tcl add test cases for decr decrby on missing key (#12070) 2023-04-19 09:55:56 +03:00
list-2.tcl Minor improvements for list-2 test (#8156) 2020-12-08 16:26:38 +02:00
list-3.tcl Fix quicklist node not being recompressed correctly after inserting a new node before or after it (#10120) 2022-01-16 08:54:40 +02:00
list-common.tcl Add listpack encoding for list (#11303) 2022-11-16 20:29:46 +02:00
list.tcl Add command being unblocked cause another command to get unblocked execution order test (#12324) 2023-06-16 15:39:00 +03:00
set.tcl Use Reservoir Sampling for random sampling of dict, and fix hang during fork (#12276) 2023-06-16 19:13:07 +03:00
stream-cgroups.tcl Fix XREADGROUP BLOCK stuck in endless loop (#12301) 2023-06-13 13:27:05 +03:00
stream.tcl Fix XSETID with max_deleted_entry_id issue (#11444) 2022-11-02 16:16:16 +02:00
string.tcl Optimize MSETNX to avoid double lookup (#11944) 2023-05-28 10:58:29 +03:00
zset.tcl Removing the duplicate test case (#12310) 2023-06-14 10:03:33 +03:00