bigdata4u / spymemcached

Automatically exported from code.google.com/p/spymemcached
0 stars 0 forks source link

cache data and db data is not consistence when i do below tests #255

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I use memcached to cache the db data. Sometimes, found db and cache data is not 
consistent when I wrote below cases. The issue can occur with 10%.

1, One thread update a db key and remove the key in memcached in a while loop 
(10 count). 

for (int i=0; i<10; i++) {
   Thread.sleep(10ms);
   dbstore.update(key, obj);
   mcclient.delete(key);
}

2, While step 1 runing, I launch 100 threads to get the key using the 
api(set(key, cacheTime, object)) in same JVM.

   Thread.sleep(10ms);
   if (mcclient.get(key) == null) {
      mcclient.set(key, cacheTime, object);
   }

3, when step 2 finished, I check the DB data and Memcached data, found 
sometimes, they are different.

   dbstore.get(key);
   mcclient.get(key);

BTW, mcclient 2.4 to 2.8, all have the issue. anyone can help me? or I did a 
wrong invoking? or there is issue when remove and set concurrently?

Original issue reported on code.google.com by nsqn...@gmail.com on 3 Jul 2012 at 9:23

GoogleCodeExporter commented 8 years ago
Can you provide the entire test file so I can fully understand how the code is 
written?

Original comment by mikewie...@gmail.com on 17 Aug 2012 at 5:38