[infinispan-issues] [JBoss JIRA] (ISPN-3163) Replacing entry via HotRod which was initially stored via Memcached does not change CAS

Martin Gencur (JIRA) jira-events at lists.jboss.org
Fri May 31 07:12:55 EDT 2013


     [ https://issues.jboss.org/browse/ISPN-3163?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Gencur updated ISPN-3163:
--------------------------------

    Description: 
Users might expect that CAS (check-and-set) operation will work even in compatibility mode which is currently not true in the following scenario:
1) store a key/value via Memcached
2) change the value via HotRod or Embedded 
3) use Memcached's CAS operation

In step #3 the memcached client will update the value even though the value was changed by another client in the meantime. The memcached client was supposed to change it only if it had not been changed in the meantime.

The following test snippet shows the problem:
{code:java}
public void testMemcachedPutHotRodEmbbeddedReplaceMemcachedCASTest() throws Exception {
      final String key1 = "5";

      // 1. Put with Memcached
      Future<Boolean> f = cacheFactory.getMemcachedClient().set(key1, 0, "v1");
      assertTrue(f.get(60, TimeUnit.SECONDS));
      CASValue oldValue = cacheFactory.getMemcachedClient().gets(key1);

      // 2. Replace with Hot Rod
      VersionedValue versioned = cacheFactory.getHotRodCache().getVersioned(key1);
      assertTrue(cacheFactory.getHotRodCache().replaceWithVersion(key1, "v2", versioned.getVersion()));

      // 3. Replace with Embedded
      assertTrue(cacheFactory.getEmbeddedCache().replace(key1, "v2", "v3"));

      // 4. Get with Memcached and verify value/CAS
      CASValue newValue = cacheFactory.getMemcachedClient().gets(key1);
      assertEquals("v3", newValue.getValue());
      assertTrue("The version (CAS) should have changed", oldValue.getCas() != newValue.getCas()); 
//<---- fails here
   }
{code}

  was:
Users might expect that CAS (check-and-set) operation will work even in compatibility mode which is currently not true in the following scenario:
1) store a key/value via Memcached
2) change the value via HotRod or Embedded 
3) use Memcached's CAS operation

In step #3 the memcached client will update the value even though the value was changed by another client in the meantime. The memcached client was supposed to change it only if it had not been changed in the meantime.

The following test snippet shows the problem:
{code:java}
public void testMemcachedPutHotRodEmbbeddedReplaceMemcachedCASTest() throws Exception {
      final String key1 = "5";

      // 1. Put with Memcached
      Future<Boolean> f = cacheFactory.getMemcachedClient().set(key1, 0, "v1");
      assertTrue(f.get(60, TimeUnit.SECONDS));
      CASValue oldValue = cacheFactory.getMemcachedClient().gets(key1);

      // 2. Replace with Hot Rod
      VersionedValue versioned = cacheFactory.getHotRodCache().getVersioned(key1);
      assertTrue(cacheFactory.getHotRodCache().replaceWithVersion(key1, "v2", versioned.getVersion()));

      // 3. Replace with Embedded
      assertTrue(cacheFactory.getEmbeddedCache().replace(key1, "v2", "v3"));

      // 4. Get with Memcached and verify value/CAS
      CASValue newValue = cacheFactory.getMemcachedClient().gets(key1);
      assertEquals("v3", newValue.getValue());
      assertTrue("The version (CAS) should have changed", oldValue.getCas() != newValue.getCas()); //<---- fails here
   }
{code}


    
> Replacing entry via HotRod which was initially stored via Memcached does not change CAS
> ---------------------------------------------------------------------------------------
>
>                 Key: ISPN-3163
>                 URL: https://issues.jboss.org/browse/ISPN-3163
>             Project: Infinispan
>          Issue Type: Bug
>    Affects Versions: 5.3.0.CR1
>            Reporter: Martin Gencur
>            Assignee: Galder ZamarreƱo
>             Fix For: 5.3.0.Final
>
>
> Users might expect that CAS (check-and-set) operation will work even in compatibility mode which is currently not true in the following scenario:
> 1) store a key/value via Memcached
> 2) change the value via HotRod or Embedded 
> 3) use Memcached's CAS operation
> In step #3 the memcached client will update the value even though the value was changed by another client in the meantime. The memcached client was supposed to change it only if it had not been changed in the meantime.
> The following test snippet shows the problem:
> {code:java}
> public void testMemcachedPutHotRodEmbbeddedReplaceMemcachedCASTest() throws Exception {
>       final String key1 = "5";
>       // 1. Put with Memcached
>       Future<Boolean> f = cacheFactory.getMemcachedClient().set(key1, 0, "v1");
>       assertTrue(f.get(60, TimeUnit.SECONDS));
>       CASValue oldValue = cacheFactory.getMemcachedClient().gets(key1);
>       // 2. Replace with Hot Rod
>       VersionedValue versioned = cacheFactory.getHotRodCache().getVersioned(key1);
>       assertTrue(cacheFactory.getHotRodCache().replaceWithVersion(key1, "v2", versioned.getVersion()));
>       // 3. Replace with Embedded
>       assertTrue(cacheFactory.getEmbeddedCache().replace(key1, "v2", "v3"));
>       // 4. Get with Memcached and verify value/CAS
>       CASValue newValue = cacheFactory.getMemcachedClient().gets(key1);
>       assertEquals("v3", newValue.getValue());
>       assertTrue("The version (CAS) should have changed", oldValue.getCas() != newValue.getCas()); 
> //<---- fails here
>    }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the infinispan-issues mailing list