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 b136f664d65 IGNITE-18259 Fixed snapshot create operation started from 
a non baseline node (#10400)
b136f664d65 is described below

commit b136f664d65b3ce435a92bc957e0205af6e2b9d8
Author: Vladimir Steshin <[email protected]>
AuthorDate: Wed Nov 30 20:42:10 2022 +0300

    IGNITE-18259 Fixed snapshot create operation started from a non baseline 
node (#10400)
---
 .../snapshot/IgniteSnapshotManager.java            | 14 +++++----
 .../snapshot/EncryptedSnapshotTest.java            | 33 +++++++++++++++-------
 .../snapshot/IgniteClusterSnapshotSelfTest.java    | 25 ++++++++++++++++
 .../failover/IgniteFailoverAbstractBenchmark.java  |  4 +--
 4 files changed, 58 insertions(+), 18 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 8cbd8e07880..af8885c5c46 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
@@ -758,10 +758,6 @@ public class IgniteSnapshotManager extends 
GridCacheSharedManagerAdapter
      * @return Future which will be completed when a snapshot has been started.
      */
     private IgniteInternalFuture<SnapshotOperationResponse> 
initLocalSnapshotStartStage(SnapshotOperationRequest req) {
-        if (cctx.kernalContext().clientNode() ||
-            !CU.baselineNode(cctx.localNode(), 
cctx.kernalContext().state().clusterState()))
-            return new GridFinishedFuture<>();
-
         // Executed inside discovery notifier thread, prior to firing 
discovery custom event,
         // so it is safe to set new snapshot task inside this method without 
synchronization.
         if (clusterSnpReq != null) {
@@ -769,6 +765,12 @@ public class IgniteSnapshotManager extends 
GridCacheSharedManagerAdapter
                 "Another snapshot operation in progress [req=" + req + ", 
curr=" + clusterSnpReq + ']'));
         }
 
+        if (!CU.baselineNode(cctx.localNode(), 
cctx.kernalContext().state().clusterState())) {
+            clusterSnpReq = req;
+
+            return new GridFinishedFuture<>();
+        }
+
         Set<UUID> leftNodes = new HashSet<>(req.nodes());
         
leftNodes.removeAll(F.viewReadOnly(cctx.discovery().serverNodes(AffinityTopologyVersion.NONE),
             F.node2id()));
@@ -778,12 +780,12 @@ public class IgniteSnapshotManager extends 
GridCacheSharedManagerAdapter
                 "prior to snapshot operation start: " + leftNodes));
         }
 
