You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2020/06/12 06:56:08 UTC
[incubator-iotdb] branch master updated: add more debug log in tag
= (#1349)
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 2c4ab85 add more debug log in tag = (#1349)
2c4ab85 is described below
commit 2c4ab8561e90a667b90d849882073bc15085f5b6
Author: Jackie Tien <Ja...@foxmail.com>
AuthorDate: Fri Jun 12 14:56:00 2020 +0800
add more debug log in tag = (#1349)
---
.../org/apache/iotdb/db/metadata/MManager.java | 119 +++++++++++++++++----
1 file changed, 98 insertions(+), 21 deletions(-)
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 99b4824..02f9e76 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
@@ -455,6 +455,12 @@ public class MManager {
for (Entry<String, String> entry : tagMap.entrySet()) {
if (tagIndex.containsKey(entry.getKey()) && tagIndex.get(entry.getKey())
.containsKey(entry.getValue())) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format(
+ "Delete: TimeSeries %s is removed from tag inverted index, "
+ + "tag key is %s, tag value is %s, tlog offset is %d",
+ node.getFullPath(), entry.getKey(), entry.getValue(), node.getOffset()));
+ }
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());
@@ -463,11 +469,11 @@ public class MManager {
}
}
} 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()));
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format(
+ "Delete: TimeSeries %s's tag info has been removed from tag inverted index before "
+ + "deleting it, tag key is %s, tag value is %s, tlog offset is %d, contains key %b",
+ node.getFullPath(), entry.getKey(), entry.getValue(), node.getOffset(), tagIndex.containsKey(entry.getKey())));
}
}
}
@@ -549,12 +555,14 @@ public class MManager {
// clear cached schema
mRemoteSchemaCache.removeItem(storageGroup);
+ // clear cached MNode
+ mNodeCache.clear();
+
// try to delete storage group
List<MeasurementMNode> leafMNodes = mtree.deleteStorageGroup(storageGroup);
for (MeasurementMNode leafMNode : leafMNodes) {
removeFromTagInvertedIndex(leafMNode);
}
- mNodeCache.clear();
if (config.isEnableParameterAdapter()) {
IoTDBConfigDynamicAdapter.getInstance().addOrDeleteStorageGroup(-1);
@@ -633,7 +641,8 @@ public class MManager {
if (!deviceNode.hasChild(measurements[i])) {
throw new MetadataException(measurements[i] + " does not exist in " + deviceId);
}
- measurementSchemas[i] = ((MeasurementMNode) deviceNode.getChild(measurements[i])).getSchema();
+ measurementSchemas[i] = ((MeasurementMNode) deviceNode.getChild(measurements[i]))
+ .getSchema();
}
return measurementSchemas;
} finally {
@@ -782,7 +791,8 @@ public class MManager {
if (value2Node.isEmpty()) {
throw new MetadataException("The key " + plan.getKey() + " is not a tag.");
}
- Set<MeasurementMNode> allMatchedNodes = new TreeSet<>(Comparator.comparing(MNode::getFullPath));
+ Set<MeasurementMNode> allMatchedNodes = new TreeSet<>(
+ Comparator.comparing(MNode::getFullPath));
if (plan.isContains()) {
for (Entry<String, Set<MeasurementMNode>> entry : value2Node.entrySet()) {
String tagValue = entry.getKey();
@@ -1228,9 +1238,26 @@ public class MManager {
// if the key has existed and the value is not equal to the new one
// we should remove before key-value from inverted index map
if (beforeValue != null && !beforeValue.equals(value)) {
- tagIndex.get(key).get(beforeValue).remove(leafMNode);
- if (tagIndex.get(key).get(beforeValue).isEmpty()) {
- tagIndex.get(key).remove(beforeValue);
+
+ if (tagIndex.containsKey(key) && tagIndex.get(key).containsKey(beforeValue)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format(
+ "Upsert: TimeSeries %s is removed from tag inverted index, "
+ + "tag key is %s, tag value is %s, tlog offset is %d",
+ leafMNode.getFullPath(), key, beforeValue, leafMNode.getOffset()));
+ }
+
+ tagIndex.get(key).get(beforeValue).remove(leafMNode);
+ if (tagIndex.get(key).get(beforeValue).isEmpty()) {
+ tagIndex.get(key).remove(beforeValue);
+ }
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format(
+ "Upsert: TimeSeries %s's tag info has been removed from tag inverted index "
+ + "before deleting it, tag key is %s, tag value is %s, tlog offset is %d, contains key %b",
+ leafMNode.getFullPath(), key, beforeValue, leafMNode.getOffset(), tagIndex.containsKey(key)));
+ }
}
}
@@ -1242,9 +1269,7 @@ public class MManager {
}
}
}
- if (tagsMap != null) {
- pair.left.putAll(tagsMap);
- }
+
pair.right.putAll(attributesMap);
// persist the change to disk
@@ -1391,13 +1416,30 @@ public class MManager {
String key = entry.getKey();
String value = entry.getValue();
// change the tag inverted index map
- tagIndex.get(key).get(value).remove(leafMNode);
- if (tagIndex.get(key).get(value).isEmpty()) {
- tagIndex.get(key).remove(value);
- if (tagIndex.get(key).isEmpty()) {
- tagIndex.remove(key);
+ if (tagIndex.containsKey(key) && tagIndex.get(key).containsKey(value)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format(
+ "Drop: TimeSeries %s is removed from tag inverted index, "
+ + "tag key is %s, tag value is %s, tlog offset is %d",
+ leafMNode.getFullPath(), entry.getKey(), entry.getValue(), leafMNode.getOffset()));
+ }
+
+ tagIndex.get(key).get(value).remove(leafMNode);
+ if (tagIndex.get(key).get(value).isEmpty()) {
+ tagIndex.get(key).remove(value);
+ if (tagIndex.get(key).isEmpty()) {
+ tagIndex.remove(key);
+ }
+ }
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format(
+ "Drop: TimeSeries %s's tag info has been removed from tag inverted index "
+ + "before deleting it, tag key is %s, tag value is %s, tlog offset is %d, contains key %b",
+ leafMNode.getFullPath(), key, value, leafMNode.getOffset(), tagIndex.containsKey(key)));
}
}
+
}
} finally {
lock.writeLock().unlock();
@@ -1455,7 +1497,24 @@ public class MManager {
String beforeValue = entry.getValue();
String currentValue = newTagValue.get(key);
// change the tag inverted index map
- tagIndex.get(key).get(beforeValue).remove(leafMNode);
+ if (tagIndex.containsKey(key) && tagIndex.get(key).containsKey(beforeValue)) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format(
+ "Set: TimeSeries %s is removed from tag inverted index, "
+ + "tag key is %s, tag value is %s, tlog offset is %d",
+ leafMNode.getFullPath(), entry.getKey(), beforeValue, leafMNode.getOffset()));
+ }
+
+ tagIndex.get(key).get(beforeValue).remove(leafMNode);
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format(
+ "Set: TimeSeries %s's tag info has been removed from tag inverted index "
+ + "before deleting it, tag key is %s, tag value is %s, tlog offset is %d, contains key %b",
+ leafMNode.getFullPath(), key, beforeValue, leafMNode.getOffset(), tagIndex.containsKey(key)));
+ }
+ }
tagIndex.computeIfAbsent(key, k -> new HashMap<>())
.computeIfAbsent(currentValue, k -> new HashSet<>()).add(leafMNode);
}
@@ -1502,7 +1561,25 @@ public class MManager {
// persist the change to disk
tagLogFile.write(pair.left, pair.right, leafMNode.getOffset());
// change the tag inverted index map
- tagIndex.get(oldKey).get(value).remove(leafMNode);
+ if (tagIndex.containsKey(oldKey) && tagIndex.get(oldKey).containsKey(value)) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format(
+ "Rename: TimeSeries %s is removed from tag inverted index, "
+ + "tag key is %s, tag value is %s, tlog offset is %d",
+ leafMNode.getFullPath(), oldKey, value, leafMNode.getOffset()));
+ }
+
+ tagIndex.get(oldKey).get(value).remove(leafMNode);
+
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format(
+ "Rename: TimeSeries %s's tag info has been removed from tag inverted index "
+ + "before deleting it, tag key is %s, tag value is %s, tlog offset is %d, contains key %b",
+ leafMNode.getFullPath(), oldKey, value, leafMNode.getOffset(), tagIndex.containsKey(oldKey)));
+ }
+ }
tagIndex.computeIfAbsent(newKey, k -> new HashMap<>())
.computeIfAbsent(value, k -> new HashSet<>()).add(leafMNode);
} else if (pair.right.containsKey(oldKey)) {