Alexey Goncharuk created IGNITE-5564: ----------------------------------------
Summary: Race between read-through and topology version update Key: IGNITE-5564 URL: https://issues.apache.org/jira/browse/IGNITE-5564 Project: Ignite Issue Type: Bug Components: cache Affects Versions: 1.7 Reporter: Alexey Goncharuk Assignee: Alexey Goncharuk Fix For: 2.1 I occasionally observe the following assertions when working with ATOMIC cache with cache store on changing topology: {code} java.lang.AssertionError: Invalid version for inner update [isNew=false, entry=GridDhtAtomicCacheEntry [super=GridDhtCacheEntry [rdrs=[], locPart=GridDhtLocalPartition [id=157, map=org.apache.ignite.internal.processors.cache.GridCacheConcurrentMapImpl@7a99d0af, rmvQueue=GridCircularBuffer [sizeMask=31, idxGen=0], cntr=8, shouldBeRenting=false, state=OWNING, reservations=0, empty=false, createTime=06/21/2017 09:59:03], super=GridDistributedCacheEntry [super=GridCacheMapEntry [key=KeyCacheObjectImpl [val=1181, hasValBytes=true], val=CacheObjectImpl [val=1181, hasValBytes=true], startVer=1498028394357, ver=GridCacheVersion [topVer=109508344, time=1498028344708, order=1498028394358, nodeOrder=1], hash=1181, extras=GridCacheTtlEntryExtras [ttl=60000, expireTime=1498028404707], flags=0]]]], newVer=GridCacheVersion [topVer=109508343, time=1498028344709, order=1498028394369, nodeOrder=1]] at org.apache.ignite.internal.processors.cache.GridCacheMapEntry.innerUpdate(GridCacheMapEntry.java:2311) at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateSingle(GridDhtAtomicCache.java:2485) at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal0(GridDhtAtomicCache.java:1887) at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal(GridDhtAtomicCache.java:1727) at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateFuture.mapSingle(GridNearAtomicAbstractUpdateFuture.java:264) at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicSingleUpdateFuture.map(GridNearAtomicSingleUpdateFuture.java:494) at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicSingleUpdateFuture.mapOnTopology(GridNearAtomicSingleUpdateFuture.java:436) at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateFuture.map(GridNearAtomicAbstractUpdateFuture.java:209) at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.update0(GridDhtAtomicCache.java:1242) at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.put0(GridDhtAtomicCache.java:675) at org.apache.ignite.internal.processors.cache.GridCacheAdapter.put(GridCacheAdapter.java:2294) at org.apache.ignite.internal.processors.cache.distributed.near.GridNearAtomicCache.put(GridNearAtomicCache.java:437) at org.apache.ignite.internal.processors.cache.GridCacheAdapter.put(GridCacheAdapter.java:2271) at org.apache.ignite.internal.processors.cache.IgniteCacheProxy.put(IgniteCacheProxy.java:1379) {code} The assertion happens because there is a race between these events: 1) An update is mapped on topology version N 2) Topology version changes and discovery updates the version to N+1, but the event is not yet processed by the exchange future 3) A read-through request comes in and performs the read. Inside {{versionedValue()}} call a new entry version is generated. Since the discovery version is already updated, the new entry version is based on topVer=N+1 4) Update request proceeds and read-locks the topology. Since the exchange future is not yet initialized, the request does not attempt to remap and proceeds with version N 5) The next entry version is generated using request topology version = N 6) Inside the entry update method, we assert that new version is greater than old version, but it's not the case in this scenario, and assertion fails Attached is a test reproducing the issue (see testConcurrentReadThroughUpdate()) -- This message was sent by Atlassian JIRA (v6.4.14#64029)