This is an automated email from the ASF dual-hosted git repository.
justinchen pushed a commit to branch c-ger-p
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/c-ger-p by this push:
new ab815b4d06e fix
ab815b4d06e is described below
commit ab815b4d06e6b3d5306b60d3b6a69f185be9050f
Author: Caideyipi <[email protected]>
AuthorDate: Thu Apr 16 10:05:46 2026 +0800
fix
---
.../protocol/thrift/impl/ClientRPCServiceImpl.java | 64 +++++++++++++++-------
1 file changed, 45 insertions(+), 19 deletions(-)
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
index 8a498fce2e3..98da206e6f0 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
@@ -37,6 +37,7 @@ import
org.apache.iotdb.commons.partition.DataPartitionQueryParam;
import org.apache.iotdb.commons.path.AlignedPath;
import org.apache.iotdb.commons.path.MeasurementPath;
import org.apache.iotdb.commons.path.PartialPath;
+import org.apache.iotdb.commons.path.PathPatternTree;
import org.apache.iotdb.commons.utils.PathUtils;
import org.apache.iotdb.db.audit.AuditLogger;
import org.apache.iotdb.db.auth.AuthorityChecker;
@@ -87,6 +88,7 @@ import
org.apache.iotdb.db.queryengine.plan.statement.crud.InsertRowStatement;
import
org.apache.iotdb.db.queryengine.plan.statement.crud.InsertRowsOfOneDeviceStatement;
import org.apache.iotdb.db.queryengine.plan.statement.crud.InsertRowsStatement;
import
org.apache.iotdb.db.queryengine.plan.statement.crud.InsertTabletStatement;
+import org.apache.iotdb.db.queryengine.plan.statement.crud.QueryStatement;
import
org.apache.iotdb.db.queryengine.plan.statement.metadata.CreateAlignedTimeSeriesStatement;
import
org.apache.iotdb.db.queryengine.plan.statement.metadata.CreateMultiTimeSeriesStatement;
import
org.apache.iotdb.db.queryengine.plan.statement.metadata.CreateTimeSeriesStatement;
@@ -819,7 +821,7 @@ public class ClientRPCServiceImpl implements
IClientRPCServiceWithHandler {
try {
final long queryId = SESSION_MANAGER.requestQueryId(clientSession,
req.statementId);
- // 1. Map<Device, String[] measurements>
ISchemaFetcher.getAllSensors(prefix) ~= 50ms
+ // 1.1 Map<Device, String[] measurements>
ISchemaFetcher.getAllSensors(prefix) ~= 50ms
final PartialPath prefixPath = new
PartialPath(req.getPrefixes().toArray(new String[0]));
if (prefixPath.hasWildcard()) {
@@ -832,13 +834,20 @@ public class ClientRPCServiceImpl implements
IClientRPCServiceWithHandler {
final Map<PartialPath, Map<String, TimeValuePair>> resultMap = new
HashMap<>();
int sensorNum = 0;
+ // 1.2 Check permission, the cost is rather low because the req only
contains one prefix path
+ final QueryStatement s =
StatementGenerator.createStatement(convert(req));
+ final TSStatus status = AuthorityChecker.checkAuthority(s,
clientSession);
+ if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+ return RpcUtils.getTSExecuteStatementResp(status);
+ }
+
final String prefixString = prefixPath.toString();
for (final ISchemaRegion region :
SchemaEngine.getInstance().getAllSchemaRegions()) {
if (!prefixString.startsWith(region.getDatabaseFullPath())
&& !region.getDatabaseFullPath().startsWith(prefixString)) {
continue;
}
- sensorNum += region.fillLastQueryMap(prefixPath, resultMap);
+ sensorNum += region.fillLastQueryMap(prefixPath, resultMap,
s.getAuthorityScope());
}
// 2.DATA_NODE_SCHEMA_CACHE.getLastCache()
@@ -914,6 +923,13 @@ public class ClientRPCServiceImpl implements
IClientRPCServiceWithHandler {
long startTime = System.nanoTime();
Throwable t = null;
try {
+ // Place the permission check first
+ final QueryStatement s =
StatementGenerator.createStatement(convert(req));
+ final TSStatus status = AuthorityChecker.checkAuthority(s,
clientSession);
+ if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+ return RpcUtils.getTSExecuteStatementResp(status);
+ }
+
String db;
String deviceId;
PartialPath devicePath;
@@ -969,9 +985,11 @@ public class ClientRPCServiceImpl implements
IClientRPCServiceWithHandler {
regionReplicaSet ->
isSameNode(
regionReplicaSet.dataNodeLocations.get(0).mPPDataExchangeEndPoint));
- int sensorNum = req.sensors.size();
- TsBlockBuilder builder = LastQueryUtil.createTsBlockBuilder(sensorNum);
+ final int sensorNum = req.sensors.size();
+ final TsBlockBuilder builder =
LastQueryUtil.createTsBlockBuilder(sensorNum);
boolean allCached = true;
+
+ PathPatternTree queryTree = new PathPatternTree();
for (String sensor : req.sensors) {
PartialPath fullPath;
if (req.isLegalPathNodes()) {
@@ -979,24 +997,32 @@ public class ClientRPCServiceImpl implements
IClientRPCServiceWithHandler {
} else {
fullPath = devicePath.concatNode((new
PartialPath(sensor)).getFullPath());
}
- TimeValuePair timeValuePair =
DATA_NODE_SCHEMA_CACHE.getLastCache(fullPath);
- if (timeValuePair == null) {
- allCached = false;
- break;
- } else if (timeValuePair.getValue() == null) {
- // there is no data for this sensor
- if (!canUseNullEntry) {
+ queryTree.appendPathPattern(fullPath);
+ }
+ queryTree.constructTree();
+ queryTree =
s.getAuthorityScope().intersectWithFullPathPrefixTree(queryTree);
+
+ if (!queryTree.isEmpty()) {
+ for (final MeasurementPath fullPath :
queryTree.getAllPathPatterns(true)) {
+ TimeValuePair timeValuePair =
DATA_NODE_SCHEMA_CACHE.getLastCache(fullPath);
+ if (timeValuePair == null) {
allCached = false;
break;
+ } else if (timeValuePair.getValue() == null) {
+ // there is no data for this sensor
+ if (!canUseNullEntry) {
+ allCached = false;
+ break;
+ }
+ } else {
+ // we don't consider TTL
+ LastQueryUtil.appendLastValue(
+ builder,
+ timeValuePair.getTimestamp(),
+ new Binary(fullPath.getFullPath(),
TSFileConfig.STRING_CHARSET),
+ timeValuePair.getValue().getStringValue(),
+ timeValuePair.getValue().getDataType().name());
}
- } else {
- // we don't consider TTL
- LastQueryUtil.appendLastValue(
- builder,
- timeValuePair.getTimestamp(),
- new Binary(fullPath.getFullPath(),
TSFileConfig.STRING_CHARSET),
- timeValuePair.getValue().getStringValue(),
- timeValuePair.getValue().getDataType().name());
}
}
// cache hit