-        if (!cctx.localNode().isClient() && 
cctx.kernalContext().encryption().isMasterKeyChangeInProgress()) {
+        if (cctx.kernalContext().encryption().isMasterKeyChangeInProgress()) {
             return new GridFinishedFuture<>(new 
IgniteCheckedException("Snapshot operation has been rejected. Master " +
                 "key changing process is not finished yet."));
         }
 
-        if (!cctx.localNode().isClient() && 
cctx.kernalContext().encryption().reencryptionInProgress()) {
+        if (cctx.kernalContext().encryption().reencryptionInProgress()) {
             return new GridFinishedFuture<>(new 
IgniteCheckedException("Snapshot operation has been rejected. Caches " +
                 "re-encryption process is not finished yet."));
         }
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/EncryptedSnapshotTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/EncryptedSnapshotTest.java
index bcceee7c132..0dfbb85f74f 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/EncryptedSnapshotTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/EncryptedSnapshotTest.java
@@ -30,6 +30,7 @@ import 
org.apache.ignite.internal.encryption.AbstractEncryptionTest;
 import org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2;
 import org.apache.ignite.internal.util.distributed.FullMessage;
 import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.G;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteFuture;
@@ -40,6 +41,8 @@ import org.junit.runners.Parameterized;
 
 import static org.apache.ignite.cluster.ClusterState.ACTIVE;
 import static 
org.apache.ignite.configuration.IgniteConfiguration.DFLT_SNAPSHOT_DIRECTORY;
+import static 
org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType.CACHE_GROUP_KEY_CHANGE_PREPARE;
+import static 
org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType.MASTER_KEY_CHANGE_PREPARE;
 
 /**
  * Snapshot test for encrypted-only snapshots.
@@ -75,42 +78,42 @@ public class EncryptedSnapshotTest extends 
AbstractSnapshotSelfTest {
     /** Checks re-encryption fails during snapshot restoration. */
     @Test
     public void testReencryptDuringRestore() throws Exception {
-        checkActionFailsDuringSnapshotOperation(true, this::chageCacheKey, 
"Cache group key change " +
+        checkActionFailsDuringSnapshotOperation(true, this::changeCacheKey, 
"Cache group key change " +
             "was rejected.", IgniteException.class);
     }
 
     /** Checks master key changing fails during snapshot restoration. */
     @Test
     public void testMasterKeyChangeDuringRestore() throws Exception {
-        checkActionFailsDuringSnapshotOperation(true, this::chageMasterKey, 
"Master key change was " +
+        checkActionFailsDuringSnapshotOperation(true, this::changeMasterKey, 
"Master key change was " +
             "rejected.", IgniteException.class);
     }
 
     /** Checks re-encryption fails during snapshot creation. */
     @Test
     public void testReencryptDuringSnapshot() throws Exception {
-        checkActionFailsDuringSnapshotOperation(false, this::chageCacheKey, 
"Cache group key change " +
+        checkActionFailsDuringSnapshotOperation(false, this::changeCacheKey, 
"Cache group key change " +
             "was rejected.", IgniteException.class);
     }
 
     /** Checks master key changing fails during snapshot creation. */
     @Test
     public void testMasterKeyChangeDuringSnapshot() throws Exception {
-        checkActionFailsDuringSnapshotOperation(false, this::chageMasterKey, 
"Master key change was " +
+        checkActionFailsDuringSnapshotOperation(false, this::changeMasterKey, 
"Master key change was " +
             "rejected.", IgniteException.class);
     }
 
     /** Checks snapshot action fail during cache group key change. */
     @Test
     public void testSnapshotFailsDuringCacheKeyChange() throws Exception {
-        checkSnapshotActionFailsDuringReencryption(this::chageCacheKey, 
"Caches re-encryption process " +
+        checkSnapshotActionFailsDuringReencryption(this::changeCacheKey, 
"Caches re-encryption process " +
             "is not finished yet");
     }
 
     /** Checks snapshot action fail during master key change. */
     @Test
     public void testSnapshotFailsDuringMasterKeyChange() throws Exception {
-        checkSnapshotActionFailsDuringReencryption(this::chageMasterKey, 
"Master key changing process " +
+        checkSnapshotActionFailsDuringReencryption(this::changeMasterKey, 
"Master key changing process " +
             "is not finished yet.");
     }
 
@@ -330,7 +333,7 @@ public class EncryptedSnapshotTest extends 
AbstractSnapshotSelfTest {
         IgniteEx ig = startGridsWithCache(2, CACHE_KEYS_RANGE, valueBuilder(), 
dfltCacheCfg.setName(CACHE2));
 
         for (int r = 0; r < reencryptionIterations; ++r) {
-            chageCacheKey(0).get(TIMEOUT);
+            changeCacheKey(0).get(TIMEOUT);
 
             for (int g = 0; g < 2; ++g)
                 
grid(g).context().encryption().reencryptionFuture(CU.cacheId(dfltCacheCfg.getName())).get();
@@ -407,6 +410,13 @@ public class EncryptedSnapshotTest extends 
AbstractSnapshotSelfTest {
         startGridsWithCache(3, CACHE_KEYS_RANGE, valueBuilder(), dfltCacheCfg,
             new CacheConfiguration<>(dfltCacheCfg).setName(CACHE2));
 
+        // + non-baseline node.
+        grid(0).cluster().baselineAutoAdjustEnabled(false);
+
+        
grid(0).cluster().setBaselineTopology(grid(0).cluster().topologyVersion());
+
+        startGrid(G.allGrids().size());
+
         grid(1).snapshot().createSnapshot(SNAPSHOT_NAME).get(TIMEOUT);
 
         grid(2).destroyCache(dfltCacheCfg.getName());
@@ -415,7 +425,10 @@ public class EncryptedSnapshotTest extends 
AbstractSnapshotSelfTest {
 
         BlockingCustomMessageDiscoverySpi discoSpi = discoSpi(grid(0));
 
-        discoSpi.block(msg -> msg instanceof FullMessage && 
((FullMessage<?>)msg).error().isEmpty());
+        discoSpi.block(msg -> msg instanceof FullMessage &&
+            (((FullMessage<?>)msg).type() == 
CACHE_GROUP_KEY_CHANGE_PREPARE.ordinal()
+                || (((FullMessage<?>)msg).type() == 
MASTER_KEY_CHANGE_PREPARE.ordinal()) &&
+                ((FullMessage<?>)msg).error().isEmpty()));
 
         IgniteFuture<?> fut = reencryption.apply(1);
 
@@ -481,14 +494,14 @@ public class EncryptedSnapshotTest extends 
AbstractSnapshotSelfTest {
     /**
      * @return Cache group key change action.
      */
-    private IgniteFuture<?> chageCacheKey(int gridNum) {
+    private IgniteFuture<?> changeCacheKey(int gridNum) {
         return 
grid(gridNum).encryption().changeCacheGroupKey(Collections.singletonList(CACHE2));
     }
 
     /**
      * @return Master key change action.
      */
-    private IgniteFuture<?> chageMasterKey(int gridNum) {
+    private IgniteFuture<?> changeMasterKey(int gridNum) {
         return 
grid(gridNum).encryption().changeMasterKey(AbstractEncryptionTest.MASTER_KEY_NAME_2);
     }
 }
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotSelfTest.java
index cffa3156c4d..63777b2f75b 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotSelfTest.java
@@ -1113,6 +1113,31 @@ public class IgniteClusterSnapshotSelfTest extends 
AbstractSnapshotSelfTest {
         assertSnapshotCacheKeys(snp.cache(dfltCacheCfg.getName()));
     }
 
+    /** @throws Exception If fails. */
+    @Test
+    public void testClusterSnapshotFromNonBaseline() throws Exception {
+        startGridsWithCache(2, dfltCacheCfg, CACHE_KEYS_RANGE);
+
+        grid(0).cluster().baselineAutoAdjustEnabled(false);
+
+        
grid(0).cluster().setBaselineTopology(grid(0).cluster().topologyVersion());
+
+        IgniteEx nonBaseLineNode = startGrid(G.allGrids().size());
+
+        // Yet another non-baseline.
+        startGrid(G.allGrids().size());
+
+        snp(nonBaseLineNode).createSnapshot(SNAPSHOT_NAME).get();
+
+        stopAllGrids();
+
+        IgniteEx snp = startGridsFromSnapshot(2, SNAPSHOT_NAME);
+
+        awaitPartitionMapExchange();
+
+        assertSnapshotCacheKeys(snp.cache(dfltCacheCfg.getName()));
+    }
+
     /** @throws Exception If fails. */
     @Test
     public void testClusterSnapshotFromClient() throws Exception {
diff --git 
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverAbstractBenchmark.java
 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverAbstractBenchmark.java
index dde6eeaa7d8..17a94639199 100644
--- 
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverAbstractBenchmark.java
+++ 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverAbstractBenchmark.java
@@ -107,7 +107,7 @@ public abstract class IgniteFailoverAbstractBenchmark<K, V> 
extends IgniteCacheA
 
                             Collections.shuffle(ids);
 
-                            println("Waiting for partitioned map exchage of 
all nodes");
+                            println("Waiting for partitioned map exchange of 
all nodes");
 
                             ignite.compute().broadcastAsync(new 
AwaitPartitionMapExchangeTask())
                                 .get(args.cacheOperationTimeoutMillis());
@@ -158,7 +158,7 @@ public abstract class IgniteFailoverAbstractBenchmark<K, V> 
extends IgniteCacheA
     }
 
     /**
-     * Awaits for partitiona map exchage.
+     * Awaits for partitiona map exchange.
      *
      * @param ignite Ignite.
      * @throws Exception If failed.

Reply via email to