Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-3163

Replacing entry via HotRod which was initially stored via Memcached does not change CAS

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 5.3.0.CR2, 5.3.0.Final
    • 5.3.0.CR1
    • None
    • None

    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:

      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
         }
      

      Attachments

        Issue Links

          Activity

            People

              rh-ee-galder Galder ZamarreƱo
              mgencur Martin Gencur
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: