Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
27beaf2f
Commit
27beaf2f
authored
Jun 11, 2018
by
antirez
Browse files
Regression test for the dictScan() issue #4906.
parent
be899b82
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/unit/scan.tcl
View file @
27beaf2f
...
@@ -236,4 +236,42 @@ start_server {tags {"scan"}} {
...
@@ -236,4 +236,42 @@ start_server {tags {"scan"}} {
set first_score
[
lindex $res 1
]
set first_score
[
lindex $res 1
]
assert
{
$first
_score != 0
}
assert
{
$first
_score != 0
}
}
}
test
"SCAN regression test for issue #4906"
{
r del set
set toremove
{}
array set found
{}
for
{
set j 0
}
{
$j
< 500
}
{
incr j
}
{
r sadd set $j
if
{
$j
>= 100
}
{
lappend toremove $j
}
}
# Start scanning
set cursor 0
set iteration 0
while
{
!
(
$cursor
== 0 && $iteration != 0
)}
{
lassign
[
r sscan set $cursor
]
cursor items
# Mark found items. We expect to find from 0 to 99 at the end
# since those elements will never be removed during the scanning.
foreach i $items
{
set found
(
$i
)
1
}
incr iteration
# At some point remove most of the items to trigger the
# rehashing to a smaller hash table.
if
{
$iteration
== 1
}
{
r srem set
{*}
$toremove
}
}
# Verify that SSCAN reported everything from 0 to 99
for
{
set j 0
}
{
$j
< 100
}
{
incr j
}
{
if
{
!
[
info exists found
(
$j
)]}
{
fail
"SSCAN element missing
$j
"
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment