Skip to content

Commit

Permalink
Improve stability of new CSC eviction test (#8160)
Browse files Browse the repository at this point in the history
c4fdf09 added a test that now fails with valgrind
it fails for two resons:
1) the test samples the used memory and then limits the maxmemory to
   that value, but it turns out this is not atomic and on slow machines
   the background cron process that clean out old query buffers reduces
   the memory so that the setting doesn't cause eviction.
2) the dbsize was tested late, after reading some invalidation messages
   by that time more and more keys got evicted, partially draining the
   db. this is not the focus of this fix (still a known limitation)
  • Loading branch information
oranagra committed Dec 8, 2020
1 parent 1acc315 commit a102b21
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tests/unit/maxmemory.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ start_server {tags {"maxmemory"}} {
}
}

# we need to wait one second for the client querybuf excess memory to be
# trimmed by cron, otherwise the INFO used_memory and CONFIG maxmemory
# below (on slow machines) won't be "atomic" and won't trigger eviction.
after 1100

# set the memory limit which will cause a few keys to be evicted
# we need to make sure to evict keynames of a total size of more than
# 16kb since the (PROTO_REPLY_CHUNK_BYTES), only after that the
Expand All @@ -302,13 +307,20 @@ start_server {tags {"maxmemory"}} {
# make sure some eviction happened
set evicted [s evicted_keys]
if {$::verbose} { puts "evicted: $evicted" }

# make sure we didn't drain the database
assert_range [r dbsize] 200 300

assert_range $evicted 10 50
foreach rd $clients {
$rd read ;# make sure we have some invalidation message waiting
$rd close
}

# make sure we didn't drain the database
assert_range [r dbsize] 200 300
# eviction continues (known problem described in #8069)
# for now this test only make sures the eviction loop itself doesn't
# have feedback loop
set evicted [s evicted_keys]
if {$::verbose} { puts "evicted: $evicted" }
}
}

0 comments on commit a102b21

Please sign in to comment.