You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/05/20 10:50:12 UTC

[GitHub] [iotdb] MarcosZyk commented on a diff in pull request #5943: [IOTDB-3083] DataNode AuthorInfo cache

MarcosZyk commented on code in PR #5943:
URL: https://github.com/apache/iotdb/pull/5943#discussion_r878013647


##########
confignode/src/main/java/org/apache/iotdb/confignode/manager/PermissionManager.java:
##########
@@ -44,7 +65,22 @@ public PermissionManager(Manager configManager, AuthorInfo authorInfo) {
    * @return TSStatus
    */
   public TSStatus operatePermission(AuthorReq authorReq) {
-    return getConsensusManager().write(authorReq).getStatus();
+    TSStatus status = getConsensusManager().write(authorReq).getStatus();
+    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+      try {
+        // If the permissions change, clear the cache content affected by the operation
+        if (authorReq.getAuthorType() != ConfigRequestType.CreateUser
+            || authorReq.getAuthorType() != ConfigRequestType.CreateRole) {
+          invalidateCache(authorReq.getUserName(), authorReq.getRoleName());
+        }
+      } catch (IOException | TException e) {
+        logger.error(
+            "Failed to initialize cache,the initialization operation is {}, the error is {}",
+            authorReq.getAuthorType(),
+            e);
+      }
+    }

Review Comment:
   The cache invalidation should be operated before write operation, otherwise there may be inconsistency between configNode and some dataNodes which fail to invalidate cache.



-- 
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: reviews-unsubscribe@iotdb.apache.org

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