Caideyipi commented on code in PR #17079:
URL: https://github.com/apache/iotdb/pull/17079#discussion_r2938822191


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/thrift/IoTDBDataNodeReceiver.java:
##########
@@ -865,6 +881,7 @@ private TSStatus 
executeStatementWithPermissionCheckAndRetryOnDataTypeMismatch(
           TSStatusCode.PIPE_TRANSFER_EXECUTE_STATEMENT_ERROR, "Execute null 
statement.");
     }
 
+    LOGGER.info("Receiver id = {}: executing {}", receiverId.get(), statement);

Review Comment:
   Consider changing it to debug? There are lots of statements here and may 
boom the whole logger..



##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/table/RenameTableProcedure.java:
##########
@@ -134,7 +155,95 @@ private void renameTable(final ConfigNodeProcedureEnv env) 
{
     if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
       setFailure(new ProcedureException(new IoTDBException(status)));
     } else {
-      setNextState(RenameTableState.COMMIT_RELEASE);
+      setNextState(RenameTableState.EXECUTE_ON_REGIONS);
+    }
+  }
+
+  private void executeOnRegions(final ConfigNodeProcedureEnv env) {
+    final Map<TConsensusGroupId, TRegionReplicaSet> relatedDataRegionGroup =
+        env.getConfigManager().getRelatedDataRegionGroup4TableModel(database);
+
+    if (!relatedDataRegionGroup.isEmpty()) {
+      List<SchemaEvolution> schemaEvolutions =
+          Collections.singletonList(new TableRename(tableName, newName));
+      PublicBAOS publicBAOS = new PublicBAOS();
+      try {
+        SchemaEvolution.serializeList(schemaEvolutions, publicBAOS);
+      } catch (IOException ignored) {
+      }
+      ByteBuffer byteBuffer = ByteBuffer.wrap(publicBAOS.getBuf(), 0, 
publicBAOS.size());
+      new TableRegionTaskExecutor<>(
+              "evolve data region schema",
+              env,
+              relatedDataRegionGroup,
+              CnToDnAsyncRequestType.EVOLVE_DATA_REGION_SCHEMA,
+              ((dataNodeLocation, consensusGroupIdList) ->
+                  new TDataRegionEvolveSchemaReq(
+                      new ArrayList<>(consensusGroupIdList), byteBuffer)))
+          .execute();
+    }
+
+    final Map<TConsensusGroupId, TRegionReplicaSet> relatedSchemaRegionGroup =
+        
env.getConfigManager().getRelatedSchemaRegionGroup4TableModel(database);
+
+    if (!relatedSchemaRegionGroup.isEmpty()) {
+      List<SchemaEvolution> schemaEvolutions =
+          Collections.singletonList(new TableRename(tableName, newName));
+      PublicBAOS publicBAOS = new PublicBAOS();
+      try {
+        SchemaEvolution.serializeList(schemaEvolutions, publicBAOS);
+      } catch (IOException ignored) {
+      }
+      ByteBuffer byteBuffer = ByteBuffer.wrap(publicBAOS.getBuf(), 0, 
publicBAOS.size());
+      new TableRegionTaskExecutor<>(
+              "evolve schema region schema",
+              env,
+              relatedSchemaRegionGroup,
+              CnToDnAsyncRequestType.EVOLVE_SCHEMA_REGION_SCHEMA,
+              ((dataNodeLocation, consensusGroupIdList) ->
+                  new TSchemaRegionEvolveSchemaReq(
+                      new ArrayList<>(consensusGroupIdList), byteBuffer)))
+          .execute();
+    }
+
+    invalidateAuthCache(env);
+
+    setNextState(RenameTableState.COMMIT_RELEASE);
+  }
+
+  private void invalidateAuthCache(final ConfigNodeProcedureEnv env) {
+    TInvalidatePermissionCacheReq req = new TInvalidatePermissionCacheReq();
+    // use all empty to invalidate all cache
+    req.setUsername("");
+    req.setRoleName("");
+    TSStatus status;
+    List<TDataNodeConfiguration> allDataNodes =
+        env.getConfigManager().getNodeManager().getRegisteredDataNodes();
+    List<Pair<TDataNodeConfiguration, Long>> dataNodesToInvalid = new 
ArrayList<>();
+    for (TDataNodeConfiguration item : allDataNodes) {
+      dataNodesToInvalid.add(new Pair<>(item, System.currentTimeMillis()));
+    }
+    Iterator<Pair<TDataNodeConfiguration, Long>> it = 
dataNodesToInvalid.iterator();
+    long timeoutMS = 10 * 60 * 1000; // 10 minutes
+    while (it.hasNext()) {

Review Comment:
   Maybe it's better to use async... However it seems to be a legacy problem in 
older version



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