You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "RYH61 (via GitHub)" <gi...@apache.org> on 2023/04/04 09:45:44 UTC

[GitHub] [iotdb] RYH61 opened a new pull request, #9534: [IOTDB-5091] The multi-tenancy design about iotdb - add throtttle quota

RYH61 opened a new pull request, #9534:
URL: https://github.com/apache/iotdb/pull/9534

   see [https://issues.apache.org/jira/browse/IOTDB-5091?filter=-1](https://issues.apache.org/jira/browse/IOTDB-5091?filter=-1)


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


[GitHub] [iotdb] neuyilan commented on a diff in pull request #9534: [IOTDB-5091] The multi-tenancy design about iotdb - add throtttle quota

Posted by "neuyilan (via GitHub)" <gi...@apache.org>.
neuyilan commented on code in PR #9534:
URL: https://github.com/apache/iotdb/pull/9534#discussion_r1160381014


##########
node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonDescriptor.java:
##########
@@ -191,6 +191,9 @@ public void loadCommonProps(Properties properties) {
         Boolean.parseBoolean(
             properties.getProperty("quota_enable", String.valueOf(config.isQuotaEnable()))));
 
+    config.setRateLimiterType(
+        properties.getProperty("rate_limiter_type", config.getRateLimiterType()));

Review Comment:
   This configuration is not exposed in the iotdb-common.properties?



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/schema/ClusterSchemaFetcher.java:
##########
@@ -54,6 +55,7 @@ public class ClusterSchemaFetcher implements ISchemaFetcher {
   private final Coordinator coordinator = Coordinator.getInstance();
   private final DataNodeSchemaCache schemaCache = DataNodeSchemaCache.getInstance();
   private final ITemplateManager templateManager = ClusterTemplateManager.getInstance();
+  private MPPQueryContext context;

Review Comment:
   ths same



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/LocalExecutionPlanner.java:
##########
@@ -141,6 +141,7 @@ private void checkMemory(Operator root, FragmentInstanceStateMachine stateMachin
             }
           }
         });
+    return estimatedMemorySize;

Review Comment:
   If quota_enable is true, I think we should estimate the memory usage.  



