ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [05/24] ignite git commit: Fixed page acquire during checkpoint
Date Mon, 17 Jul 2017 08:24:09 GMT
Fixed page acquire during checkpoint


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

Branch: refs/heads/ignite-5578
Commit: c6ee085b8a1321ce7fa15f8adf74fa7a01f7a445
Parents: 8afdc7b
Author: Dmitriy Govorukhin <dmitriy.govorukhin@gmail.com>
Authored: Wed Jul 12 14:22:03 2017 +0300
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Wed Jul 12 14:22:03 2017 +0300

----------------------------------------------------------------------
 .../persistence/pagemem/PageMemoryImpl.java     | 30 ++++++++++++++++----
 1 file changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c6ee085b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java
index e4428a2..47381d7 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java
@@ -803,9 +803,14 @@ public class PageMemoryImpl implements PageMemoryEx {
 
         int tag;
 
+        boolean tmpBuffer = false;
+
         seg.readLock().lock();
 
         try {
+            if (!isInCheckpoint(fullId))
+                return null;
+
             tag = seg.partTag(fullId.groupId(), PageIdUtils.partId(fullId.pageId()));
 
             relPtr = seg.loadedPages.get(
@@ -826,6 +831,8 @@ public class PageMemoryImpl implements PageMemoryEx {
                 // Pin the page until page will not be copied.
                 if (PageHeader.tempBufferPointer(absPtr) == INVALID_REL_PTR)
                     PageHeader.acquirePage(absPtr);
+                else
+                    tmpBuffer = true;
             }
         }
         finally {
@@ -869,7 +876,7 @@ public class PageMemoryImpl implements PageMemoryEx {
             }
         }
         else
-            return copyPageForCheckpoint(absPtr, fullId, tmpBuf, tracker) ? tag : null;
+            return copyPageForCheckpoint(absPtr, fullId, tmpBuf, tmpBuffer, tracker) ? tag
: null;
     }
 
     /**
@@ -877,19 +884,24 @@ public class PageMemoryImpl implements PageMemoryEx {
      * @param fullId Full id.
      * @param tmpBuf Tmp buffer.
      */
-    private boolean copyPageForCheckpoint(long absPtr, FullPageId fullId, ByteBuffer tmpBuf,
CheckpointMetricsTracker tracker) {
+    private boolean copyPageForCheckpoint(
+        long absPtr,
+        FullPageId fullId,
+        ByteBuffer tmpBuf,
+        boolean tmpBuffer,
+        CheckpointMetricsTracker tracker
+    ) {
         assert absPtr != 0;
+        assert PageHeader.isAcquired(absPtr);
 
         rwLock.writeLock(absPtr + PAGE_LOCK_OFFSET, OffheapReadWriteLock.TAG_LOCK_ALWAYS);
 
         try {
             long tmpRelPtr = PageHeader.tempBufferPointer(absPtr);
 
-            if (!clearCheckpoint(fullId)){
-                assert tmpRelPtr == INVALID_REL_PTR;
+            boolean success = clearCheckpoint(fullId);
 
-                return false;
-            }
+            assert success : "Page was pin when we resolve abs pointer, it can not be evicted";
 
             if (tmpRelPtr != INVALID_REL_PTR){
                 PageHeader.tempBufferPointer(absPtr, INVALID_REL_PTR);
@@ -907,6 +919,12 @@ public class PageMemoryImpl implements PageMemoryEx {
 
                 // We pinned the page when allocated the temp buffer, release it now.
                 PageHeader.releasePage(absPtr);
+
+                // Need release again because we pin page when resolve abs pointer,
+                // and page did not have tmp buffer page.
+                if (!tmpBuffer)
+                    PageHeader.releasePage(absPtr);
+
             }
             else {
                 copyInBuffer(absPtr, tmpBuf);


Mime
View raw message