Ignite 2.10.0 cache.repalce(K,V,V) return false after upgrade from 2.7

Viewed 95

After upgrade from ignite version 2.7 to 2.10.0 the operation cache.repalce(K,V,V) return false. but with version 2.7 it was working fine.

No exception is thrown just the operation return false. the class is annotated with @EqualsAndHashCode(onlyExplicitlyIncluded = true) the test was done with no code change just the upgrade.

Thank you for your help. I have been trying to solve this problem for a while but with no luck

@NoArgsConstructor
@EqualsAndHashCode(callSuper=true, onlyExplicitlyIncluded = true)
public class Emplyoee extends BaseClass implements Serialisable {
    public static void main(String args[]) {
      
      @QuerySqlField
      private name
    }
}

@NoArgsConstructor
@EqualsAndHashCode(of="id")
public class BaseClass implements Serialisable {
    public static void main(String args[]) {
      
      @QuerySqlField
      private id
    }
}


updateEmpolyee(IgniteCache <Long, T> cache, T oldValue, T newValue, Long key, int maxRetry) {
T cacheValue = cache.get(key);
boolean result = cache.replace(key, cacheValue, newValue);
if (!result && maxRetry 0)
 result = updateEmpolyee(cache, newValue, key, maxRetry )
return result;
}

1 Answers

I can see a couple of improvements in #replace(k,v,nv) method, like IGNITE-11734 and IGNITE-7072.

The most interesting changes are in #11734 that introduced the following lines:

    // here val is stored value, this.val = new value

    if (this.val == null && val == null)
        return true;

    if (this.val == null || val == null)
        return false;

I.e. if there were no value for a given key (no record exists) and you are trying to make a value replacement, you will always get false starting from 2.8. Though it looks like this is how it worked in 2.7 as well...

Here you might check a complete source code of CacheEntryPredicateContainsValue#apply method.

Related