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

nizhikov 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 abd4f9932cc IGNITE-26803 Fix check dump on other node (#12450)
abd4f9932cc is described below

commit abd4f9932cc928feda60c8a944e3b578a5ad5cfd
Author: Nikolay <[email protected]>
AuthorDate: Fri Oct 24 13:50:57 2025 +0300

    IGNITE-26803 Fix check dump on other node (#12450)
---
 .../snapshot/SnapshotPartitionsVerifyHandler.java  |  13 ++-
 .../snapshot/dump/IgniteCacheDumpSelf2Test.java    | 111 ++++++++++++++++++++-
 2 files changed, 118 insertions(+), 6 deletions(-)

diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyHandler.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyHandler.java
index 61ac8c0f265..7de1479d0db 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyHandler.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyHandler.java
@@ -368,7 +368,12 @@ public class SnapshotPartitionsVerifyHandler implements 
SnapshotHandler<Map<Part
             Collection<PartitionHashRecord> partitionHashRecords = 
U.doInParallel(
                 cctx.snapshotMgr().snapshotExecutorService(),
                 partFiles,
-                part -> calculateDumpedPartitionHash(dump, 
cacheName(part.getParentFile()), partId(part))
+                part -> calculateDumpedPartitionHash(
+                    dump,
+                    opCtx.snapshotFileTree().folderName(),
+                    cacheName(part.getParentFile()),
+                    partId(part)
+                )
             );
 
             return 
partitionHashRecords.stream().collect(Collectors.toMap(PartitionHashRecord::partitionKey,
 r -> r));
@@ -381,7 +386,7 @@ public class SnapshotPartitionsVerifyHandler implements 
SnapshotHandler<Map<Part
     }
 
     /** */
-    private PartitionHashRecord calculateDumpedPartitionHash(Dump dump, String 
grpName, int part) {
+    private PartitionHashRecord calculateDumpedPartitionHash(Dump dump, String 
folderName, String grpName, int part) {
         if (skipHash()) {
             return new PartitionHashRecord(
                 new PartitionKey(CU.cacheId(grpName), part, grpName),
@@ -395,9 +400,7 @@ public class SnapshotPartitionsVerifyHandler implements 
SnapshotHandler<Map<Part
         }
 
         try {
-            String node = 
cctx.kernalContext().pdsFolderResolver().fileTree().folderName();
-
-            try (Dump.DumpedPartitionIterator iter = dump.iterator(node, 
CU.cacheId(grpName), part, null)) {
+            try (Dump.DumpedPartitionIterator iter = dump.iterator(folderName, 
CU.cacheId(grpName), part, null)) {
                 long size = 0;
 
                 VerifyPartitionContext ctx = new VerifyPartitionContext();
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java
index 85440adfa74..5101d758fc4 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java
@@ -20,6 +20,7 @@ package 
org.apache.ignite.internal.processors.cache.persistence.snapshot.dump;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.RandomAccessFile;
 import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
 import java.nio.file.Files;
@@ -80,6 +81,7 @@ import 
org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo;
 import 
org.apache.ignite.internal.processors.cache.persistence.filename.NodeFileTree;
 import 
org.apache.ignite.internal.processors.cache.persistence.filename.SnapshotFileTree;
 import 
org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager;
+import 
org.apache.ignite.internal.processors.cache.persistence.snapshot.SnapshotPartitionsVerifyTaskResult;
 import 
org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.AbstractCacheDumpTest.TestDumpConsumer;
 import 
org.apache.ignite.internal.processors.cache.version.CacheVersionConflictResolver;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
@@ -146,7 +148,8 @@ public class IgniteCacheDumpSelf2Test extends 
GridCommonAbstractTest {
 
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName)
+            .setConsistentId(igniteInstanceName);
 
         if (lsnr != null) {
             ListeningTestLogger testLog = new ListeningTestLogger(log);
@@ -215,6 +218,112 @@ public class IgniteCacheDumpSelf2Test extends 
GridCommonAbstractTest {
         doTestDumpRawData(true, true);
     }
 
+    /** */
+    @Test
+    public void testCheckDumpFromOtherNode_singleNode() throws Exception {
+        doTestCheckDumpFromOtherNode(1, 0);
+    }
+
+    /** */
+    @Test
+    public void testCheckDumpFromOtherNode_multiNode() throws Exception {
+        doTestCheckDumpFromOtherNode(3, 0);
+    }
+
+    /** */
+    @Test
+    public void testCheckDumpFromOtherNode_singleNode_errorNoFile() throws 
Exception {
+        doTestCheckDumpFromOtherNode(1, 1);
+    }
+
+    /** */
+    @Test
+    public void testCheckDumpFromOtherNode_multiNode_errorNoFile() throws 
Exception {
+        doTestCheckDumpFromOtherNode(3, 1);
+    }
+
+    /** */
+    @Test
+    public void testCheckDumpFromOtherNode_singleNode_errorWrongHash() throws 
Exception {
+        doTestCheckDumpFromOtherNode(1, 2);
+    }
+
+    /** */
+    @Test
+    public void testCheckDumpFromOtherNode_multiNode_errorWrongHash() throws 
Exception {
+        doTestCheckDumpFromOtherNode(3, 2);
+    }
+
+    /** */
+    private void doTestCheckDumpFromOtherNode(int nodes, int errorType) throws 
Exception {
+        IgniteEx ign = startGrids(nodes);
+
+        CacheConfiguration<Object, Object> ccfg = defaultCacheConfiguration()
+            .setAffinity(new RendezvousAffinityFunction().setPartitions(20))
+            .setBackups(nodes - 1);
+
+        ign.createCache(ccfg);
+
+        for (int i = 0; i < KEYS_CNT; ++i)
+            ign.cache(DEFAULT_CACHE_NAME).put(i, USER_FACTORY.apply(i));
+
+        SnapshotFileTree sft = snapshotFileTree(grid(nodes - 1), DMP_NAME);
+
+        ign.snapshot().createDump(DMP_NAME, null).get(getTestTimeout());
+
+        stopAllGrids();
+
+        cleanPersistenceDir(true);
+
+        if (errorType == 1) {
+            File part = sft.dumpPartition(ccfg, 13, false);
+
+            assertTrue(part.exists());
+            assertTrue(part.delete());
+        }
+        else if (errorType == 2) {
+            File part = sft.dumpPartition(ccfg, 13, false);
+
+            assertTrue(part.exists());
+            assertTrue(part.length() > HEADER_SZ);
+
+            try (RandomAccessFile raf = new RandomAccessFile(part, "rw")) {
+                raf.seek(HEADER_SZ);
+
+                byte first = raf.readByte();
+
+                raf.seek(HEADER_SZ);
+
+                raf.write(first - 1);
+            }
+        }
+
+        ign = startGrid(nodes + 1);
+
+        SnapshotPartitionsVerifyTaskResult res =
+            
ign.context().cache().context().snapshotMgr().checkSnapshot(DMP_NAME, 
null).get(getTestTimeout());
+
+        if (errorType == 0) {
+            assertTrue(F.isEmpty(res.exceptions()));
+        }
+        else if (errorType == 1) {
+            Exception err = res.exceptions().get(ign.localNode());
+
+            assertNotNull(err);
+            assertTrue(err.getMessage().contains("Snapshot data doesn't 
contain required cache group partition"));
+        }
+        else if (errorType == 2) {
+            Exception err = res.exceptions().get(ign.localNode());
+
+            assertNotNull(err);
+            assertTrue(err.getCause().getCause().getMessage().contains("Data 
corrupted"));
+
+        }
+        else
+            fail("Unknown errorType: " + errorType);
+
+    }
+
     /** */
     private void doTestDumpRawData(boolean dataCustomLocation, boolean 
dumpAbsPath) throws Exception {
         IgniteEx ign = startGrids(3);

Reply via email to