JackieTien97 commented on code in PR #18425:
URL: https://github.com/apache/iotdb/pull/18425#discussion_r3746323166


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaFetcher.java:
##########
@@ -365,6 +365,7 @@ public boolean parseFilter4TraverseDevice(
               integerListMap.values().stream()
                   .flatMap(Collection::stream)
                   .collect(Collectors.toList()));
+          Collection<List<SchemaFilter>> values = integerListMap.values();

Review Comment:
   what's this used for?



##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/sync/AuthOperationProcedure.java:
##########
@@ -97,54 +100,40 @@ protected Flow executeFromState(ConfigNodeProcedureEnv 
env, AuthOperationProcedu
           writePlan(env);
           return Flow.HAS_MORE_STATE;
         case DATANODE_AUTHCACHE_INVALIDING:
-          TInvalidatePermissionCacheReq req = new 
TInvalidatePermissionCacheReq();
-          TSStatus status;
-          req.setUsername(user);
-          req.setRoleName(role);
+          TInvalidatePermissionCacheReq req = new 
TInvalidatePermissionCacheReq(user, role);
           if (plan.getAuthorType() == ConfigPhysicalPlanType.AccountUnlock
               || plan.getAuthorType() == 
ConfigPhysicalPlanType.RAccountUnlock) {
             // For account unlock, role carries the optional login address.
             req.setNeedDisconnect(true);
           }
-          Iterator<Pair<TDataNodeConfiguration, Long>> it = 
dataNodesToInvalid.iterator();
-          while (it.hasNext()) {
-            Pair<TDataNodeConfiguration, Long> pair = it.next();
-            if (pair.getRight() + this.timeoutMS < System.currentTimeMillis()) 
{
-              it.remove();
-              continue;
-            }
-            status =
-                (TSStatus)
-                    SyncDataNodeClientPool.getInstance()
-                        .sendSyncRequestToDataNodeWithRetry(
-                            pair.getLeft().getLocation().getInternalEndPoint(),
-                            req,
-                            CnToDnSyncRequestType.INVALIDATE_PERMISSION_CACHE);
-            if (status.getCode() == 
TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
-              it.remove();
-            }
-          }
-          if (dataNodesToInvalid.isEmpty()) {
+          final boolean proceeded =
+              new 
ClusterCachePropagator(SchemaUtils.filterFencedDataNode(env.getConfigManager()))
+                  .propagate(targets -> broadcastAuthorityCache(req, targets));
+
+          if (proceeded) {
             
LOGGER.info(ProcedureMessages.AUTH_PROCEDURE_CLEAN_DATANODE_CACHE_SUCCESSFULLY);
             return Flow.NO_MORE_STATE;
-          } else {
-            
setNextState(AuthOperationProcedureState.DATANODE_AUTHCACHE_INVALIDING);
           }
-          break;
+          
LOGGER.error(ProcedureMessages.AUTH_PROCEDURE_CACHE_INVALIDATION_FAILED);

Review Comment:
   warn ?



##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/sync/AuthOperationProcedure.java:
##########
@@ -97,54 +100,40 @@ protected Flow executeFromState(ConfigNodeProcedureEnv 
env, AuthOperationProcedu
           writePlan(env);
           return Flow.HAS_MORE_STATE;
         case DATANODE_AUTHCACHE_INVALIDING:
-          TInvalidatePermissionCacheReq req = new 
TInvalidatePermissionCacheReq();
-          TSStatus status;
-          req.setUsername(user);
-          req.setRoleName(role);
+          TInvalidatePermissionCacheReq req = new 
TInvalidatePermissionCacheReq(user, role);
           if (plan.getAuthorType() == ConfigPhysicalPlanType.AccountUnlock
               || plan.getAuthorType() == 
ConfigPhysicalPlanType.RAccountUnlock) {
             // For account unlock, role carries the optional login address.
             req.setNeedDisconnect(true);
           }
-          Iterator<Pair<TDataNodeConfiguration, Long>> it = 
dataNodesToInvalid.iterator();
-          while (it.hasNext()) {
-            Pair<TDataNodeConfiguration, Long> pair = it.next();
-            if (pair.getRight() + this.timeoutMS < System.currentTimeMillis()) 
{
-              it.remove();
-              continue;
-            }
-            status =
-                (TSStatus)
-                    SyncDataNodeClientPool.getInstance()
-                        .sendSyncRequestToDataNodeWithRetry(
-                            pair.getLeft().getLocation().getInternalEndPoint(),
-                            req,
-                            CnToDnSyncRequestType.INVALIDATE_PERMISSION_CACHE);
-            if (status.getCode() == 
TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
-              it.remove();
-            }
-          }
-          if (dataNodesToInvalid.isEmpty()) {
+          final boolean proceeded =
+              new 
ClusterCachePropagator(SchemaUtils.filterFencedDataNode(env.getConfigManager()))
+                  .propagate(targets -> broadcastAuthorityCache(req, targets));
+
+          if (proceeded) {
             
LOGGER.info(ProcedureMessages.AUTH_PROCEDURE_CLEAN_DATANODE_CACHE_SUCCESSFULLY);
             return Flow.NO_MORE_STATE;
-          } else {
-            
setNextState(AuthOperationProcedureState.DATANODE_AUTHCACHE_INVALIDING);
           }
-          break;
+          
LOGGER.error(ProcedureMessages.AUTH_PROCEDURE_CACHE_INVALIDATION_FAILED);
+          setFailure(
+              new ProcedureException(
+                  new IoTDBException(
+                      
ProcedureMessages.AUTH_PROCEDURE_CACHE_INVALIDATION_FAILED,
+                      TSStatusCode.AUTH_OPERATE_EXCEPTION.getStatusCode())));
+          return Flow.NO_MORE_STATE;
       }
     } catch (Exception e) {
       if (isRollbackSupported(state)) {
         LOGGER.error(ProcedureMessages.FAIL_WHEN_EXECUTE, plan);
         setFailure(new ProcedureException(e));
       } else {
-        LOGGER.error(
-            ProcedureMessages.RETRIEVABLE_ERROR_TRYING_TO_EXECUTE_PLAN_STATE, 
plan, state, e);
-        if (getCycles() > RETRY_THRESHOLD) {
-          setFailure(
-              new ProcedureException(
-                  String.format(
-                      ProcedureMessages.FAIL_TO_EXECUTE_PLAN_AT_STATE, 
plan.toString(), state)));
-        }
+        
LOGGER.error(ProcedureMessages.AUTH_PROCEDURE_CACHE_INVALIDATION_FAILED, e);

Review Comment:
   warn is enough?



-- 
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: [email protected]

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

Reply via email to