arthurnn / memcached

A Ruby interface to the libmemcached C client
Academic Free License v3.0
432 stars 125 forks source link

tests: Fix concurrency test flakiness from unintentional key overlap #191

Closed dylanahsmith closed 3 years ago

dylanahsmith commented 3 years ago

@casperisfine for review

Problem

I noticed another flaky concurrency test failure on CI:

  1) Failure:
ConcurrencyTest#test_threads_with_multi_get [/home/runner/work/memcached/memcached/test/unit/concurrency_test.rb:51]:
--- expected
+++ actual
@@ -1 +1 @@
-["v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1"]
+["v11", "v11", "v11", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v11", "v11", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v11", "v11", "v11", "v11", "v11", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1", "v1"]

which seems to be from the overlap of keys between threads that are supposed to have their own keys, since there is no separation between the thread number and key number on the set line (e.g. thread_cache.set("foo#{n}#{i}", "v#{n}")). So thread 1, key 11 uses the key foo111, which is the same key as for thread 11, key 1.

Solution

Add a separator between the thread number and key number.