tkalkirill commented on code in PR #6354:
URL: https://github.com/apache/ignite-3/pull/6354#discussion_r2247669404


##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/PersistentPageMemory.java:
##########
@@ -1115,25 +1115,64 @@ private long writeLockPage(long absPtr, FullPageId 
fullId, boolean checkTag) {
     private long postWriteLockPage(long absPtr, FullPageId fullId) {
         writeTimestamp(absPtr, coarseCurrentTimeMillis());
 
+        copyPageIfInCheckpoint(absPtr, fullId);
+
+        assert getCrc(absPtr + PAGE_OVERHEAD) == 0; // TODO IGNITE-16612
+
+        return absPtr + PAGE_OVERHEAD;
+    }
+
+    private void copyPageIfInCheckpoint(long absPtr, FullPageId fullId) {
+        Segment seg = segment(fullId);
+
+        if (!seg.isInCheckpoint(fullId) || tempBufferPointer(absPtr) != 
INVALID_REL_PTR) {
+            return;
+        }
+
         // Create a buffer copy if the page is scheduled for a checkpoint.
-        if (isInCheckpoint(fullId) && tempBufferPointer(absPtr) == 
INVALID_REL_PTR) {
-            long tmpRelPtr;
+        long tmpRelPtr;
 
-            PagePool checkpointPool = this.checkpointPool;
+        PagePool checkpointPool = this.checkpointPool;
 
-            while (true) {
-                tmpRelPtr = 
checkpointPool.borrowOrAllocateFreePage(tag(fullId.pageId()));
+        while (true) {
+            int tag = tag(fullId.pageId());
+            tmpRelPtr = checkpointPool.borrowOrAllocateFreePage(tag);
 
-                if (tmpRelPtr != INVALID_REL_PTR) {
-                    break;
-                }
+            if (tmpRelPtr != INVALID_REL_PTR) {
+                break;
+            }
 
-                // TODO https://issues.apache.org/jira/browse/IGNITE-23106 
Replace spin-wait with a proper wait.
-                try {
-                    Thread.sleep(1);
-                } catch (InterruptedException ignore) {
-                    // No-op.
-                }
+            // TODO https://issues.apache.org/jira/browse/IGNITE-23106 Replace 
spin-wait with a proper wait.
+            try {
+                Thread.sleep(1);
+            } catch (InterruptedException ignore) {
+                // No-op.
+            }
+        }
+
+        // The partition could have been deleted in parallel and we could get 
an empty page.
+        seg.writeLock().lock();
+
+        try {
+            // Double check to see if we need to clear the page because it has 
already been partitioned.

Review Comment:
   Fix it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to