This is an automated email from the ASF dual-hosted git repository.

sergeychugunov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new 70d4cc1  IGNITE-15295 Correct exception for checkpoint marker reading 
error - Fixes #9325.
70d4cc1 is described below

commit 70d4cc16f73749d661580550c950289a2cc48549
Author: denis-chudov <moongll...@gmail.com>
AuthorDate: Thu Aug 26 17:26:48 2021 +0300

    IGNITE-15295 Correct exception for checkpoint marker reading error - Fixes 
#9325.
    
    Signed-off-by: Sergey Chugunov <sergey.chugu...@gmail.com>
---
 .../checkpoint/CheckpointMarkersStorage.java       |  2 +-
 .../CheckpointMarkerReadingErrorOnStartTest.java   | 98 ++++++++++++++++++++++
 .../ignite/testsuites/IgnitePdsTestSuite2.java     |  3 +
 3 files changed, 102 insertions(+), 1 deletion(-)

diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/checkpoint/CheckpointMarkersStorage.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/checkpoint/CheckpointMarkersStorage.java
index d601d53..630b918 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/checkpoint/CheckpointMarkersStorage.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/checkpoint/CheckpointMarkersStorage.java
@@ -304,7 +304,7 @@ public class CheckpointMarkersStorage {
 
             return new WALPointer(buf.getLong(), buf.getInt(), buf.getInt());
         }
-        catch (IOException e) {
+        catch (Exception e) {
             throw new IgniteCheckedException(
                 "Failed to read checkpoint pointer from marker file: " + 
cpMarkerFile.getAbsolutePath(), e);
         }
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/checkpoint/CheckpointMarkerReadingErrorOnStartTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/checkpoint/CheckpointMarkerReadingErrorOnStartTest.java
new file mode 100644
index 0000000..55d80b3
--- /dev/null
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/checkpoint/CheckpointMarkerReadingErrorOnStartTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.persistence.db.checkpoint;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cluster.ClusterState;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import 
org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
+
+/**
+ * Tests that checkpoint marker reading error throws correct exception.
+ */
+public class CheckpointMarkerReadingErrorOnStartTest extends 
GridCommonAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        return super.getConfiguration(igniteInstanceName)
+            .setDataStorageConfiguration(
+                new DataStorageConfiguration()
+                    .setDefaultDataRegionConfiguration(new 
DataRegionConfiguration().setPersistenceEnabled(true))
+            );
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        stopAllGrids();
+
+        cleanPersistenceDir();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+
+        cleanPersistenceDir();
+
+        super.afterTest();
+    }
+
+    /** Tests that checkpoint marker reading error throws correct exception. */
+    @Test
+    public void test() throws Exception {
+        IgniteEx ignite = startGrid(0);
+
+        ignite.cluster().state(ClusterState.ACTIVE);
+
+        IgniteCache<Integer, Integer> cache = 
ignite.getOrCreateCache(DEFAULT_CACHE_NAME);
+
+        cache.put(0, 0);
+
+        forceCheckpoint();
+
+        final PdsFolderSettings folderSettings = 
ignite.context().pdsFolderResolver().resolveFolders();
+
+        File storeWorkDir = new File(folderSettings.persistentStoreRootPath(), 
folderSettings.folderName());
+
+        File cpMarkersDir = new File(storeWorkDir, "cp");
+
+        stopGrid(0);
+
+        File[] cpMarkers = cpMarkersDir.listFiles();
+
+        assertNotNull(cpMarkers);
+
+        for (File marker : cpMarkers) {
+            new FileOutputStream(marker).close();
+        }
+
+        assertThrows(log, () -> startGrid(0), IgniteCheckedException.class,
+            "Failed to read checkpoint pointer from marker file");
+    }
+}
diff --git 
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
 
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
index f2e1cff..445002b 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
@@ -56,6 +56,7 @@ import 
org.apache.ignite.internal.processors.cache.persistence.db.SlowHistorical
 import 
org.apache.ignite.internal.processors.cache.persistence.db.checkpoint.CheckpointFailBeforeWriteMarkTest;
 import 
org.apache.ignite.internal.processors.cache.persistence.db.checkpoint.CheckpointFreeListTest;
 import 
org.apache.ignite.internal.processors.cache.persistence.db.checkpoint.CheckpointListenerForRegionTest;
+import 
org.apache.ignite.internal.processors.cache.persistence.db.checkpoint.CheckpointMarkerReadingErrorOnStartTest;
 import 
org.apache.ignite.internal.processors.cache.persistence.db.checkpoint.CheckpointStartLoggingTest;
 import 
org.apache.ignite.internal.processors.cache.persistence.db.checkpoint.IgniteCheckpointDirtyPagesForLowLoadTest;
 import 
org.apache.ignite.internal.processors.cache.persistence.db.checkpoint.LightweightCheckpointTest;
@@ -150,6 +151,8 @@ public class IgnitePdsTestSuite2 {
 
         GridTestUtils.addTestIfNeeded(suite, 
WalArchiveSizeConfigurationTest.class, ignoredTests);
 
+        GridTestUtils.addTestIfNeeded(suite, 
CheckpointMarkerReadingErrorOnStartTest.class, ignoredTests);
+
         return suite;
     }
 

Reply via email to