xtern commented on a change in pull request #7941:
URL: https://github.com/apache/ignite/pull/7941#discussion_r496486918



##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/managers/encryption/GridEncryptionManager.java
##########
@@ -821,11 +1181,57 @@ private void writeKeysToMetaStore(boolean writeAll) 
throws IgniteCheckedExceptio
         if (writeAll)
             metaStorage.write(MASTER_KEY_NAME_PREFIX, 
getSpi().getMasterKeyName());
 
-        for (Map.Entry<Integer, Serializable> entry : grpEncKeys.entrySet()) {
-            if (!writeAll && metaStorage.read(ENCRYPTION_KEY_PREFIX + 
entry.getKey()) != null)
+        if (!reencryptGroupsForced.isEmpty())
+            writeTrackedWalIdxsToMetaStore();
+
+        for (Integer grpId : grpKeys.groupIds()) {
+            if (!writeAll && !reencryptGroupsForced.containsKey(grpId) &&
+                metaStorage.read(ENCRYPTION_KEYS_PREFIX + grpId) != null)
                 continue;
 
-            writeToMetaStore(entry.getKey(), 
getSpi().encryptKey(entry.getValue()));
+            writeGroupKeysToMetaStore(grpId);
+        }
+    }
+
+    /**
+     * Writes cache group encryption keys to metastore.
+     *
+     * @param grpId Cache group ID.
+     */
+    private void writeGroupKeysToMetaStore(int grpId) throws 
IgniteCheckedException {
+        assert Thread.holdsLock(metaStorageMux);
+
+        if (metaStorage == null || !writeToMetaStoreEnabled || stopped)
+            return;
+
+        List<GroupKeyEncrypted> keysEncrypted = withMasterKeyChangeReadLock(() 
-> grpKeys.getAll(grpId));

Review comment:
       Locks reordered.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to