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

timoninmaxim 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 1d69c5fc52c IGNITE-25226: Forbid custom snapshot handlers for 
incremental snapshots (#12034)
1d69c5fc52c is described below

commit 1d69c5fc52c1b7cdaab01e24f316b993b6520075
Author: Vladimir Steshin <vlads...@gmail.com>
AuthorDate: Wed May 7 14:28:37 2025 +0300

    IGNITE-25226: Forbid custom snapshot handlers for incremental snapshots 
(#12034)
---
 .../persistence/snapshot/IgniteSnapshotManager.java     |  1 +
 .../snapshot/IncrementalSnapshotVerificationTask.java   | 13 ++++++++-----
 .../persistence/snapshot/SnapshotRestoreProcess.java    |  2 +-
 .../IncrementalSnapshotCheckBeforeRestoreTest.java      | 17 +++++++++++++++++
 4 files changed, 27 insertions(+), 6 deletions(-)

diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
index c494b6d3e1b..7afbe4562a6 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
@@ -1701,6 +1701,7 @@ public class IgniteSnapshotManager extends 
GridCacheSharedManagerAdapter
         A.ensure(U.alphanumericUnderscore(name), "Snapshot name must satisfy 
the following name pattern: a-zA-Z0-9_");
         A.ensure(grps == null || 
grps.stream().filter(Objects::isNull).collect(Collectors.toSet()).isEmpty(),
             "Collection of cache groups names cannot contain null elements.");
+        A.ensure(!includeCustomHandlers || incIdx < 1, "Snapshot handlers 
aren't supported for incremental snapshot.");
 
         GridFutureAdapter<SnapshotPartitionsVerifyTaskResult> res = new 
GridFutureAdapter<>();
 
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotVerificationTask.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotVerificationTask.java
index b2f367b1a64..d4febb6abd9 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotVerificationTask.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotVerificationTask.java
@@ -149,7 +149,10 @@ public class IncrementalSnapshotVerificationTask extends 
AbstractSnapshotVerific
 
                 BaselineTopology blt = 
ignite.context().state().clusterState().baselineTopology();
 
-                checkBaseline(blt);
+                Map<String, Short> cstIdsMap = 
blt.consistentIdMapping().entrySet().stream()
+                    .collect(Collectors.toMap(e -> e.getKey().toString(), 
Map.Entry::getValue));
+
+                checkBaseline(cstIdsMap.keySet());
 
                 Map<Integer, StoredCacheData> txCaches = readTxCachesData();
 
@@ -171,7 +174,7 @@ public class IncrementalSnapshotVerificationTask extends 
AbstractSnapshotVerific
                     }
                 };
 
-                short locNodeId = blt.consistentIdMapping().get(consId);
+                short locNodeId = cstIdsMap.get(consId);
 
                 Set<GridCacheVersion> activeDhtTxs = new HashSet<>();
                 Map<GridCacheVersion, Set<Short>> txPrimParticipatingNodes = 
new HashMap<>();
@@ -331,14 +334,14 @@ public class IncrementalSnapshotVerificationTask extends 
AbstractSnapshotVerific
         }
 
         /** Checks that current baseline topology matches baseline topology of 
the snapshot. */
-        private void checkBaseline(BaselineTopology blt) throws 
IgniteCheckedException, IOException {
+        private void checkBaseline(Collection<String> baselineCstIds) throws 
IgniteCheckedException, IOException {
             IgniteSnapshotManager snpMgr = 
ignite.context().cache().context().snapshotMgr();
 
             SnapshotMetadata meta = snpMgr.readSnapshotMetadata(sft.meta());
 
-            if (!F.eqNotOrdered(blt.consistentIds(), meta.baselineNodes())) {
+            if (!F.eqNotOrdered(baselineCstIds, meta.baselineNodes())) {
                 throw new IgniteCheckedException("Topologies of snapshot and 
current cluster are different [snp=" +
-                    meta.baselineNodes() + ", current=" + blt.consistentIds() 
+ ']');
+                    meta.baselineNodes() + ", current=" + baselineCstIds + 
']');
             }
         }
 
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
index 96a5ed3c607..6bd6cac05b2 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
@@ -322,7 +322,7 @@ public class SnapshotRestoreProcess {
 
         snpMgr.recordSnapshotEvent(snpName, msg, 
EventType.EVT_CLUSTER_SNAPSHOT_RESTORE_STARTED);
 
-        snpMgr.checkSnapshot(snpName, snpPath, cacheGrpNames, true, incIdx, 
check).listen(f -> {
+        snpMgr.checkSnapshot(snpName, snpPath, cacheGrpNames, incIdx < 1, 
incIdx, check).listen(f -> {
             if (f.error() != null) {
                 finishProcess(fut0.rqId, f.error());
 
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/incremental/IncrementalSnapshotCheckBeforeRestoreTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/incremental/IncrementalSnapshotCheckBeforeRestoreTest.java
index 702b771bddb..80fb59a6741 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/incremental/IncrementalSnapshotCheckBeforeRestoreTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/incremental/IncrementalSnapshotCheckBeforeRestoreTest.java
@@ -85,6 +85,23 @@ public class IncrementalSnapshotCheckBeforeRestoreTest 
extends AbstractSnapshotS
         );
     }
 
+    /** */
+    @Test
+    public void testCheckWithCustomHandlersUnallowed() throws Exception {
+        createFullSnapshot();
+
+        int incSnpCnt = 1;
+
+        createIncrementalSnapshots(incSnpCnt);
+
+        GridTestUtils.assertThrows(
+            null,
+            () -> snp(grid(1)).checkSnapshot(SNP, null, null, true, 1, 
true).get(getTestTimeout()),
+            IllegalArgumentException.class,
+            "Snapshot handlers aren't supported for incremental snapshot"
+        );
+    }
+
     /** */
     @Test
     public void testCheckCorrectIncrementalSnapshot() throws Exception {

Reply via email to