Bug 745839 (EDG-92) - memcached flush_all command doesn't replicate
Summary: memcached flush_all command doesn't replicate
Keywords:
Status: CLOSED NOTABUG
Alias: EDG-92
Product: JBoss Data Grid 5
Classification: JBoss
Component: Infinispan
Version: EAP 5.1.0 EDG TP
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
: EAP 5.1.0 EDG TP
Assignee: Default User
QA Contact:
URL: http://jira.jboss.org/jira/browse/EDG-92
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-12-03 13:58 UTC by Michal Linhard
Modified: 2014-03-17 04:01 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-12-07 16:17:40 UTC
Type: Bug


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker EDG-92 0 None None None Never

Description Michal Linhard 2010-12-03 13:58:14 UTC
project_key: EDG

infinispan version 4.2.0.CR2

memcached flush_all command clears cache only on node it has been called on, not in whole cluster, even when default cache is configured to dist mode.

this doesn't seem as bug but deliberate decision:
line 237 in
https://github.com/infinispan/infinispan/blob/4.2.0.CR2/server/memcached/src/main/scala/org/infinispan/server/memcached/MemcachedDecoder.scala

testcase is here:
testReplicatedFlushAll()
https://anonsvn.jboss.org/repos/jbossas/branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/MemcachedReplicationTestCase.java

REST server module seems to replicate cache wipes
see testReplicationWipeCache() in
https://anonsvn.jboss.org/repos/jbossas/branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/RESTClientTestCase.java

I don't know how it works in hot rod yet, because hot rod computes target node itself and maybe it gets topology updates so when I work with two distinct clients, I'm not sure they're not sharing the topology information and start sending the requests only to one node based on hash...

so I don't know whether we want this (local only flush_all) or not but IMO it should be consistent across server modules.

Comment 1 Michal Linhard 2010-12-03 14:01:49 UTC
this is the questionable HotRod clear() replication test case scenario, It works but I suspect this is not the way to test it because hotrod hra1 and hra2 send the request to the same node.

    	String[] testHosts = getServers();
        Properties props1 = new Properties();
        Properties props2 = new Properties();
        props1.setProperty("infinispan.client.hotrod.server_list", testHosts[0] +":11222");
        props2.setProperty("infinispan.client.hotrod.server_list", testHosts[1] +":11222");
        RemoteCacheManager hra1 = new RemoteCacheManager(props1);
        RemoteCacheManager hra2 = new RemoteCacheManager(props2);
        Cache c1 = hra1.getCache("aaa");
        Cache c2 = hra2.getCache("aaa");
        c1.put("a", "a");
        c1.put("b", "b");
        c1.put("c", "c");
        assertEquals("a", c2.get("a"));
        assertEquals("b", c2.get("b"));
        assertEquals("c", c2.get("c"));
        c1.clear();
        assertNull(c2.get("a"));
        assertNull(c2.get("b"));
        assertNull(c2.get("c"));

Comment 2 Galder Zamarreño 2010-12-07 13:57:35 UTC
Hot Rod and REST result in cluster wide clears, Memcached should be the same.

Michal, not sure what your problem is with that test that you mention in the last comment. Whether c1 or c2 calls to get/put go to same node depend on diff factors, whether HR servers are replicated or distributed. The clear will get to one of the nodes and clear all the cache everywhere. I agree that you might not be sure where c1.clear() lands. You could just add extra checks for c1.get() to make sure it returns null. 

Comment 3 Galder Zamarreño 2010-12-07 14:06:18 UTC
Link: Added: This issue depends ISPN-821


Comment 4 Michal Linhard 2010-12-07 14:29:00 UTC
The comment is not very important, it just showed how I tried to learn whether hotrod clear() replicates.
I just didn't know whether this test is good enough to prove whether clear() will clear all nodes.
it would prove this only in case c1.get returns null and c2.get returns not null
but in this case c2.returns null

and it might be because c1 and c2 are getting from the same node, not because clear() replicates, 
it's possible that the testcase would pass even if clear() didn't replicate.

Comment 5 Galder Zamarreño 2010-12-07 15:22:06 UTC
The problem with flush_all replicating is that you then can't use the strategy suggested of flush_all plus a delay in order to avoid clearing all memcached servers at the same time:

"The intent of flush_all with a delay, was that in a setting where you
have a pool of memcached servers, and you need to flush all content,
you have the option of not resetting all memcached servers at the
same time (which could e.g. cause a spike in database load with all
clients suddenly needing to recreate content that would otherwise
have been found in the memcached daemon).

The delay option allows you to have them reset in e.g. 10 second
intervals (by passing 0 to the first, 10 to the second, 20 to the
third, etc. etc.)."

I think that's precisely why I made it local and skip cache store. I think I'll leave it as it is.

If anything, I could make flush_all without params be cluster wide, and flush_all with delay be local only. However, I think this might cause more confusion.

Comment 6 Michal Linhard 2010-12-07 15:27:38 UTC
I see, that's a good argument for leaving it as it is. OK then,

anyway seems worth mentioning in the docs...

Comment 7 Galder Zamarreño 2010-12-07 16:03:23 UTC
Good point, I'll add a note to the Memcached wiki explaining how flush_all call is local.

Thanks for the thorough work Michal!

Comment 8 Galder Zamarreño 2010-12-07 16:17:27 UTC
Updated http://community.jboss.org/docs/DOC-14644


Note You need to log in before you can comment on or make changes to this bug.