You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "ibessonov (via GitHub)" <gi...@apache.org> on 2023/09/15 14:05:34 UTC

[GitHub] [ignite-3] ibessonov opened a new pull request, #2594: IGNITE-20419 Fix partition meta loss after idle cluster restart.

ibessonov opened a new pull request, #2594:
URL: https://github.com/apache/ignite-3/pull/2594

   https://issues.apache.org/jira/browse/IGNITE-20419
   
   Thank you for submitting the pull request.
   
   To streamline the review process of the patch and ensure better code quality
   we ask both an author and a reviewer to verify the following:
   
   ### The Review Checklist
   - [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:  
   \- There is a single JIRA ticket related to the pull request.  
   \- The web-link to the pull request is attached to the JIRA ticket.  
   \- The JIRA ticket has the Patch Available state.  
   \- The description of the JIRA ticket explains WHAT was made, WHY and HOW.  
   \- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
   - [ ] **Design:** new code conforms with the design principles of the components it is added to.
   - [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
   - [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
   - [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
   
   ### Notes
   - [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)


-- 
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-unsubscribe@ignite.apache.org

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


[GitHub] [ignite-3] tkalkirill commented on a diff in pull request #2594: IGNITE-20419 Fix partition meta loss after idle cluster restart.

Posted by "tkalkirill (via GitHub)" <gi...@apache.org>.
tkalkirill commented on code in PR #2594:
URL: https://github.com/apache/ignite-3/pull/2594#discussion_r1328287005


##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/CheckpointWorkflow.java:
##########
@@ -343,14 +365,35 @@ private DataRegionsDirtyPages beginCheckpoint(
             Collection<? extends DataRegion<PersistentPageMemory>> dataRegions,
             CompletableFuture<?> allowToReplace
     ) {
+        Map<DataRegion<?>, Set<FullPageId>> dirtyPartitionsMap = this.dirtyPartitionsMap;
+
+        this.dirtyPartitionsMap = new ConcurrentHashMap<>();

Review Comment:
   Why is `dirtyPartitionsMap` not volatile?
   If this is a fine case, mention the reason in the javaDoc for the field.



##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/PersistentPageMemory.java:
##########
@@ -1230,6 +1230,7 @@ private void setDirty(FullPageId pageId, long absPtr, boolean dirty, boolean for
 
         if (dirty) {
             assert checkpointTimeoutLock.checkpointLockIsHeldByThread();
+            assert pageIndex(pageId.pageId()) != 0;

Review Comment:
   Optional: maybe add text, what's wrong here?



##########
modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/engine/AbstractStorageEngineTest.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.storage.engine;
+
+import static org.apache.ignite.internal.catalog.commands.CatalogUtils.DEFAULT_DATA_REGION;
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assumptions.assumeFalse;
+import static org.mockito.Mockito.mock;
+
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.internal.storage.AbstractMvTableStorageTest;
+import org.apache.ignite.internal.storage.BaseMvStoragesTest;
+import org.apache.ignite.internal.storage.MvPartitionStorage;
+import org.apache.ignite.internal.storage.index.StorageIndexDescriptorSupplier;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests basic functionality of storage engines. Allows for more complex scenarios than {@link AbstractMvTableStorageTest}, because it
+ * doesn't limit the usage of the engine with a single table.
+ */
+public abstract class AbstractStorageEngineTest extends BaseMvStoragesTest {
+    /** Engine instance. */
+    private StorageEngine storageEngine;
+
+    @BeforeEach
+    void createEngineBeforeTest() {
+        storageEngine = createEngine();
+
+        storageEngine.start();
+    }
+
+    @AfterEach
+    void stopEngineAfterTest() {
+        if (storageEngine != null) {
+            storageEngine.stop();
+        }
+    }
+
+    /**
+     * Creates a new storage engine instance. For persistent engines, the instances within a single test method should point to the same
+     * directory.
+     */
+    protected abstract StorageEngine createEngine();
+
+    /**
+     * Tests that explicitly flushed data remains persistent on the device, when the engine is restarted.
+     */
+    @Test
+    void testRestartAfterFlush() throws Exception {
+        assumeFalse(storageEngine.isVolatile());
+
+        StorageTableDescriptor tableDescriptor = new StorageTableDescriptor(1, 1, DEFAULT_DATA_REGION);
+        StorageIndexDescriptorSupplier indexSupplier = mock(StorageIndexDescriptorSupplier.class);
+
+        MvTableStorage mvTableStorage = storageEngine.createMvTable(tableDescriptor, indexSupplier);
+
+        mvTableStorage.start();
+        try (AutoCloseable ignored0 = mvTableStorage::stop) {
+            CompletableFuture<MvPartitionStorage> mvPartitionStorageFuture = mvTableStorage.createMvPartition(0);
+
+            assertThat(mvPartitionStorageFuture, willCompleteSuccessfully());
+            MvPartitionStorage mvPartitionStorage = mvPartitionStorageFuture.join();
+
+            try (AutoCloseable ignored1 = mvTableStorage::stop) {
+                // Flush. Persist the table itself, not the update.
+                CompletableFuture<Void> flushFuture = mvPartitionStorage.flush();
+                assertThat(flushFuture, willCompleteSuccessfully());
+
+                mvPartitionStorage.runConsistently(locker -> {
+                    // Update of basic storage data.
+                    mvPartitionStorage.lastApplied(10, 20);
+
+                    return null;
+                });
+
+                // Flush.
+                flushFuture = mvPartitionStorage.flush();
+                assertThat(flushFuture, willCompleteSuccessfully());

Review Comment:
   ```suggestion
                   assertThat(mvPartitionStorage.flush(), willCompleteSuccessfully());
   ```



##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/CheckpointWorkflow.java:
##########
@@ -343,14 +365,35 @@ private DataRegionsDirtyPages beginCheckpoint(
             Collection<? extends DataRegion<PersistentPageMemory>> dataRegions,
             CompletableFuture<?> allowToReplace
     ) {
+        Map<DataRegion<?>, Set<FullPageId>> dirtyPartitionsMap = this.dirtyPartitionsMap;
+
+        this.dirtyPartitionsMap = new ConcurrentHashMap<>();
+
         Collection<DataRegionDirtyPages<Collection<FullPageId>>> dataRegionsDirtyPages = new ArrayList<>(dataRegions.size());
 
+        // First, we iterate all regions that have dirty pages.
         for (DataRegion<PersistentPageMemory> dataRegion : dataRegions) {
             Collection<FullPageId> dirtyPages = dataRegion.pageMemory().beginCheckpoint(allowToReplace);
 
+            Set<FullPageId> dirtyMetaPageIds = dirtyPartitionsMap.remove(dataRegion);
+
+            if (dirtyMetaPageIds != null) {
+                // Merge these two collections. There should be no intersections.
+                dirtyPages = CollectionUtils.concat(dirtyMetaPageIds, dirtyPages);

Review Comment:
   I remember that you didn’t like `CollectionUtils#concat`, I see that you used it)



##########
modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/engine/AbstractStorageEngineTest.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.storage.engine;
+
+import static org.apache.ignite.internal.catalog.commands.CatalogUtils.DEFAULT_DATA_REGION;
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assumptions.assumeFalse;
+import static org.mockito.Mockito.mock;
+
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.internal.storage.AbstractMvTableStorageTest;
+import org.apache.ignite.internal.storage.BaseMvStoragesTest;
+import org.apache.ignite.internal.storage.MvPartitionStorage;
+import org.apache.ignite.internal.storage.index.StorageIndexDescriptorSupplier;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests basic functionality of storage engines. Allows for more complex scenarios than {@link AbstractMvTableStorageTest}, because it
+ * doesn't limit the usage of the engine with a single table.
+ */
+public abstract class AbstractStorageEngineTest extends BaseMvStoragesTest {
+    /** Engine instance. */
+    private StorageEngine storageEngine;
+
+    @BeforeEach
+    void createEngineBeforeTest() {
+        storageEngine = createEngine();
+
+        storageEngine.start();
+    }
+
+    @AfterEach
+    void stopEngineAfterTest() {
+        if (storageEngine != null) {
+            storageEngine.stop();
+        }
+    }
+
+    /**
+     * Creates a new storage engine instance. For persistent engines, the instances within a single test method should point to the same
+     * directory.
+     */
+    protected abstract StorageEngine createEngine();
+
+    /**
+     * Tests that explicitly flushed data remains persistent on the device, when the engine is restarted.
+     */
+    @Test
+    void testRestartAfterFlush() throws Exception {
+        assumeFalse(storageEngine.isVolatile());
+
+        StorageTableDescriptor tableDescriptor = new StorageTableDescriptor(1, 1, DEFAULT_DATA_REGION);
+        StorageIndexDescriptorSupplier indexSupplier = mock(StorageIndexDescriptorSupplier.class);
+
+        MvTableStorage mvTableStorage = storageEngine.createMvTable(tableDescriptor, indexSupplier);
+
+        mvTableStorage.start();
+        try (AutoCloseable ignored0 = mvTableStorage::stop) {
+            CompletableFuture<MvPartitionStorage> mvPartitionStorageFuture = mvTableStorage.createMvPartition(0);
+
+            assertThat(mvPartitionStorageFuture, willCompleteSuccessfully());
+            MvPartitionStorage mvPartitionStorage = mvPartitionStorageFuture.join();
+
+            try (AutoCloseable ignored1 = mvTableStorage::stop) {
+                // Flush. Persist the table itself, not the update.
+                CompletableFuture<Void> flushFuture = mvPartitionStorage.flush();
+                assertThat(flushFuture, willCompleteSuccessfully());

Review Comment:
   ```suggestion
                   assertThat(mvPartitionStorage.flush(), willCompleteSuccessfully());
   ```



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/mv/PersistentPageMemoryMvPartitionStorage.java:
##########
@@ -212,13 +212,30 @@ public void lastApplied(long lastAppliedIndex, long lastAppliedTerm) throws Stor
     }
 
     private void lastAppliedBusy(long lastAppliedIndex, long lastAppliedTerm) throws StorageException {
+        updateMeta((lastCheckpointId, meta) -> meta.lastApplied(lastCheckpointId, lastAppliedIndex, lastAppliedTerm));
+    }
+
+    /**
+     * Closure interface for {@link #update(UUID, PartitionMeta)}.
+     */
+    @FunctionalInterface
+    private interface MetaUpdateClosure {
+        void update(UUID lastCheckpointId, PartitionMeta meta);
+    }
+
+    /**
+     * Updates partition meta. Hides all the necessary boilderplate in a single place.
+     */

Review Comment:
   ```suggestion
       /** Updates partition meta. Hides all the necessary boilderplate in a single place. */
   ```



##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/CheckpointWorkflow.java:
##########
@@ -161,6 +174,15 @@ public void stop() {
         }
     }
 
+    /**
+     * Marks partition as dirty, forcing partition's meta-page to be written on disk during next checkpoint.
+     */
+    public void markPartitionAsDirty(DataRegion<?> dataRegion, int groupId, int partitionId) {
+        Set<FullPageId> dirtyMetaPageIds = dirtyPartitionsMap.computeIfAbsent(dataRegion, unused -> newKeySet());

Review Comment:
   Optional: It is not necessary to use a local variable.



##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/CheckpointWorkflow.java:
##########
@@ -343,14 +365,35 @@ private DataRegionsDirtyPages beginCheckpoint(
             Collection<? extends DataRegion<PersistentPageMemory>> dataRegions,
             CompletableFuture<?> allowToReplace
     ) {
+        Map<DataRegion<?>, Set<FullPageId>> dirtyPartitionsMap = this.dirtyPartitionsMap;
+
+        this.dirtyPartitionsMap = new ConcurrentHashMap<>();
+
         Collection<DataRegionDirtyPages<Collection<FullPageId>>> dataRegionsDirtyPages = new ArrayList<>(dataRegions.size());
 
+        // First, we iterate all regions that have dirty pages.
         for (DataRegion<PersistentPageMemory> dataRegion : dataRegions) {
             Collection<FullPageId> dirtyPages = dataRegion.pageMemory().beginCheckpoint(allowToReplace);
 
+            Set<FullPageId> dirtyMetaPageIds = dirtyPartitionsMap.remove(dataRegion);
+
+            if (dirtyMetaPageIds != null) {
+                // Merge these two collections. There should be no intersections.
+                dirtyPages = CollectionUtils.concat(dirtyMetaPageIds, dirtyPages);

Review Comment:
   I remember that you didn’t like `CollectionUtils#concat`, I see that you used it)



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/mv/PersistentPageMemoryMvPartitionStorage.java:
##########
@@ -212,13 +212,30 @@ public void lastApplied(long lastAppliedIndex, long lastAppliedTerm) throws Stor
     }
 
     private void lastAppliedBusy(long lastAppliedIndex, long lastAppliedTerm) throws StorageException {
+        updateMeta((lastCheckpointId, meta) -> meta.lastApplied(lastCheckpointId, lastAppliedIndex, lastAppliedTerm));
+    }
+
+    /**
+     * Closure interface for {@link #update(UUID, PartitionMeta)}.
+     */

Review Comment:
   ```suggestion
       /** Closure interface for {@link #update(UUID, PartitionMeta)}. */
   ```



##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/engine/StorageEngine.java:
##########
@@ -43,6 +43,11 @@ public interface StorageEngine {
      */
     void stop() throws StorageException;
 
+    /**
+     * Whether the data is lost upon engine restart or not.
+     */

Review Comment:
   ```suggestion
       /** Whether the data is lost upon engine restart or not. */
   ```



-- 
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-unsubscribe@ignite.apache.org

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


[GitHub] [ignite-3] ibessonov commented on a diff in pull request #2594: IGNITE-20419 Fix partition meta loss after idle cluster restart.

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2594:
URL: https://github.com/apache/ignite-3/pull/2594#discussion_r1328313524


##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/CheckpointWorkflow.java:
##########
@@ -343,14 +365,35 @@ private DataRegionsDirtyPages beginCheckpoint(
             Collection<? extends DataRegion<PersistentPageMemory>> dataRegions,
             CompletableFuture<?> allowToReplace
     ) {
+        Map<DataRegion<?>, Set<FullPageId>> dirtyPartitionsMap = this.dirtyPartitionsMap;
+
+        this.dirtyPartitionsMap = new ConcurrentHashMap<>();

Review Comment:
   Ok, I will explain it in the javadoc



-- 
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-unsubscribe@ignite.apache.org

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


[GitHub] [ignite-3] tkalkirill commented on a diff in pull request #2594: IGNITE-20419 Fix partition meta loss after idle cluster restart.

Posted by "tkalkirill (via GitHub)" <gi...@apache.org>.
tkalkirill commented on code in PR #2594:
URL: https://github.com/apache/ignite-3/pull/2594#discussion_r1328321895


##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/engine/StorageEngine.java:
##########
@@ -43,6 +43,11 @@ public interface StorageEngine {
      */
     void stop() throws StorageException;
 
+    /**
+     * Whether the data is lost upon engine restart or not.
+     */

Review Comment:
   I didn’t know that you could use a one-line JavaDoc for methods and classes, I think it’s more beautiful and reduces the lines of code in the file.



##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/engine/StorageEngine.java:
##########
@@ -43,6 +43,11 @@ public interface StorageEngine {
      */
     void stop() throws StorageException;
 
+    /**
+     * Whether the data is lost upon engine restart or not.
+     */

Review Comment:
   I didn’t know that you could use a one-line JavaDoc for methods and classes, I think it’s more beautiful and reduces the lines of code in the file.



-- 
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-unsubscribe@ignite.apache.org

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


[GitHub] [ignite-3] ibessonov commented on a diff in pull request #2594: IGNITE-20419 Fix partition meta loss after idle cluster restart.

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2594:
URL: https://github.com/apache/ignite-3/pull/2594#discussion_r1328317160


##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/CheckpointWorkflow.java:
##########
@@ -343,14 +365,35 @@ private DataRegionsDirtyPages beginCheckpoint(
             Collection<? extends DataRegion<PersistentPageMemory>> dataRegions,
             CompletableFuture<?> allowToReplace
     ) {
+        Map<DataRegion<?>, Set<FullPageId>> dirtyPartitionsMap = this.dirtyPartitionsMap;
+
+        this.dirtyPartitionsMap = new ConcurrentHashMap<>();
+
         Collection<DataRegionDirtyPages<Collection<FullPageId>>> dataRegionsDirtyPages = new ArrayList<>(dataRegions.size());
 
+        // First, we iterate all regions that have dirty pages.
         for (DataRegion<PersistentPageMemory> dataRegion : dataRegions) {
             Collection<FullPageId> dirtyPages = dataRegion.pageMemory().beginCheckpoint(allowToReplace);
 
+            Set<FullPageId> dirtyMetaPageIds = dirtyPartitionsMap.remove(dataRegion);
+
+            if (dirtyMetaPageIds != null) {
+                // Merge these two collections. There should be no intersections.
+                dirtyPages = CollectionUtils.concat(dirtyMetaPageIds, dirtyPages);

Review Comment:
   Please take the context into account. In this case we must do it to avoid excessive allocations. `dirtyPages` is itself a concatenation.
   Maybe streams would fit better, but the idea is the same



-- 
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-unsubscribe@ignite.apache.org

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


[GitHub] [ignite-3] tkalkirill commented on a diff in pull request #2594: IGNITE-20419 Fix partition meta loss after idle cluster restart.

Posted by "tkalkirill (via GitHub)" <gi...@apache.org>.
tkalkirill commented on code in PR #2594:
URL: https://github.com/apache/ignite-3/pull/2594#discussion_r1328332815


##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/engine/StorageEngine.java:
##########
@@ -43,6 +43,11 @@ public interface StorageEngine {
      */
     void stop() throws StorageException;
 
+    /**
+     * Whether the data is lost upon engine restart or not.
+     */

Review Comment:
   Everyone will have their own opinion.



-- 
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-unsubscribe@ignite.apache.org

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


[GitHub] [ignite-3] tkalkirill commented on a diff in pull request #2594: IGNITE-20419 Fix partition meta loss after idle cluster restart.

Posted by "tkalkirill (via GitHub)" <gi...@apache.org>.
tkalkirill commented on code in PR #2594:
URL: https://github.com/apache/ignite-3/pull/2594#discussion_r1328322778


##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/CheckpointWorkflow.java:
##########
@@ -161,6 +174,15 @@ public void stop() {
         }
     }
 
+    /**
+     * Marks partition as dirty, forcing partition's meta-page to be written on disk during next checkpoint.
+     */
+    public void markPartitionAsDirty(DataRegion<?> dataRegion, int groupId, int partitionId) {
+        Set<FullPageId> dirtyMetaPageIds = dirtyPartitionsMap.computeIfAbsent(dataRegion, unused -> newKeySet());

Review Comment:
   ok



-- 
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-unsubscribe@ignite.apache.org

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


[GitHub] [ignite-3] tkalkirill commented on a diff in pull request #2594: IGNITE-20419 Fix partition meta loss after idle cluster restart.

Posted by "tkalkirill (via GitHub)" <gi...@apache.org>.
tkalkirill commented on code in PR #2594:
URL: https://github.com/apache/ignite-3/pull/2594#discussion_r1328323527


##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/CheckpointWorkflow.java:
##########
@@ -343,14 +365,35 @@ private DataRegionsDirtyPages beginCheckpoint(
             Collection<? extends DataRegion<PersistentPageMemory>> dataRegions,
             CompletableFuture<?> allowToReplace
     ) {
+        Map<DataRegion<?>, Set<FullPageId>> dirtyPartitionsMap = this.dirtyPartitionsMap;
+
+        this.dirtyPartitionsMap = new ConcurrentHashMap<>();
+
         Collection<DataRegionDirtyPages<Collection<FullPageId>>> dataRegionsDirtyPages = new ArrayList<>(dataRegions.size());
 
+        // First, we iterate all regions that have dirty pages.
         for (DataRegion<PersistentPageMemory> dataRegion : dataRegions) {
             Collection<FullPageId> dirtyPages = dataRegion.pageMemory().beginCheckpoint(allowToReplace);
 
+            Set<FullPageId> dirtyMetaPageIds = dirtyPartitionsMap.remove(dataRegion);
+
+            if (dirtyMetaPageIds != null) {
+                // Merge these two collections. There should be no intersections.
+                dirtyPages = CollectionUtils.concat(dirtyMetaPageIds, dirtyPages);

Review Comment:
   Just a funny observation)



-- 
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-unsubscribe@ignite.apache.org

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


[GitHub] [ignite-3] ibessonov commented on a diff in pull request #2594: IGNITE-20419 Fix partition meta loss after idle cluster restart.

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2594:
URL: https://github.com/apache/ignite-3/pull/2594#discussion_r1328327449


##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/engine/StorageEngine.java:
##########
@@ -43,6 +43,11 @@ public interface StorageEngine {
      */
     void stop() throws StorageException;
 
+    /**
+     * Whether the data is lost upon engine restart or not.
+     */

Review Comment:
   Reducing the lines is not the goal. Usually it's quite the opposite, trying to cram everything into a smaller number of lines makes code significantly worse.
   Beauty is subjective. I like when code looks homogeneous, these's a sense of order and structure in that case. When every method looks different, it just feels wrong to me. That's my part of the motivation.



-- 
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-unsubscribe@ignite.apache.org

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


[GitHub] [ignite-3] ibessonov commented on a diff in pull request #2594: IGNITE-20419 Fix partition meta loss after idle cluster restart.

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2594:
URL: https://github.com/apache/ignite-3/pull/2594#discussion_r1328318121


##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/engine/StorageEngine.java:
##########
@@ -43,6 +43,11 @@ public interface StorageEngine {
      */
     void stop() throws StorageException;
 
+    /**
+     * Whether the data is lost upon engine restart or not.
+     */

Review Comment:
   Every other method in this interface has multi-lined javadoc. What's your motivation here?



-- 
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-unsubscribe@ignite.apache.org

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


[GitHub] [ignite-3] ibessonov merged pull request #2594: IGNITE-20419 Fix partition meta loss after idle cluster restart.

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov merged PR #2594:
URL: https://github.com/apache/ignite-3/pull/2594


-- 
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-unsubscribe@ignite.apache.org

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


[GitHub] [ignite-3] ibessonov commented on a diff in pull request #2594: IGNITE-20419 Fix partition meta loss after idle cluster restart.

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2594:
URL: https://github.com/apache/ignite-3/pull/2594#discussion_r1328313149


##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/CheckpointWorkflow.java:
##########
@@ -161,6 +174,15 @@ public void stop() {
         }
     }
 
+    /**
+     * Marks partition as dirty, forcing partition's meta-page to be written on disk during next checkpoint.
+     */
+    public void markPartitionAsDirty(DataRegion<?> dataRegion, int groupId, int partitionId) {
+        Set<FullPageId> dirtyMetaPageIds = dirtyPartitionsMap.computeIfAbsent(dataRegion, unused -> newKeySet());

Review Comment:
   I know, this way I made the code easier to read



-- 
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-unsubscribe@ignite.apache.org

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


[GitHub] [ignite-3] ibessonov commented on a diff in pull request #2594: IGNITE-20419 Fix partition meta loss after idle cluster restart.

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2594:
URL: https://github.com/apache/ignite-3/pull/2594#discussion_r1328320019


##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/mv/PersistentPageMemoryMvPartitionStorage.java:
##########
@@ -212,13 +212,30 @@ public void lastApplied(long lastAppliedIndex, long lastAppliedTerm) throws Stor
     }
 
     private void lastAppliedBusy(long lastAppliedIndex, long lastAppliedTerm) throws StorageException {
+        updateMeta((lastCheckpointId, meta) -> meta.lastApplied(lastCheckpointId, lastAppliedIndex, lastAppliedTerm));
+    }
+
+    /**
+     * Closure interface for {@link #update(UUID, PartitionMeta)}.
+     */

Review Comment:
   There's no rule to force comments into a single line if they fit. And, as far as I see in the project, such comments are usually attributed to fields, not classes or methods. Again, what's your motivation?



-- 
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-unsubscribe@ignite.apache.org

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


[GitHub] [ignite-3] tkalkirill commented on a diff in pull request #2594: IGNITE-20419 Fix partition meta loss after idle cluster restart.

Posted by "tkalkirill (via GitHub)" <gi...@apache.org>.
tkalkirill commented on code in PR #2594:
URL: https://github.com/apache/ignite-3/pull/2594#discussion_r1328465082


##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/mv/PersistentPageMemoryMvPartitionStorage.java:
##########
@@ -212,13 +212,30 @@ public void lastApplied(long lastAppliedIndex, long lastAppliedTerm) throws Stor
     }
 
     private void lastAppliedBusy(long lastAppliedIndex, long lastAppliedTerm) throws StorageException {
+        updateMeta((lastCheckpointId, meta) -> meta.lastApplied(lastCheckpointId, lastAppliedIndex, lastAppliedTerm));
+    }
+
+    /**
+     * Closure interface for {@link #update(UUID, PartitionMeta)}.
+     */

Review Comment:
   Previously mentioned beauty for me.



-- 
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-unsubscribe@ignite.apache.org

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