You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2017/09/08 12:35:54 UTC

[22/36] ignite git commit: ignite-3484

ignite-3484


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6be6779b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6be6779b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6be6779b

Branch: refs/heads/ignite-6149
Commit: 6be6779b6336c36cd71eef0a25199a6a877ce6b5
Parents: d1b8280
Author: sboikov <sb...@gridgain.com>
Authored: Tue Sep 5 16:47:11 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Sep 5 17:46:35 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheAdapter.java      |   2 +-
 .../processors/cache/GridCacheMapEntry.java     |  10 +-
 .../cache/IgniteCacheOffheapManager.java        |  33 ++++-
 .../cache/IgniteCacheOffheapManagerImpl.java    | 119 +++++++++++++++++--
 .../dht/GridPartitionedGetFuture.java           |   4 +-
 .../dht/GridPartitionedSingleGetFuture.java     |   2 +-
 .../dht/atomic/GridDhtAtomicCache.java          |   2 +-
 .../dht/colocated/GridDhtColocatedCache.java    |   8 +-
 .../local/atomic/GridLocalAtomicCache.java      |   2 +-
 .../cache/persistence/CacheDataRow.java         |   4 +-
 .../cache/persistence/CacheDataRowAdapter.java  |   4 +-
 .../cache/persistence/CacheSearchRow.java       |   4 +-
 .../persistence/GridCacheOffheapManager.java    |  23 ++++
 .../processors/cache/tree/CacheDataTree.java    |   9 +-
 .../processors/cache/tree/MvccDataRow.java      |  63 ++++++++++
 .../processors/cache/tree/MvccSearchRow.java    |  48 ++++++++
 .../processors/cache/tree/SearchRow.java        |   7 +-
 17 files changed, 306 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6be6779b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 9e255e5..83b085a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -1902,7 +1902,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
                             boolean skipEntry = readNoEntry;
 
                             if (readNoEntry) {
-                                CacheDataRow row = ctx.offheap().read(ctx, key, mvccCrdCntr);
+                                CacheDataRow row = ctx.offheap().read(ctx, key);
 
                                 if (row != null) {
                                     long expireTime = row.expireTime();

http://git-wip-us.apache.org/repos/asf/ignite/blob/6be6779b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index dae874c..3e39b6b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -583,7 +583,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
             CacheObject val;
 
             if (mvccCntr != TxMvccVersion.COUNTER_NA) {
-                CacheDataRow row = cctx.offheap().read(cctx, key, mvccCntr);
+                CacheDataRow row = cctx.offheap().readMvcc(cctx, key, 0, mvccCntr); // TODO IGNITE-3484.
 
                 if (row != null) {
                     val = row.value();
@@ -1006,7 +1006,13 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
 
             assert val != null;
 
-            storeValue(val, expireTime, newVer, null);
+            if (cctx.mvccEnabled()) {
+                assert mvccCntr != TxMvccVersion.COUNTER_NA;
+
+                cctx.offheap().mvccUpdate(this, val, newVer, topVer.topologyVersion(), mvccCntr);
+            }
+            else
+                storeValue(val, expireTime, newVer, null);
 
             if (cctx.deferredDelete() && deletedUnlocked() && !isInternal() && !detached())
                 deletedUnlocked(false);

http://git-wip-us.apache.org/repos/asf/ignite/blob/6be6779b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
index 22b4832..cbf5455 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
@@ -106,7 +106,16 @@ public interface IgniteCacheOffheapManager {
      * @return Cached row, if available, null otherwise.
      * @throws IgniteCheckedException If failed.
      */
-    @Nullable public CacheDataRow read(GridCacheContext cctx, KeyCacheObject key, long mvccCntr) throws IgniteCheckedException;
+    @Nullable public CacheDataRow read(GridCacheContext cctx, KeyCacheObject key) throws IgniteCheckedException;
+
+    /**
+     * @param cctx Cache context.
+     * @param key Key.
+     * @return Cached row, if available, null otherwise.
+     * @throws IgniteCheckedException If failed.
+     */
+    @Nullable public CacheDataRow readMvcc(GridCacheContext cctx, KeyCacheObject key, long topVer, long mvccCntr)
+        throws IgniteCheckedException;
 
     /**
      * @param p Partition.
@@ -163,6 +172,12 @@ public interface IgniteCacheOffheapManager {
     public void invoke(GridCacheContext cctx, KeyCacheObject key, GridDhtLocalPartition part, OffheapInvokeClosure c)
         throws IgniteCheckedException;
 
+    public void mvccUpdate(GridCacheMapEntry entry,
+        CacheObject val,
+        GridCacheVersion ver,
+        long topVer,
+        long mvccCntr) throws IgniteCheckedException;
+
     /**
      * @param cctx Cache context.
      * @param key  Key.
@@ -451,6 +466,14 @@ public interface IgniteCacheOffheapManager {
             long expireTime,
             @Nullable CacheDataRow oldRow) throws IgniteCheckedException;
 
+        void mvccUpdate(
+            GridCacheContext cctx,
+            KeyCacheObject key,
+            CacheObject val,
+            GridCacheVersion ver,
+            long topVer,
+            long mvccCntr) throws IgniteCheckedException;
+
         /**
          * @param cctx Cache context.
          * @param key Key.
@@ -483,6 +506,14 @@ public interface IgniteCacheOffheapManager {
         public CacheDataRow find(GridCacheContext cctx, KeyCacheObject key) throws IgniteCheckedException;
 
         /**
+         * @param cctx Cache context.
+         * @param key Key.
+         * @return Data row.
+         * @throws IgniteCheckedException If failed.
+         */
+        public CacheDataRow findMvcc(GridCacheContext cctx, KeyCacheObject key, long topVer, long mvccCntr) throws IgniteCheckedException;
+
+        /**
          * @return Data cursor.
          * @throws IgniteCheckedException If failed.
          */

http://git-wip-us.apache.org/repos/asf/ignite/blob/6be6779b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
index 39eec0b..19a940d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
@@ -48,6 +48,8 @@ import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager;
 import org.apache.ignite.internal.processors.cache.tree.CacheDataRowStore;
 import org.apache.ignite.internal.processors.cache.tree.CacheDataTree;
 import org.apache.ignite.internal.processors.cache.tree.DataRow;
+import org.apache.ignite.internal.processors.cache.tree.MvccDataRow;
+import org.apache.ignite.internal.processors.cache.tree.MvccSearchRow;
 import org.apache.ignite.internal.processors.cache.tree.PendingEntriesTree;
 import org.apache.ignite.internal.processors.cache.tree.PendingRow;
 import org.apache.ignite.internal.processors.cache.tree.SearchRow;
@@ -359,6 +361,20 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
     }
 
     /** {@inheritDoc} */
+    @Override public void mvccUpdate(GridCacheMapEntry entry,
+        CacheObject val,
+        GridCacheVersion ver,
+        long topVer,
+        long mvccCntr) throws IgniteCheckedException {
+        dataStore(entry.localPartition()).mvccUpdate(entry.context(),
+            entry.key(),
+            val,
+            ver,
+            topVer,
+            mvccCntr);
+    }
+
+    /** {@inheritDoc} */
     @Override public void updateIndexes(GridCacheContext cctx, KeyCacheObject key, GridDhtLocalPartition part)
         throws IgniteCheckedException {
         dataStore(part).updateIndexes(cctx, key);
@@ -386,23 +402,43 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public CacheDataRow read(GridCacheContext cctx, KeyCacheObject key, long mvccCntr)
+    @Nullable @Override public CacheDataRow read(GridCacheContext cctx, KeyCacheObject key)
         throws IgniteCheckedException {
-        CacheDataRow row;
+        CacheDataStore dataStore = dataStore(cctx, key);
 
-        if (cctx.isLocal())
-            row = locCacheDataStore.find(cctx, key);
-        else {
-            GridDhtLocalPartition part = cctx.topology().localPartition(cctx.affinity().partition(key), null, false);
+        CacheDataRow row = dataStore != null ? dataStore.find(cctx, key) : null;
 
-            row = part != null ? dataStore(part).find(cctx, key) : null;
-        }
+        assert row == null || row.value() != null : row;
+
+        return row;
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public CacheDataRow readMvcc(GridCacheContext cctx, KeyCacheObject key, long topVer, long mvccCntr)
+        throws IgniteCheckedException {
+        CacheDataStore dataStore = dataStore(cctx, key);
+
+        CacheDataRow row = dataStore != null ? dataStore.findMvcc(cctx, key, topVer, mvccCntr) : null;
 
         assert row == null || row.value() != null : row;
 
         return row;
     }
 
+    /**
+     * @param cctx Cache context.
+     * @param key Key.
+     * @return Data store.
+     */
+    @Nullable private CacheDataStore dataStore(GridCacheContext cctx, KeyCacheObject key) {
+        if (grp.isLocal())
+            return locCacheDataStore;
+
+        GridDhtLocalPartition part = grp.topology().localPartition(cctx.affinity().partition(key), null, false);
+
+        return part != null ? dataStore(part) : null;
+    }
+
     /** {@inheritDoc} */
     @Override public boolean containsKey(GridCacheMapEntry entry) {
         try {
@@ -1265,8 +1301,43 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
         }
 
         /** {@inheritDoc} */
-        @Override public void update(GridCacheContext cctx,KeyCacheObject key,
+        @Override public void mvccUpdate(GridCacheContext cctx,
+            KeyCacheObject key,
+            CacheObject val,
+            GridCacheVersion ver,
+            long topVer,
+            long mvccCntr) throws IgniteCheckedException {
+            if (!busyLock.enterBusy())
+                throw new NodeStoppingException("Operation has been cancelled (node is stopping).");
+
+            try {
+                int cacheId = grp.storeCacheIdInDataPage() ? cctx.cacheId() : CU.UNDEFINED_CACHE_ID;
+
+                MvccDataRow dataRow = new MvccDataRow(key, val, ver, partId, cacheId, topVer, mvccCntr);
 
+                CacheObjectContext coCtx = cctx.cacheObjectContext();
+
+                // Make sure value bytes initialized.
+                key.valueBytes(coCtx);
+                val.valueBytes(coCtx);
+
+                rowStore.addRow(dataRow);
+
+                assert dataRow.link() != 0 : dataRow;
+
+                if (grp.sharedGroup() && dataRow.cacheId() == CU.UNDEFINED_CACHE_ID)
+                    dataRow.cacheId(cctx.cacheId());
+
+                dataTree.putx(dataRow);
+            }
+            finally {
+                busyLock.leaveBusy();
+            }
+        }
+
+        /** {@inheritDoc} */
+        @Override public void update(GridCacheContext cctx,
+            KeyCacheObject key,
             CacheObject val,
             GridCacheVersion ver,
             long expireTime,
@@ -1467,13 +1538,39 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
 
             CacheDataRow row = dataTree.findOne(new SearchRow(cacheId, key), CacheDataRowAdapter.RowData.NO_KEY);
 
+            afterRowFound(row, key);
+
+            return row;
+        }
+
+        /** {@inheritDoc} */
+        @Override public CacheDataRow findMvcc(GridCacheContext cctx,
+            KeyCacheObject key,
+            long topVer,
+            long mvccCntr) throws IgniteCheckedException {
+            key.valueBytes(cctx.cacheObjectContext());
+
+            int cacheId = grp.sharedGroup() ? cctx.cacheId() : CU.UNDEFINED_CACHE_ID;
+
+            CacheDataRow row = dataTree.findOne(new MvccSearchRow(cacheId, key, topVer, mvccCntr),
+                CacheDataRowAdapter.RowData.NO_KEY);
+
+            afterRowFound(row, key);
+
+            return row;
+        }
+
+        /**
+         * @param row Row.
+         * @param key Key.
+         * @throws IgniteCheckedException If failed.
+         */
+        private void afterRowFound(@Nullable CacheDataRow row, KeyCacheObject key) throws IgniteCheckedException {
             if (row != null) {
                 row.key(key);
 
                 grp.memoryPolicy().evictionTracker().touchPage(row.link());
             }
-
-            return row;
         }
 
         /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/6be6779b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
index 066a706..8359043 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
@@ -507,7 +507,9 @@ public class GridPartitionedGetFuture<K, V> extends CacheDistributedGetFutureAda
                 GridCacheVersion ver = null;
 
                 if (readNoEntry) {
-                    CacheDataRow row = cctx.offheap().read(cctx, key, mvccCntr);
+                    CacheDataRow row = cctx.mvccEnabled() ?
+                        cctx.offheap().readMvcc(cctx, key, topVer.topologyVersion(), mvccCntr) :
+                        cctx.offheap().read(cctx, key);
 
                     if (row != null) {
                         long expireTime = row.expireTime();

http://git-wip-us.apache.org/repos/asf/ignite/blob/6be6779b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
index 9da6db5..950295e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
@@ -357,7 +357,7 @@ public class GridPartitionedSingleGetFuture extends GridCacheFutureAdapter<Objec
                 boolean skipEntry = readNoEntry;
 
                 if (readNoEntry) {
-                    CacheDataRow row = cctx.offheap().read(cctx, key, TxMvccVersion.COUNTER_NA); // TODO IGNITE-3478
+                    CacheDataRow row = cctx.offheap().read(cctx, key); // TODO IGNITE-3478
 
                     if (row != null) {
                         long expireTime = row.expireTime();

http://git-wip-us.apache.org/repos/asf/ignite/blob/6be6779b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index ef1661c..5de6d19 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -1495,7 +1495,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                 // Optimistically expect that all keys are available locally (avoid creation of get future).
                 for (KeyCacheObject key : keys) {
                     if (readNoEntry) {
-                        CacheDataRow row = ctx.offheap().read(ctx, key, TxMvccVersion.COUNTER_NA);
+                        CacheDataRow row = ctx.offheap().read(ctx, key);
 
                         if (row != null) {
                             long expireTime = row.expireTime();

http://git-wip-us.apache.org/repos/asf/ignite/blob/6be6779b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
index c54d91e..5e87a05 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
@@ -443,7 +443,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
             expiryPlc = expiryPolicy(null);
 
         // Optimisation: try to resolve value locally and escape 'get future' creation.
-        if (!forcePrimary && ctx.affinityNode()) {
+        if (!forcePrimary && ctx.affinityNode() && !ctx.mvccEnabled()) {
             try {
                 Map<K, V> locVals = null;
 
@@ -453,7 +453,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
 
                 for (KeyCacheObject key : keys) {
                     if (readNoEntry) {
-                        CacheDataRow row = ctx.offheap().read(ctx, key, TxMvccVersion.COUNTER_NA); // TODO IGNITE-3478
+                        CacheDataRow row = ctx.offheap().read(ctx, key);
 
                         if (row != null) {
                             long expireTime = row.expireTime();
@@ -517,7 +517,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
                                             expiryPlc,
                                             !deserializeBinary,
                                             TxMvccVersion.COUNTER_NA,
-                                            null); // TODO IGNITE-3478
+                                            null);
 
                                         if (getRes != null) {
                                             v = getRes.value();
@@ -536,7 +536,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
                                             taskName,
                                             expiryPlc,
                                             !deserializeBinary,
-                                            TxMvccVersion.COUNTER_NA); // TODO IGNITE-3478
+                                            TxMvccVersion.COUNTER_NA);
                                     }
 
                                     // Entry was not in memory or in swap, so we remove it from cache.

http://git-wip-us.apache.org/repos/asf/ignite/blob/6be6779b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
index ccedbcd..f53087d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
@@ -404,7 +404,7 @@ public class GridLocalAtomicCache<K, V> extends GridLocalCache<K, V> {
             boolean skipEntry = readNoEntry;
 
             if (readNoEntry) {
-                CacheDataRow row = ctx.offheap().read(ctx, cacheKey, TxMvccVersion.COUNTER_NA);
+                CacheDataRow row = ctx.offheap().read(ctx, cacheKey);
 
                 if (row != null) {
                     long expireTime = row.expireTime();

http://git-wip-us.apache.org/repos/asf/ignite/blob/6be6779b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRow.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRow.java
index b17baa2..5316eef 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRow.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRow.java
@@ -55,7 +55,7 @@ public interface CacheDataRow extends CacheSearchRow {
      */
     public void key(KeyCacheObject key);
 
-    public long mvccUpdateCounter();
-
     public long mvccUpdateTopologyVersion();
+
+    public long mvccUpdateCounter();
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/6be6779b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java
index bb824dd..11da76d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java
@@ -573,12 +573,12 @@ public class CacheDataRowAdapter implements CacheDataRow {
     }
 
     /** {@inheritDoc} */
-    @Override public long mvccUpdateCounter() {
+    @Override public long mvccUpdateTopologyVersion() {
         return 0;
     }
 
     /** {@inheritDoc} */
-    @Override public long mvccUpdateTopologyVersion() {
+    @Override public long mvccUpdateCounter() {
         return 0;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/6be6779b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheSearchRow.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheSearchRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheSearchRow.java
index 48ff90a..7834a03 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheSearchRow.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheSearchRow.java
@@ -43,7 +43,7 @@ public interface CacheSearchRow {
      */
     public int cacheId();
 
-    public long mvccUpdateCounter();
-
     public long mvccUpdateTopologyVersion();
+
+    public long mvccUpdateCounter();
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/6be6779b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
index 3c9b1ca..9ba2f39 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
@@ -1246,6 +1246,18 @@ public class GridCacheOffheapManager extends IgniteCacheOffheapManagerImpl imple
         }
 
         /** {@inheritDoc} */
+        @Override public void mvccUpdate(GridCacheContext cctx,
+            KeyCacheObject key,
+            CacheObject val,
+            GridCacheVersion ver,
+            long topVer,
+            long mvccCntr) throws IgniteCheckedException {
+            CacheDataStore delegate = init0(false);
+
+            delegate.mvccUpdate(cctx, key, val, ver, topVer, mvccCntr);
+        }
+
+        /** {@inheritDoc} */
         @Override public void updateIndexes(GridCacheContext cctx, KeyCacheObject key) throws IgniteCheckedException {
             CacheDataStore delegate = init0(false);
 
@@ -1292,6 +1304,17 @@ public class GridCacheOffheapManager extends IgniteCacheOffheapManagerImpl imple
         }
 
         /** {@inheritDoc} */
+        @Override public CacheDataRow findMvcc(GridCacheContext cctx, KeyCacheObject key, long topVer, long mvccCntr)
+            throws IgniteCheckedException {
+            CacheDataStore delegate = init0(true);
+
+            if (delegate != null)
+                return delegate.findMvcc(cctx, key, topVer, mvccCntr);
+
+            return null;
+        }
+
+        /** {@inheritDoc} */
         @Override public GridCursor<? extends CacheDataRow> cursor() throws IgniteCheckedException {
             CacheDataStore delegate = init0(true);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/6be6779b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheDataTree.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheDataTree.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheDataTree.java
index 6ed1c74..b65483e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheDataTree.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheDataTree.java
@@ -145,15 +145,12 @@ public class CacheDataTree extends BPlusTree<CacheSearchRow, CacheDataRow> {
 
         cmp = compareKeys(row.key(), link);
 
-        if (cmp != 0 || !grp.mvccEnabled())
+        if (cmp != 0 || !grp.mvccEnabled() || row.mvccUpdateTopologyVersion() == 0)
             return 0;
 
         long mvccTopVer = io.getMvccUpdateTopologyVersion(pageAddr, idx);
 
-        if (mvccTopVer == 0)
-            return 0;
-
-        cmp = Long.compare(mvccTopVer, row.mvccUpdateTopologyVersion());
+        cmp = Long.compare(row.mvccUpdateTopologyVersion(), mvccTopVer);
 
         if (cmp != 0)
             return 0;
@@ -162,7 +159,7 @@ public class CacheDataTree extends BPlusTree<CacheSearchRow, CacheDataRow> {
 
         assert row.mvccUpdateCounter() != TxMvccVersion.COUNTER_NA;
 
-        cmp = Long.compare(mvccCntr, row.mvccUpdateCounter());
+        cmp = Long.compare(row.mvccUpdateCounter(), mvccCntr);
 
         return cmp;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/6be6779b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccDataRow.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccDataRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccDataRow.java
new file mode 100644
index 0000000..1ab86ca
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccDataRow.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.tree;
+
+import org.apache.ignite.internal.processors.cache.CacheObject;
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+
+/**
+ *
+ */
+public class MvccDataRow extends DataRow {
+    /** */
+    private long mvccCntr;
+
+    /** */
+    private long mvccTopVer;
+
+    /**
+     * @param key
+     * @param val
+     * @param ver
+     * @param part
+     * @param cacheId
+     */
+    public MvccDataRow(KeyCacheObject key,
+        CacheObject val,
+        GridCacheVersion ver,
+        int part,
+        int cacheId,
+        long mvccTopVer,
+        long mvccCntr) {
+        super(key, val, ver, part, 0L, cacheId);
+
+        this.mvccCntr = mvccCntr;
+        this.mvccTopVer = mvccTopVer;
+    }
+
+    /** {@inheritDoc} */
+    @Override public long mvccUpdateTopologyVersion() {
+        return mvccTopVer;
+    }
+
+    /** {@inheritDoc} */
+    @Override public long mvccUpdateCounter() {
+        return mvccCntr;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6be6779b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccSearchRow.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccSearchRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccSearchRow.java
new file mode 100644
index 0000000..da235ab
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccSearchRow.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.tree;
+
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+
+/**
+ *
+ */
+public class MvccSearchRow extends SearchRow {
+    /** */
+    private long mvccTopVer;
+
+    /** */
+    private long mvccCntr;
+
+    public MvccSearchRow(int cacheId, KeyCacheObject key, long mvccTopVer, long mvccCntr) {
+        super(cacheId, key);
+
+        this.mvccTopVer = mvccTopVer;
+        this.mvccCntr = mvccCntr;
+    }
+
+    /** {@inheritDoc} */
+    @Override public long mvccUpdateCounter() {
+        return super.mvccUpdateCounter();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long mvccUpdateTopologyVersion() {
+        return super.mvccUpdateTopologyVersion();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6be6779b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/SearchRow.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/SearchRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/SearchRow.java
index dc48928..d2226ca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/SearchRow.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/SearchRow.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.cache.tree;
 
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import org.apache.ignite.internal.processors.cache.mvcc.TxMvccVersion;
 import org.apache.ignite.internal.processors.cache.persistence.CacheSearchRow;
 
 /**
@@ -75,12 +76,12 @@ public class SearchRow implements CacheSearchRow {
     }
 
     /** {@inheritDoc} */
-    @Override public long mvccUpdateCounter() {
+    @Override public long mvccUpdateTopologyVersion() {
         return 0;
     }
 
     /** {@inheritDoc} */
-    @Override public long mvccUpdateTopologyVersion() {
-        return 0;
+    @Override public long mvccUpdateCounter() {
+        return TxMvccVersion.COUNTER_NA;
     }
 }