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

namelchev 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 e4b38b25e66 IGNITE-23222 Fixed incremental snapshot restore fail if 
consistent ID is not a string (#11545)
e4b38b25e66 is described below

commit e4b38b25e66b6a1594f512d853431b8f560981bc
Author: Anastasia Iakimova <[email protected]>
AuthorDate: Sun Sep 22 19:43:36 2024 +0300

    IGNITE-23222 Fixed incremental snapshot restore fail if consistent ID is 
not a string (#11545)
---
 .../snapshot/SnapshotMetadataVerificationTask.java | 13 ++++++--
 .../snapshot/IncrementalSnapshotTest.java          | 37 ++++++++++++++++++++++
 2 files changed, 47 insertions(+), 3 deletions(-)

diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotMetadataVerificationTask.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotMetadataVerificationTask.java
index fc6d4e431c3..370e922c7a4 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotMetadataVerificationTask.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotMetadataVerificationTask.java
@@ -39,6 +39,7 @@ import org.apache.ignite.compute.ComputeJobResult;
 import org.apache.ignite.compute.ComputeJobResultPolicy;
 import org.apache.ignite.compute.ComputeTaskAdapter;
 import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import 
org.apache.ignite.internal.processors.cache.persistence.wal.FileDescriptor;
 import 
org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager;
 import 
org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory;
@@ -49,7 +50,9 @@ import org.apache.ignite.resources.IgniteInstanceResource;
 import org.apache.ignite.resources.LoggerResource;
 import org.jetbrains.annotations.NotNull;
 
+import static java.lang.String.valueOf;
 import static 
org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.incrementalSnapshotWalsDir;
+import static 
org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.snapshotMetaFileName;
 
 /** Snapshot task to verify snapshot metadata on the baseline nodes for given 
snapshot name. */
 @GridInternal
@@ -112,7 +115,7 @@ public class SnapshotMetadataVerificationTask
 
             if (arg.incrementIndex() > 0) {
                 List<SnapshotMetadata> metas = snpMeta.stream()
-                    .filter(m -> 
m.consistentId().equals(ignite.localNode().consistentId()))
+                    .filter(m -> 
m.consistentId().equals(valueOf(ignite.localNode().consistentId())))
                     .collect(Collectors.toList());
 
                 if (metas.size() != 1) {
@@ -174,7 +177,9 @@ public class SnapshotMetadataVerificationTask
         /** Checks that all incremental snapshots are present, contain correct 
metafile and WAL segments. */
         public void checkIncrementalSnapshots(SnapshotMetadata fullMeta, 
SnapshotMetadataVerificationTaskArg arg) {
             try {
-                IgniteSnapshotManager snpMgr = 
ignite.context().cache().context().snapshotMgr();
+                GridCacheSharedContext<Object, Object> ctx = 
ignite.context().cache().context();
+
+                IgniteSnapshotManager snpMgr = ctx.snapshotMgr();
 
                 // Incremental snapshot must contain ClusterSnapshotRecord.
                 long startSeg = fullMeta.snapshotRecordPointer().index();
@@ -187,7 +192,9 @@ public class SnapshotMetadataVerificationTask
                             "[snpName=" + arg.snapshotName() + ", snpPath=" + 
arg.snapshotPath() + ", incrementIndex=" + inc + ']');
                     }
 
-                    String metaFileName = 
IgniteSnapshotManager.snapshotMetaFileName(ignite.localNode().consistentId().toString());
+                    String folderName = 
ctx.kernalContext().pdsFolderResolver().resolveFolders().folderName();
+
+                    String metaFileName = snapshotMetaFileName(folderName);
 
                     File metafile = 
incSnpDir.toPath().resolve(metaFileName).toFile();
 
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotTest.java
index 57a8a2bac79..415fc905890 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotTest.java
@@ -25,6 +25,7 @@ import java.util.function.UnaryOperator;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cluster.ClusterState;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.DataStorageConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
@@ -440,6 +441,42 @@ public class IncrementalSnapshotTest extends 
AbstractSnapshotSelfTest {
         assertCacheKeys(srv.cache(DEFAULT_CACHE_NAME), CACHE_KEYS_RANGE);
     }
 
+    /** */
+    @Test
+    public void testDefaultConsistentId() throws Exception {
+        assumeFalse("https://issues.apache.org/jira/browse/IGNITE-17819";, 
encryption);
+
+        IgniteEx ignite = startGrid(getConfiguration().setConsistentId(null));
+
+        ignite.cluster().state(ClusterState.ACTIVE);
+
+        IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(new 
CacheConfiguration<>(DEFAULT_CACHE_NAME));
+
+        cache.put(1, 1);
+
+        ignite.snapshot().createSnapshot(SNAPSHOT_NAME).get();
+
+        cache.put(2, 2);
+
+        ignite.snapshot().createIncrementalSnapshot(SNAPSHOT_NAME).get();
+
+        ignite.destroyCache(DEFAULT_CACHE_NAME);
+
+        awaitPartitionMapExchange();
+
+        ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, 
F.asList(DEFAULT_CACHE_NAME)).get(getTestTimeout());
+
+        assertEquals(1, cache.size());
+
+        ignite.destroyCache(DEFAULT_CACHE_NAME);
+
+        awaitPartitionMapExchange();
+
+        ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, 
F.asList(DEFAULT_CACHE_NAME), 1).get(getTestTimeout());
+
+        assertEquals(2, cache.size());
+    }
+
     /** */
     private void checkFailWhenCacheDestroyed(String cache2rvm, String errMsg) 
throws Exception {
         IgniteEx srv = startGridsWithCache(

Reply via email to