You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by li...@apache.org on 2019/11/08 09:40:37 UTC
[incubator-iotdb] branch dynamic_config updated: fix(MManager): fix
dynamic config bug when creating timeseries
This is an automated email from the ASF dual-hosted git repository.
liurui pushed a commit to branch dynamic_config
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/dynamic_config by this push:
new e524b0b fix(MManager): fix dynamic config bug when creating timeseries
e524b0b is described below
commit e524b0bb3ca907ac23ba0f837729c9067f32a574
Author: liuruiyiyang <24...@qq.com>
AuthorDate: Fri Nov 8 17:40:21 2019 +0800
fix(MManager): fix dynamic config bug when creating timeseries
---
.../org/apache/iotdb/db/metadata/MManager.java | 26 +++++++++++++---------
.../iotdb/db/qp/executor/QueryProcessExecutor.java | 2 +-
2 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java b/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
index 5396e43..640496f 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
@@ -222,7 +222,7 @@ public class MManager {
props);
break;
case MetadataOperationType.DELETE_PATH_FROM_MTREE:
- deletePaths(Collections.singletonList(new Path(args[1])));
+ deletePaths(Collections.singletonList(new Path(args[1])), false);
break;
case MetadataOperationType.SET_STORAGE_GROUP_TO_MTREE:
setStorageGroupToMTree(args[1]);
@@ -317,11 +317,6 @@ public class MManager {
} catch (StorageGroupException e) {
throw new MetadataErrorException(e);
}
- try {
- IoTDBConfigDynamicAdapter.getInstance().addOrDeleteTimeSeries(1);
- } catch (ConfigAdjusterException e) {
- throw new MetadataErrorException(e);
- }
// the two map is stored in the storage group node
Map<String, MeasurementSchema> schemaMap = getStorageGroupSchemaMap(fileNodePath);
Map<String, Integer> numSchemaMap = getStorageGroupNumSchemaMap(fileNodePath);
@@ -365,6 +360,13 @@ public class MManager {
schemaMap.put(lastNode, columnSchema);
numSchemaMap.put(lastNode, 1);
}
+ try {
+ IoTDBConfigDynamicAdapter.getInstance().addOrDeleteTimeSeries(1);
+ } catch (ConfigAdjusterException e) {
+ // Undo create time series
+ deletePaths(Collections.singletonList(path), true);
+ throw new MetadataErrorException(e);
+ }
return isNewMeasurement;
}
} finally {
@@ -483,17 +485,19 @@ public class MManager {
* @return a set contains StorageGroups that contain no more timeseries after this deletion and
* files of such StorageGroups should be deleted to reclaim disk space.
*/
- public Set<String> deletePaths(List<Path> deletePathList)
+ public Set<String> deletePaths(List<Path> deletePathList, boolean isUndo)
throws MetadataErrorException {
if (deletePathList != null && !deletePathList.isEmpty()) {
List<String> fullPath = collectPaths(deletePathList);
Set<String> emptyStorageGroups = new HashSet<>();
for (String p : fullPath) {
- try {
- IoTDBConfigDynamicAdapter.getInstance().addOrDeleteTimeSeries(-1);
- } catch (ConfigAdjusterException e) {
- throw new MetadataErrorException(e);
+ if (!isUndo) {
+ try {
+ IoTDBConfigDynamicAdapter.getInstance().addOrDeleteTimeSeries(-1);
+ } catch (ConfigAdjusterException e) {
+ throw new MetadataErrorException(e);
+ }
}
String emptiedStorageGroup = deletePath(p);
if (emptiedStorageGroup != null) {
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/executor/QueryProcessExecutor.java b/server/src/main/java/org/apache/iotdb/db/qp/executor/QueryProcessExecutor.java
index d3d6b64..073f9b9 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/executor/QueryProcessExecutor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/executor/QueryProcessExecutor.java
@@ -406,7 +406,7 @@ public class QueryProcessExecutor extends AbstractQueryProcessExecutor {
List<Path> deletePathList = deleteTimeSeriesPlan.getPaths();
try {
deleteDataOfTimeSeries(deletePathList);
- Set<String> emptyStorageGroups = mManager.deletePaths(deletePathList);
+ Set<String> emptyStorageGroups = mManager.deletePaths(deletePathList, false);
for (String deleteStorageGroup : emptyStorageGroups) {
storageEngine.deleteAllDataFilesInOneStorageGroup(deleteStorageGroup);
}