##########
server/src/main/java/org/apache/iotdb/db/mpp/execution/driver/DataDriver.java:
##########
@@ -39,9 +39,11 @@
 public class DataDriver extends Driver {
 
   private boolean init;
+  private final long estimatedMemorySize;

Review Comment:
   add some comments about the unit of the size, byte,kb or mb?



##########
server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGMemoryImpl.java:
##########
@@ -384,7 +384,7 @@ private IMemMNode checkAndAutoCreateDeviceNode(String deviceName, IMemMNode devi
       if (!DataNodeSpaceQuotaManager.getInstance().checkDeviceLimit(storageGroupMNode.getName())) {
         throw new ExceedQuotaException(
             "The number of devices has reached the upper limit",
-            TSStatusCode.EXCEED_QUOTA_ERROR.getStatusCode());
+            TSStatusCode.SPACE_QUOTA_EXCEEDED.getStatusCode());
       }

Review Comment:
   as we have the `quota_enable` configuration, I think we can check the parameter first when we check the space/throttle quota.
   And I see there are two places that contains the `quota_enable` configurtion, the first is in the CommonDescriptor, the second is in the  IoTDBDescriptor, is it really needed in two places?



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java:
##########
@@ -243,7 +243,7 @@ public Analysis visitQuery(QueryStatement queryStatement, MPPQueryContext contex
       if (queryStatement.isGroupByTag()) {
         schemaTree = schemaFetcher.fetchSchemaWithTags(patternTree);
       } else {
-        schemaTree = schemaFetcher.fetchSchema(patternTree);
+        schemaTree = schemaFetcher.fetchSchema(patternTree, context);
       }

Review Comment:
   what is the `context` usage? the same as blow



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


[GitHub] [iotdb] RYH61 commented on a diff in pull request #9534: [IOTDB-5091] The multi-tenancy design about iotdb - add throtttle quota

Posted by "RYH61 (via GitHub)" <gi...@apache.org>.
RYH61 commented on code in PR #9534:
URL: https://github.com/apache/iotdb/pull/9534#discussion_r1160410304


##########
node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonDescriptor.java:
##########
@@ -191,6 +191,9 @@ public void loadCommonProps(Properties properties) {
         Boolean.parseBoolean(
             properties.getProperty("quota_enable", String.valueOf(config.isQuotaEnable()))));
 
+    config.setRateLimiterType(
+        properties.getProperty("rate_limiter_type", config.getRateLimiterType()));

Review Comment:
   yes



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


[GitHub] [iotdb] mychaow commented on a diff in pull request #9534: [IOTDB-5091] The multi-tenancy design about iotdb - add throtttle quota

Posted by "mychaow (via GitHub)" <gi...@apache.org>.
mychaow commented on code in PR #9534:
URL: https://github.com/apache/iotdb/pull/9534#discussion_r1159698210


##########
confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java:
##########
@@ -164,6 +169,61 @@ public List<Integer> getDataRegionIds() {
     return dataRegionIds;
   }
 
+  public TSStatus setThrottleQuota(TSetThrottleQuotaReq req) {
+    ConsensusWriteResponse response =
+        configManager
+            .getConsensusManager()
+            .write(new SetThrottleQuotaPlan(req.getUserName(), req.getThrottleQuota()));
+    if (response.getStatus() != null) {
+      if (response.getStatus().getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+        Map<Integer, TDataNodeLocation> dataNodeLocationMap =
+            configManager.getNodeManager().getRegisteredDataNodeLocations();
+        AsyncClientHandler<TSetThrottleQuotaReq, TSStatus> clientHandler =
+            new AsyncClientHandler<>(
+                DataNodeRequestType.SET_THROTTLE_QUOTA, req, dataNodeLocationMap);
+        AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler);
+        return RpcUtils.squashResponseStatusList(clientHandler.getResponseList());
+      }
+      return response.getStatus();
+    } else {
+      LOGGER.warn(
+          "Unexpected error happened while setting throttle quota on user: {}: ",
+          req.getUserName(),
+          response.getException());
+      // consensus layer related errors
+      TSStatus res = new TSStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode());
+      res.setMessage(response.getErrorMessage());
+      return res;
+    }
+  }
+
+  public TThrottleQuotaResp showThrottleQuota(TShowThrottleReq req) {
+    TThrottleQuotaResp throttleQuotaResp = new TThrottleQuotaResp();
+    if (req.getUserName() == null) {
+      throttleQuotaResp.setThrottleQuota(quotaInfo.getThrottleQuotaLimit());
+

Review Comment:
   remove the blank line



##########
server/src/main/java/org/apache/iotdb/db/quotas/DataNodeThrottleQuotaManager.java:
##########
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.quotas;
+
+import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.common.rpc.thrift.TSetThrottleQuotaReq;
+import org.apache.iotdb.commons.conf.CommonDescriptor;
+import org.apache.iotdb.commons.exception.RpcThrottlingException;
+import org.apache.iotdb.confignode.rpc.thrift.TThrottleQuotaResp;
+import org.apache.iotdb.db.mpp.plan.execution.config.executor.ClusterConfigTaskExecutor;
+import org.apache.iotdb.db.mpp.plan.statement.Statement;
+import org.apache.iotdb.rpc.RpcUtils;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DataNodeThrottleQuotaManager {
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(DataNodeThrottleQuotaManager.class);
+
+  private ThrottleQuotaLimit throttleQuotaLimit;
+
+  public DataNodeThrottleQuotaManager() {
+    throttleQuotaLimit = new ThrottleQuotaLimit();
+    recover();
+  }
+
+  /** SingleTone */

Review Comment:
   singleton



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


[GitHub] [iotdb] neuyilan commented on a diff in pull request #9534: [IOTDB-5091] The multi-tenancy design about iotdb - add throtttle quota

Posted by "neuyilan (via GitHub)" <gi...@apache.org>.
neuyilan commented on code in PR #9534:
URL: https://github.com/apache/iotdb/pull/9534#discussion_r1160497705


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java:
##########
@@ -243,7 +243,7 @@ public Analysis visitQuery(QueryStatement queryStatement, MPPQueryContext contex
       if (queryStatement.isGroupByTag()) {
         schemaTree = schemaFetcher.fetchSchemaWithTags(patternTree);
       } else {
-        schemaTree = schemaFetcher.fetchSchema(patternTree);
+        schemaTree = schemaFetcher.fetchSchema(patternTree, context);
       }

Review Comment:
   However, I do not see it's usage. 



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


[GitHub] [iotdb] neuyilan merged pull request #9534: [IOTDB-5091] The multi-tenancy design about iotdb - add throtttle quota

Posted by "neuyilan (via GitHub)" <gi...@apache.org>.
neuyilan merged PR #9534:
URL: https://github.com/apache/iotdb/pull/9534


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


[GitHub] [iotdb] RYH61 commented on a diff in pull request #9534: [IOTDB-5091] The multi-tenancy design about iotdb - add throtttle quota

Posted by "RYH61 (via GitHub)" <gi...@apache.org>.
RYH61 commented on code in PR #9534:
URL: https://github.com/apache/iotdb/pull/9534#discussion_r1160416491


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java:
##########
@@ -243,7 +243,7 @@ public Analysis visitQuery(QueryStatement queryStatement, MPPQueryContext contex
       if (queryStatement.isGroupByTag()) {
         schemaTree = schemaFetcher.fetchSchemaWithTags(patternTree);
       } else {
-        schemaTree = schemaFetcher.fetchSchema(patternTree);
+        schemaTree = schemaFetcher.fetchSchema(patternTree, context);
       }

Review Comment:
   The context contains information about the session



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