Skip to content

Commit eece66e

Browse files
authored
Fixed the bug that drop table won't release device num in quota & table requests may block forever after ConfigNode restart
1 parent 9cffb76 commit eece66e

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ProcedureManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,7 @@ public Pair<Long, Boolean> checkDuplicateTableTask(
17201720
ProcedureType type;
17211721
for (final Procedure<?> procedure : executor.getProcedures().values()) {
17221722
type = ProcedureFactory.getProcedureType(procedure);
1723-
if (type == null) {
1723+
if (type == null || procedure.isFinished()) {
17241724
continue;
17251725
}
17261726
// A table shall not be concurrently operated or else the dataNode cache

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/SchemaEngine.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,8 @@ private long getTimeSeriesNumber(ISchemaRegion schemaRegion) {
418418
* @param req heartbeat request
419419
* @param resp heartbeat response
420420
*/
421-
public void updateAndFillSchemaCountMap(TDataNodeHeartbeatReq req, TDataNodeHeartbeatResp resp) {
421+
public void updateAndFillSchemaCountMap(
422+
final TDataNodeHeartbeatReq req, final TDataNodeHeartbeatResp resp) {
422423
// update DataNodeSchemaQuotaManager
423424
schemaQuotaManager.updateRemain(
424425
req.getTimeSeriesQuotaRemain(),
@@ -427,7 +428,7 @@ public void updateAndFillSchemaCountMap(TDataNodeHeartbeatReq req, TDataNodeHear
427428
if (resp.getRegionDeviceUsageMap() == null) {
428429
resp.setRegionDeviceUsageMap(new HashMap<>());
429430
}
430-
Map<Integer, Long> tmp = resp.getRegionDeviceUsageMap();
431+
final Map<Integer, Long> tmp = resp.getRegionDeviceUsageMap();
431432
SchemaRegionConsensusImpl.getInstance().getAllConsensusGroupIds().stream()
432433
.filter(
433434
consensusGroupId ->
@@ -446,7 +447,7 @@ public void updateAndFillSchemaCountMap(TDataNodeHeartbeatReq req, TDataNodeHear
446447
if (resp.getRegionSeriesUsageMap() == null) {
447448
resp.setRegionSeriesUsageMap(new HashMap<>());
448449
}
449-
Map<Integer, Long> tmp = resp.getRegionSeriesUsageMap();
450+
final Map<Integer, Long> tmp = resp.getRegionSeriesUsageMap();
450451
SchemaRegionConsensusImpl.getInstance().getAllConsensusGroupIds().stream()
451452
.filter(
452453
consensusGroupId ->

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/rescon/DataNodeSchemaQuotaManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ private void checkDeviceLevel() throws SchemaQuotaExceededException {
7272
}
7373
}
7474

75-
public void check(long acquireMeasurementNumber, int acquireDeviceNumber)
75+
public void check(final long acquireMeasurementNumber, final int acquireDeviceNumber)
7676
throws SchemaQuotaExceededException {
7777
if (acquireDeviceNumber > 0) {
7878
checkDeviceLevel();
7979
}
8080
// if pass device check, check measurement level
8181
try {
8282
checkMeasurementLevel(acquireMeasurementNumber);
83-
} catch (SchemaQuotaExceededException e) {
83+
} catch (final SchemaQuotaExceededException e) {
8484
// if measurement level check failed, roll back device remain
8585
if (acquireDeviceNumber > 0) {
8686
deviceRemain.addAndGet(1L);

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/rescon/MemSchemaRegionStatistics.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,11 @@ public void decreaseTableDevice(final String table, final long decrease) {
117117
tableDeviceNumber.computeIfPresent(table, (tableName, num) -> num - decrease);
118118
}
119119

120+
// Reset table device, will alter the schema statistics as well
120121
public void resetTableDevice(final String table) {
121-
tableDeviceNumber.computeIfPresent(table, (tableName, num) -> 0L);
122+
final long num = tableDeviceNumber.remove(table);
123+
devicesNumber.addAndGet(-num);
124+
schemaEngineStatistics.deleteDevice(num);
122125
}
123126

124127
public void addDevice() {

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/mem/MTreeBelowSGMemoryImpl.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,8 +1724,6 @@ protected void updateEntity(final IDeviceMNode<IMemMNode> node) {
17241724
}
17251725
}
17261726

1727-
public void renameTableAttribute() {}
1728-
17291727
public boolean deleteTableDevice(final String tableName, final IntConsumer attributeDeleter)
17301728
throws MetadataException {
17311729
if (!store.hasChild(storageGroupMNode, tableName)) {

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/tag/TagLogFile.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import java.util.Collections;
4242
import java.util.List;
4343
import java.util.Map;
44+
import java.util.Objects;
4445

4546
public class TagLogFile implements AutoCloseable {
4647

@@ -359,8 +360,10 @@ private void serializeMap(Map<String, String> map, ByteBuffer byteBuffer)
359360

360361
@Override
361362
public void close() throws IOException {
362-
fileChannel.force(true);
363-
fileChannel.close();
364-
fileChannel = null;
363+
if (Objects.nonNull(fileChannel) && fileChannel.isOpen()) {
364+
fileChannel.force(true);
365+
fileChannel.close();
366+
fileChannel = null;
367+
}
365368
}
366369
}

0 commit comments

Comments
 (0)