Skip to content

Commit

Permalink
Fixed the bug that drop table won't release device num in quota & tab…
Browse files Browse the repository at this point in the history
…le requests may block forever after ConfigNode restart
  • Loading branch information
Caideyipi authored Dec 2, 2024
1 parent 9cffb76 commit eece66e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1720,7 +1720,7 @@ public Pair<Long, Boolean> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -427,7 +428,7 @@ public void updateAndFillSchemaCountMap(TDataNodeHeartbeatReq req, TDataNodeHear
if (resp.getRegionDeviceUsageMap() == null) {
resp.setRegionDeviceUsageMap(new HashMap<>());
}
Map<Integer, Long> tmp = resp.getRegionDeviceUsageMap();
final Map<Integer, Long> tmp = resp.getRegionDeviceUsageMap();
SchemaRegionConsensusImpl.getInstance().getAllConsensusGroupIds().stream()
.filter(
consensusGroupId ->
Expand All @@ -446,7 +447,7 @@ public void updateAndFillSchemaCountMap(TDataNodeHeartbeatReq req, TDataNodeHear
if (resp.getRegionSeriesUsageMap() == null) {
resp.setRegionSeriesUsageMap(new HashMap<>());
}
Map<Integer, Long> tmp = resp.getRegionSeriesUsageMap();
final Map<Integer, Long> tmp = resp.getRegionSeriesUsageMap();
SchemaRegionConsensusImpl.getInstance().getAllConsensusGroupIds().stream()
.filter(
consensusGroupId ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ 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();
}
// 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1724,8 +1724,6 @@ protected void updateEntity(final IDeviceMNode<IMemMNode> node) {
}
}

public void renameTableAttribute() {}

public boolean deleteTableDevice(final String tableName, final IntConsumer attributeDeleter)
throws MetadataException {
if (!store.hasChild(storageGroupMNode, tableName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -359,8 +360,10 @@ private void serializeMap(Map<String, String> 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;
}
}
}

0 comments on commit eece66e

Please sign in to comment.