This is an automated email from the ASF dual-hosted git repository.
justinchen pushed a commit to branch auth-log-13
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/auth-log-13 by this push:
new ec660c564b7 Reduced the auth log when paths are too many (#16825)
ec660c564b7 is described below
commit ec660c564b78367772c7de1953f5c5d88b77ca9d
Author: Caideyipi <[email protected]>
AuthorDate: Thu Nov 27 19:18:30 2025 +0800
Reduced the auth log when paths are too many (#16825)
* partial
* test
---
.../org/apache/iotdb/db/auth/AuthorityChecker.java | 9 +++-
.../apache/iotdb/db/auth/AuthorityCheckerTest.java | 51 ++++++++++++++++++++++
.../apache/iotdb/commons/conf/CommonConfig.java | 9 ++++
.../iotdb/commons/conf/CommonDescriptor.java | 5 +++
4 files changed, 73 insertions(+), 1 deletion(-)
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/AuthorityChecker.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/AuthorityChecker.java
index aeb48149694..61b3931ba75 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/AuthorityChecker.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/AuthorityChecker.java
@@ -156,10 +156,17 @@ public class AuthorityChecker {
prompt.append(neededPrivilege);
prompt.append(" on [");
prompt.append(pathList.get(noPermissionIndexList.get(0)));
- for (int i = 1; i < noPermissionIndexList.size(); i++) {
+ final int size =
+ Math.min(
+ noPermissionIndexList.size(),
+ CommonDescriptor.getInstance().getConfig().getPathLogMaxSize());
+ for (int i = 1; i < size; i++) {
prompt.append(", ");
prompt.append(pathList.get(noPermissionIndexList.get(i)));
}
+ if (size < noPermissionIndexList.size()) {
+ prompt.append(", ...");
+ }
prompt.append("]");
return new
TSStatus(TSStatusCode.NO_PERMISSION.getStatusCode()).setMessage(prompt.toString());
}
diff --git
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/auth/AuthorityCheckerTest.java
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/auth/AuthorityCheckerTest.java
new file mode 100644
index 00000000000..ca730c377b7
--- /dev/null
+++
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/auth/AuthorityCheckerTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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.auth;
+
+import org.apache.iotdb.commons.auth.entity.PrivilegeType;
+import org.apache.iotdb.commons.conf.CommonConfig;
+import org.apache.iotdb.commons.conf.CommonDescriptor;
+import org.apache.iotdb.commons.exception.IllegalPathException;
+import org.apache.iotdb.commons.path.MeasurementPath;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Arrays;
+
+public class AuthorityCheckerTest {
+
+ @Test
+ public void testLogReduce() throws IllegalPathException {
+ final CommonConfig config = CommonDescriptor.getInstance().getConfig();
+ final int oldSize = config.getPathLogMaxSize();
+ config.setPathLogMaxSize(1);
+ Assert.assertEquals(
+ "No permissions for this operation, please add privilege WRITE_DATA on
[root.db.device.s1, ...]",
+ AuthorityChecker.getTSStatus(
+ Arrays.asList(0, 1),
+ Arrays.asList(
+ new MeasurementPath("root.db.device.s1"),
+ new MeasurementPath("root.db.device.s2")),
+ PrivilegeType.WRITE_DATA)
+ .getMessage());
+ config.setPathLogMaxSize(oldSize);
+ }
+}
diff --git
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonConfig.java
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonConfig.java
index f831125d46d..e29575d1477 100644
---
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonConfig.java
+++
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonConfig.java
@@ -427,6 +427,7 @@ public class CommonConfig {
private volatile boolean enableQuerySampling = true;
private volatile Pattern trustedUriPattern = Pattern.compile("file:.*");
+ private int pathLogMaxSize = 100;
CommonConfig() {
// Empty constructor
@@ -2475,6 +2476,14 @@ public class CommonConfig {
this.log2SizeClassGroup = log2SizeClassGroup;
}
+ public int getPathLogMaxSize() {
+ return pathLogMaxSize;
+ }
+
+ public void setPathLogMaxSize(int pathLogMaxSize) {
+ this.pathLogMaxSize = pathLogMaxSize;
+ }
+
/**
* @param querySamplingRateLimit query_sample_throughput_bytes_per_sec
*/
diff --git
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonDescriptor.java
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonDescriptor.java
index 0432415637f..dd5c5b2e164 100644
---
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonDescriptor.java
+++
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonDescriptor.java
@@ -247,6 +247,11 @@ public class CommonDescriptor {
"cluster_device_limit_threshold",
String.valueOf(config.getDeviceLimitThreshold()))));
+ config.setPathLogMaxSize(
+ Integer.parseInt(
+ properties.getProperty(
+ "path_log_max_size",
String.valueOf(config.getPathLogMaxSize()))));
+
loadRetryProperties(properties);
loadBinaryAllocatorProps(properties);
}