diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ProcedureManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ProcedureManager.java index 2822e03b7a01..dfe6f14441b5 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ProcedureManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ProcedureManager.java @@ -1720,7 +1720,7 @@ public Pair checkDuplicateTableTask( ProcedureType type; for (final Procedure procedure : executor.getProcedures().values()) { type = ProcedureFactory.getProcedureType(procedure); - if (type == null) { + if (type == null || procedure.isFinished()) { continue; } // A table shall not be concurrently operated or else the dataNode cache diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/SchemaEngine.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/SchemaEngine.java index 4f73a8707c17..de336b0a9df3 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/SchemaEngine.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/SchemaEngine.java @@ -418,7 +418,8 @@ private long getTimeSeriesNumber(ISchemaRegion schemaRegion) { * @param req heartbeat request * @param resp heartbeat response */ - public void updateAndFillSchemaCountMap(TDataNodeHeartbeatReq req, TDataNodeHeartbeatResp resp) { + public void updateAndFillSchemaCountMap( + final TDataNodeHeartbeatReq req, final TDataNodeHeartbeatResp resp) { // update DataNodeSchemaQuotaManager schemaQuotaManager.updateRemain( req.getTimeSeriesQuotaRemain(), @@ -427,7 +428,7 @@ public void updateAndFillSchemaCountMap(TDataNodeHeartbeatReq req, TDataNodeHear if (resp.getRegionDeviceUsageMap() == null) { resp.setRegionDeviceUsageMap(new HashMap<>()); } - Map tmp = resp.getRegionDeviceUsageMap(); + final Map tmp = resp.getRegionDeviceUsageMap(); SchemaRegionConsensusImpl.getInstance().getAllConsensusGroupIds().stream() .filter( consensusGroupId -> @@ -446,7 +447,7 @@ public void updateAndFillSchemaCountMap(TDataNodeHeartbeatReq req, TDataNodeHear if (resp.getRegionSeriesUsageMap() == null) { resp.setRegionSeriesUsageMap(new HashMap<>()); } - Map tmp = resp.getRegionSeriesUsageMap(); + final Map tmp = resp.getRegionSeriesUsageMap(); SchemaRegionConsensusImpl.getInstance().getAllConsensusGroupIds().stream() .filter( consensusGroupId -> diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/rescon/DataNodeSchemaQuotaManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/rescon/DataNodeSchemaQuotaManager.java index 962e68c75121..f1f2506007cc 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/rescon/DataNodeSchemaQuotaManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/rescon/DataNodeSchemaQuotaManager.java @@ -72,7 +72,7 @@ private void checkDeviceLevel() throws SchemaQuotaExceededException { } } - public void check(long acquireMeasurementNumber, int acquireDeviceNumber) + public void check(final long acquireMeasurementNumber, final int acquireDeviceNumber) throws SchemaQuotaExceededException { if (acquireDeviceNumber > 0) { checkDeviceLevel(); @@ -80,7 +80,7 @@ public void check(long acquireMeasurementNumber, int acquireDeviceNumber) // if pass device check, check measurement level try { checkMeasurementLevel(acquireMeasurementNumber); - } catch (SchemaQuotaExceededException e) { + } catch (final SchemaQuotaExceededException e) { // if measurement level check failed, roll back device remain if (acquireDeviceNumber > 0) { deviceRemain.addAndGet(1L); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/rescon/MemSchemaRegionStatistics.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/rescon/MemSchemaRegionStatistics.java index ad29546a78bd..f373f33a3419 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/rescon/MemSchemaRegionStatistics.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/rescon/MemSchemaRegionStatistics.java @@ -117,8 +117,11 @@ public void decreaseTableDevice(final String table, final long decrease) { tableDeviceNumber.computeIfPresent(table, (tableName, num) -> num - decrease); } + // Reset table device, will alter the schema statistics as well public void resetTableDevice(final String table) { - tableDeviceNumber.computeIfPresent(table, (tableName, num) -> 0L); + final long num = tableDeviceNumber.remove(table); + devicesNumber.addAndGet(-num); + schemaEngineStatistics.deleteDevice(num); } public void addDevice() { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/mem/MTreeBelowSGMemoryImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/mem/MTreeBelowSGMemoryImpl.java index 893b9cf22812..d9a09bed98d9 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/mem/MTreeBelowSGMemoryImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/mem/MTreeBelowSGMemoryImpl.java @@ -1724,8 +1724,6 @@ protected void updateEntity(final IDeviceMNode node) { } } - public void renameTableAttribute() {} - public boolean deleteTableDevice(final String tableName, final IntConsumer attributeDeleter) throws MetadataException { if (!store.hasChild(storageGroupMNode, tableName)) { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/tag/TagLogFile.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/tag/TagLogFile.java index 9cf9d51cf211..b63d5a68abb7 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/tag/TagLogFile.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/tag/TagLogFile.java @@ -41,6 +41,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Objects; public class TagLogFile implements AutoCloseable { @@ -359,8 +360,10 @@ private void serializeMap(Map map, ByteBuffer byteBuffer) @Override public void close() throws IOException { - fileChannel.force(true); - fileChannel.close(); - fileChannel = null; + if (Objects.nonNull(fileChannel) && fileChannel.isOpen()) { + fileChannel.force(true); + fileChannel.close(); + fileChannel = null; + } } }