Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 45 additions & 22 deletions server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -753,14 +753,16 @@ private TSExecuteStatementResp internalExecuteQueryStatement(String statement,
Measurement.INSTANCE.addOperationLatency(Operation.EXECUTE_QUERY, startTime);
long costTime = System.currentTimeMillis() - startTime;
if (costTime >= config.getSlowQueryThreshold()) {
SLOW_SQL_LOGGER.info("Cost: " + costTime + " ms, sql is " + statement);
SLOW_SQL_LOGGER.info("Cost: {} ms, sql is {}", costTime, statement);
}
if (config.isDebugOn()) {
SLOW_SQL_LOGGER.info("ChunkCache used memory proportion: " + ChunkCache.getInstance()
.getUsedMemoryProportion() + "\nChunkMetadataCache used memory proportion: "
+ ChunkMetadataCache.getInstance().getUsedMemoryProportion()
+ "\nTimeSeriesMetadataCache used memory proportion: " + TimeSeriesMetadataCache
.getInstance().getUsedMemoryProportion());
SLOW_SQL_LOGGER.info(
"ChunkCache used memory proportion: {}\nChunkMetadataCache used memory proportion: {}\n"
+ "TimeSeriesMetadataCache used memory proportion: {}",
ChunkCache.getInstance()
.getUsedMemoryProportion(),
ChunkMetadataCache.getInstance().getUsedMemoryProportion(), TimeSeriesMetadataCache
.getInstance().getUsedMemoryProportion());
}
}
}
Expand Down Expand Up @@ -1253,6 +1255,7 @@ public TSStatus insertRecords(TSInsertRecordsReq req) {

List<TSStatus> statusList = new ArrayList<>();
InsertRowPlan plan = new InsertRowPlan();
boolean isAllSuccessful = true;
for (int i = 0; i < req.deviceIds.size(); i++) {
try {
plan.setDeviceId(new PartialPath(req.getDeviceIds().get(i)));
Expand All @@ -1263,18 +1266,25 @@ public TSStatus insertRecords(TSInsertRecordsReq req) {
plan.fillValues(req.valuesList.get(i));
plan.setNeedInferType(false);
TSStatus status = checkAuthority(plan, req.getSessionId());
if (status != null) {
statusList.add(status);
} else {
statusList.add(executeNonQueryPlan(plan));
if (status == null) {
status = executeNonQueryPlan(plan);
isAllSuccessful =
((status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode())
&& isAllSuccessful);
}
statusList.add(status);
} catch (Exception e) {
logger.error("meet error when insert in batch", e);
isAllSuccessful = false;
statusList.add(RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR));
}
}

return RpcUtils.getStatus(statusList);
if (!isAllSuccessful) {
return RpcUtils.getStatus(statusList);
}

return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS);
}

@Override
Expand All @@ -1291,6 +1301,7 @@ public TSStatus insertStringRecords(TSInsertStringRecordsReq req) throws TExcept

List<TSStatus> statusList = new ArrayList<>();
InsertRowPlan plan = new InsertRowPlan();
boolean isAllSuccessful = true;
for (int i = 0; i < req.deviceIds.size(); i++) {
try {
plan.setDeviceId(new PartialPath(req.getDeviceIds().get(i)));
Expand All @@ -1301,18 +1312,25 @@ public TSStatus insertStringRecords(TSInsertStringRecordsReq req) throws TExcept
req.getValuesList().get(i).toArray(new Object[req.getValuesList().get(i).size()]));
plan.setNeedInferType(true);
TSStatus status = checkAuthority(plan, req.getSessionId());
if (status != null) {
statusList.add(status);
} else {
statusList.add(executeNonQueryPlan(plan));
if (status == null) {
status = executeNonQueryPlan(plan);
isAllSuccessful =
((status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode())
&& isAllSuccessful);
}
statusList.add(status);
} catch (Exception e) {
logger.error("meet error when insert in batch", e);
isAllSuccessful = false;
statusList.add(RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR));
}
}

return RpcUtils.getStatus(statusList);
if (!isAllSuccessful) {
return RpcUtils.getStatus(statusList);
}

return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS);
}

@Override
Expand Down Expand Up @@ -1483,6 +1501,7 @@ public TSStatus insertTablets(TSInsertTabletsReq req) {
}

List<TSStatus> statusList = new ArrayList<>();
boolean isAllSuccessful = true;
for (int i = 0; i < req.deviceIds.size(); i++) {
InsertTabletPlan insertTabletPlan = new InsertTabletPlan(
new PartialPath(req.deviceIds.get(i)),
Expand All @@ -1497,14 +1516,18 @@ public TSStatus insertTablets(TSInsertTabletsReq req) {
insertTabletPlan.setDataTypes(req.typesList.get(i));

TSStatus status = checkAuthority(insertTabletPlan, req.getSessionId());
if (status != null) {
statusList.add(status);
continue;
if (status == null) {
status = executeNonQueryPlan(insertTabletPlan);
isAllSuccessful =
((status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode())
&& isAllSuccessful);
}

statusList.add(executeNonQueryPlan(insertTabletPlan));
statusList.add(status);
}
return RpcUtils.getStatus(statusList);
if (!isAllSuccessful) {
return RpcUtils.getStatus(statusList);
}
return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS);
} catch (Exception e) {
logger.error("{}: error occurs when insertTablets", IoTDBConstant.GLOBAL_DB_NAME, e);
return RpcUtils
Expand Down