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/06/10 07:46:09 UTC

[GitHub] [iotdb] OneSizeFitsQuorum commented on a diff in pull request #6216: [IOTDB-3448] Migrate the logic of deleteRegion onto the consensus module

OneSizeFitsQuorum commented on code in PR #6216:
URL: https://github.com/apache/iotdb/pull/6216#discussion_r894246608


##########
server/src/main/java/org/apache/iotdb/db/service/thrift/impl/InternalServiceImpl.java:
##########
@@ -365,22 +363,33 @@ public TSStatus invalidatePermissionCache(TInvalidatePermissionCacheReq req) thr
 
   @Override
   public TSStatus deleteRegion(TConsensusGroupId tconsensusGroupId) throws TException {
-    QueryId queryId = Coordinator.getInstance().createQueryId();
-    PlanNodeId planNodeId = queryId.genPlanNodeId();
-    DeleteRegionNode deleteRegionNode = new DeleteRegionNode(queryId.genPlanNodeId());
     ConsensusGroupId consensusGroupId =
         ConsensusGroupId.Factory.createFromTConsensusGroupId(tconsensusGroupId);
-    deleteRegionNode.setConsensusGroupId(consensusGroupId);
-    deleteRegionNode.setPlanNodeId(planNodeId);
     if (consensusGroupId instanceof DataRegionId) {
-      return DataRegionConsensusImpl.getInstance()
-          .write(consensusGroupId, deleteRegionNode)
-          .getStatus();
+      ConsensusGenericResponse response =
+          DataRegionConsensusImpl.getInstance().removeConsensusGroup(consensusGroupId);
+      if (!response.isSuccess()
+          && !(response.getException() instanceof PeerNotInConsensusGroupException)) {
+        return RpcUtils.getStatus(
+            TSStatusCode.INTERNAL_SERVER_ERROR, response.getException().getMessage());
+      }
+      StorageEngineV2.getInstance().deleteDataRegion((DataRegionId) consensusGroupId);
     } else {
-      return SchemaRegionConsensusImpl.getInstance()
-          .write(consensusGroupId, deleteRegionNode)
-          .getStatus();
+      ConsensusGenericResponse response =
+          SchemaRegionConsensusImpl.getInstance().removeConsensusGroup(consensusGroupId);
+      if (!response.isSuccess()
+          && !(response.getException() instanceof PeerNotInConsensusGroupException)) {
+        return RpcUtils.getStatus(
+            TSStatusCode.INTERNAL_SERVER_ERROR, response.getException().getMessage());

Review Comment:
   Fixed



##########
server/src/main/java/org/apache/iotdb/db/service/thrift/impl/InternalServiceImpl.java:
##########
@@ -365,22 +363,33 @@ public TSStatus invalidatePermissionCache(TInvalidatePermissionCacheReq req) thr
 
   @Override
   public TSStatus deleteRegion(TConsensusGroupId tconsensusGroupId) throws TException {
-    QueryId queryId = Coordinator.getInstance().createQueryId();
-    PlanNodeId planNodeId = queryId.genPlanNodeId();
-    DeleteRegionNode deleteRegionNode = new DeleteRegionNode(queryId.genPlanNodeId());
     ConsensusGroupId consensusGroupId =
         ConsensusGroupId.Factory.createFromTConsensusGroupId(tconsensusGroupId);
-    deleteRegionNode.setConsensusGroupId(consensusGroupId);
-    deleteRegionNode.setPlanNodeId(planNodeId);
     if (consensusGroupId instanceof DataRegionId) {
-      return DataRegionConsensusImpl.getInstance()
-          .write(consensusGroupId, deleteRegionNode)
-          .getStatus();
+      ConsensusGenericResponse response =
+          DataRegionConsensusImpl.getInstance().removeConsensusGroup(consensusGroupId);
+      if (!response.isSuccess()
+          && !(response.getException() instanceof PeerNotInConsensusGroupException)) {
+        return RpcUtils.getStatus(
+            TSStatusCode.INTERNAL_SERVER_ERROR, response.getException().getMessage());

Review Comment:
   Fixed



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