diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/attribute/update/DeviceAttributeCacheUpdater.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/attribute/update/DeviceAttributeCacheUpdater.java index 28f92bad165fe..7f37309f632e9 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/attribute/update/DeviceAttributeCacheUpdater.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/attribute/update/DeviceAttributeCacheUpdater.java @@ -189,17 +189,10 @@ public Pair> getAttributeUpdateInfo( public void commit(final TableDeviceAttributeCommitUpdateNode node) { final Set shrunkNodes = node.getShrunkNodes(); targetDataNodeLocations.removeAll(shrunkNodes); - shrunkNodes.forEach( - location -> { - if (attributeUpdateMap.containsKey(location)) { - removeLocation(location); - } - }); - updateContainerStatistics.keySet().removeAll(shrunkNodes); + shrunkNodes.forEach(this::removeLocation); - final TDataNodeLocation leaderLocation = node.getLeaderLocation(); - if (version.get() == node.getVersion() && attributeUpdateMap.containsKey(leaderLocation)) { - removeLocation(leaderLocation); + if (version.get() == node.getVersion()) { + removeLocation(node.getLeaderLocation()); } node.getCommitMap() @@ -238,6 +231,7 @@ private void removeLocation(final TDataNodeLocation location) { ? updateContainerStatistics.get(location).getContainerSize() : ((UpdateClearContainer) attributeUpdateMap.get(location)).ramBytesUsed()); attributeUpdateMap.remove(location); + updateContainerStatistics.remove(location); } } @@ -385,10 +379,9 @@ private void deserialize(final InputStream inputStream) throws IOException { size = ReadWriteIOUtils.readInt(inputStream); for (int i = 0; i < size; ++i) { final TDataNodeLocation location = deserializeNodeLocationForAttributeUpdate(inputStream); + final boolean isDetails = ReadWriteIOUtils.readBool(inputStream); final UpdateContainer container = - ReadWriteIOUtils.readBool(inputStream) - ? new UpdateDetailContainer() - : new UpdateClearContainer(); + isDetails ? new UpdateDetailContainer() : new UpdateClearContainer(); container.deserialize(inputStream); // Update local cache for region migration @@ -401,6 +394,9 @@ private void deserialize(final InputStream inputStream) throws IOException { guard.handleContainer(databaseName, container); } else { attributeUpdateMap.put(location, container); + if (isDetails) { + updateContainerStatistics.put(location, new UpdateDetailContainerStatistics()); + } } } }