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 19e3a0aae055c..7a857a618b3df 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 @@ -453,11 +453,21 @@ private void removeFromTagInvertedIndex(LeafMNode node) throws IOException { tagLogFile.readTag(config.getTagAttributeTotalSize(), node.getOffset()); if (tagMap != null) { for (Entry entry : tagMap.entrySet()) { - tagIndex.get(entry.getKey()).get(entry.getValue()).remove(node); - if (tagIndex.get(entry.getKey()).get(entry.getValue()).isEmpty()) { - tagIndex.get(entry.getKey()).remove(entry.getValue()); - if (tagIndex.get(entry.getKey()).isEmpty()) { - tagIndex.remove(entry.getKey()); + if (tagIndex.containsKey(entry.getKey()) && tagIndex.get(entry.getKey()) + .containsKey(entry.getValue())) { + tagIndex.get(entry.getKey()).get(entry.getValue()).remove(node); + if (tagIndex.get(entry.getKey()).get(entry.getValue()).isEmpty()) { + tagIndex.get(entry.getKey()).remove(entry.getValue()); + if (tagIndex.get(entry.getKey()).isEmpty()) { + tagIndex.remove(entry.getKey()); + } + } + } else { + if (logger.isWarnEnabled()) { + logger.warn(String.format( + "TimeSeries %s's tag info has been removed from tag inverted index before " + + "deleting it, tag key is %s, tag value is %s", + node.getFullPath(), entry.getKey(), entry.getValue())); } } } @@ -972,7 +982,7 @@ public StorageGroupMNode getStorageGroupNode(String path) throws MetadataExcepti /** * get device node, if the storage group is not set, create it when autoCreateSchema is true - * + *

* (we develop this method as we need to get the node's lock after we get the lock.writeLock()) * *

!!!!!!Attention!!!!! must call the return node's readUnlock() if you call this method. @@ -1573,8 +1583,9 @@ public Map determineStorageGroup(String path) throws IllegalPath } /** - * if the path is in local mtree, nothing needed to do (because mtree is in the memory); - * Otherwise cache the path to mRemoteSchemaCache + * if the path is in local mtree, nothing needed to do (because mtree is in the memory); Otherwise + * cache the path to mRemoteSchemaCache + * * @param path * @param schema */