morningman commented on a change in pull request #7403:
URL: https://github.com/apache/incubator-doris/pull/7403#discussion_r774327223
##########
File path: docs/zh-CN/administrator-guide/block-rule/sql-block.md
##########
@@ -51,15 +59,27 @@ PROPERTIES(
mysql> select * from order_analysis;
ERROR 1064 (HY000): errCode = 2, detailMessage = sql match regex sql block
rule: order_analysis_rule
```
+
+```sql
+CREATE SQL_BLOCK_RULE test_rule2 PROPERTIES("partitionNum" = "30",
"cardinality"="10000000000","global"="false","enable"="true")
Review comment:
这个sql示例没有说明?
##########
File path: docs/zh-CN/administrator-guide/block-rule/sql-block.md
##########
@@ -26,15 +26,23 @@ under the License.
# SQL黑名单
-支持按用户配置SQL黑名单,通过正则匹配的方式拒绝指定SQL。
该功能仅用于限制查询语句,并且不会限制 explain 语句的执行。
+支持按用户配置SQL黑名单:
+
+1. 通过正则匹配的方式拒绝指定SQL
+
+2. 通过设置partitionNum, tabletNum, cardinality, 检查一个查询是否达到其中一个限制
+ - partitionNum, tabletNum, cardinality 可以一起设置,一旦一个查询达到其中一个限制,查询将会被拦截
## 规则
对SQL规则增删改查
- 创建SQL阻止规则
- - sql:匹配规则(基于正则匹配,特殊字符需要转译),可选
- - sqlHash: sql
hash值,用于完全匹配,我们会在`fe.audit.log`打印这个值,可选,这个参数和sql只能二选一,如果给空值,是空字符串不是null
+ - sql:匹配规则(基于正则匹配,特殊字符需要转译),可选,默认值为 "NULL"
+ - sqlHash: sql hash值,用于完全匹配,我们会在`fe.audit.log`打印这个值,可选,这个参数和sql只能二选一,默认值为
"NULL"
+ - partitionNum: 一个扫描节点会扫描的最大partition数量,默认值为0L
+ - tabletNum: 一个扫描节点会扫描的最大扽tablet数量,默认值为0L
Review comment:
```suggestion
- tabletNum: 一个扫描节点会扫描的最大tablet数量,默认值为0L
```
##########
File path: docs/zh-CN/administrator-guide/block-rule/sql-block.md
##########
@@ -51,15 +59,27 @@ PROPERTIES(
mysql> select * from order_analysis;
ERROR 1064 (HY000): errCode = 2, detailMessage = sql match regex sql block
rule: order_analysis_rule
```
+
+```sql
+CREATE SQL_BLOCK_RULE test_rule2 PROPERTIES("partitionNum" = "30",
"cardinality"="10000000000","global"="false","enable"="true")
Review comment:
```suggestion
CREATE SQL_BLOCK_RULE test_rule2 PROPERTIES("partition_num" = "30",
"cardinality"="10000000000","global"="false","enable"="true")
```
##########
File path:
fe/fe-core/src/main/java/org/apache/doris/blockrule/SqlBlockRuleMgr.java
##########
@@ -107,12 +108,22 @@ public void alterSqlBlockRule(AlterSqlBlockRuleStmt stmt)
throws DdlException {
throw new DdlException("the sql block rule " + ruleName + "
not exist");
}
SqlBlockRule originRule = nameToSqlBlockRuleMap.get(ruleName);
+ SqlBlockUtil.checkAlterValidate(sqlBlockRule, originRule);
if (StringUtils.isEmpty(sqlBlockRule.getSql())) {
sqlBlockRule.setSql(originRule.getSql());
}
if (StringUtils.isEmpty(sqlBlockRule.getSqlHash())) {
sqlBlockRule.setSqlHash(originRule.getSqlHash());
}
+ if
(StringUtils.isEmpty(sqlBlockRule.getPartitionNum().toString())) {
Review comment:
sqlBlockRule.getPartitionNum() may be null?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]