You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "xtern (via GitHub)" <gi...@apache.org> on 2023/06/30 11:55:26 UTC

[GitHub] [ignite] xtern commented on a diff in pull request #10817: IGNITE-19878 Restrict possibility to create two caches with the same schemas and index names

xtern commented on code in PR #10817:
URL: https://github.com/apache/ignite/pull/10817#discussion_r1247775581


##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java:
##########
@@ -1086,33 +1088,42 @@ private boolean processStartNewCacheRequest(
             );
         }
 
-        if (err == null) {
-            String conflictErr = checkCacheConflict(req.startCacheConfiguration());
+        if (!validateStartNewCache(err, persistedCfgs, res, req))
+            return false;
 
-            if (conflictErr != null) {
-                U.warn(log, "Ignore cache start request. " + conflictErr);
+        err = QueryUtils.checkQueryEntityConflicts(req.startCacheConfiguration(), registeredCaches.values());
 
-                err = new IgniteCheckedException("Failed to start cache. " + conflictErr);
-            }
+        if (!validateStartNewCache(err, persistedCfgs, res, req))
+            return false;
+
+        String conflictErr = checkCacheConflict(req.startCacheConfiguration(), false);
+
+        if (conflictErr != null) {
+            U.warn(log, "Ignore cache start request. " + conflictErr);
+
+            err = new IgniteCheckedException("Failed to start cache. " + conflictErr);
         }
 
-        if (err == null)
-            err = QueryUtils.checkQueryEntityConflicts(req.startCacheConfiguration(), registeredCaches.values());
+        if (!validateStartNewCache(err, persistedCfgs, res, req))
+            return false;
 
-        if (err == null) {
-            GridEncryptionManager encMgr = ctx.encryption();
+        GridEncryptionManager encMgr = ctx.encryption();
 
-            if (ccfg.isEncryptionEnabled()) {
-                if (encMgr.isMasterKeyChangeInProgress())
-                    err = new IgniteCheckedException("Cache start failed. Master key change is in progress.");
-                else if (encMgr.masterKeyDigest() != null &&
-                    !Arrays.equals(encMgr.masterKeyDigest(), req.masterKeyDigest())) {
-                    err = new IgniteCheckedException("Cache start failed. The request was initiated before " +
-                        "the master key change and can't be processed.");
-                }
+        if (ccfg.isEncryptionEnabled()) {
+            IgniteCheckedException error = null;
 
-                if (err != null)
-                    U.warn(log, "Ignore cache start request during the master key change process.", err);
+            if (encMgr.isMasterKeyChangeInProgress())
+                error = new IgniteCheckedException("Cache start failed. Master key change is in progress.");
+            else if (encMgr.masterKeyDigest() != null &&
+                !Arrays.equals(encMgr.masterKeyDigest(), req.masterKeyDigest())) {
+                error = new IgniteCheckedException("Cache start failed. The request was initiated before " +
+                    "the master key change and can't be processed.");
+            }
+
+            if (error != null) {
+                U.warn(log, "Ignore cache start request during the master key change process.", error);
+                if (!validateStartNewCache(err, persistedCfgs, res, req))

Review Comment:
   ```suggestion
                   if (!validateStartNewCache(error, persistedCfgs, res, req))
   ```



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java:
##########
@@ -1086,33 +1088,42 @@ private boolean processStartNewCacheRequest(
             );
         }
 
-        if (err == null) {
-            String conflictErr = checkCacheConflict(req.startCacheConfiguration());
+        if (!validateStartNewCache(err, persistedCfgs, res, req))
+            return false;
 
-            if (conflictErr != null) {
-                U.warn(log, "Ignore cache start request. " + conflictErr);
+        err = QueryUtils.checkQueryEntityConflicts(req.startCacheConfiguration(), registeredCaches.values());
 
-                err = new IgniteCheckedException("Failed to start cache. " + conflictErr);
-            }
+        if (!validateStartNewCache(err, persistedCfgs, res, req))
+            return false;
+
+        String conflictErr = checkCacheConflict(req.startCacheConfiguration(), false);
+
+        if (conflictErr != null) {
+            U.warn(log, "Ignore cache start request. " + conflictErr);
+
+            err = new IgniteCheckedException("Failed to start cache. " + conflictErr);
         }
 
-        if (err == null)
-            err = QueryUtils.checkQueryEntityConflicts(req.startCacheConfiguration(), registeredCaches.values());
+        if (!validateStartNewCache(err, persistedCfgs, res, req))
+            return false;
 
-        if (err == null) {
-            GridEncryptionManager encMgr = ctx.encryption();
+        GridEncryptionManager encMgr = ctx.encryption();
 
-            if (ccfg.isEncryptionEnabled()) {
-                if (encMgr.isMasterKeyChangeInProgress())
-                    err = new IgniteCheckedException("Cache start failed. Master key change is in progress.");
-                else if (encMgr.masterKeyDigest() != null &&
-                    !Arrays.equals(encMgr.masterKeyDigest(), req.masterKeyDigest())) {
-                    err = new IgniteCheckedException("Cache start failed. The request was initiated before " +
-                        "the master key change and can't be processed.");
-                }
+        if (ccfg.isEncryptionEnabled()) {
+            IgniteCheckedException error = null;

Review Comment:
   Why we need this variable?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org