You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by zy...@apache.org on 2022/12/20 09:53:02 UTC
[iotdb] branch master updated: [IOTDB-5247] Fix drop tags or attributes throw NPE in SchemaFile (#8537)
This is an automated email from the ASF dual-hosted git repository.
zyk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 3ec0e99992 [IOTDB-5247] Fix drop tags or attributes throw NPE in SchemaFile (#8537)
3ec0e99992 is described below
commit 3ec0e999928e35e45343de8412d618695987daf5
Author: Chen YZ <43...@users.noreply.github.com>
AuthorDate: Tue Dec 20 17:52:56 2022 +0800
[IOTDB-5247] Fix drop tags or attributes throw NPE in SchemaFile (#8537)
[IOTDB-5247] Fix drop tags or attributes throw NPE in SchemaFile (#8537)
---
.../schemaregion/SchemaRegionSchemaFileImpl.java | 4 ++++
.../schemaRegion/SchemaRegionAliasAndTagTest.java | 26 +++++++++++++++++++---
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java
index a0ef3e73f0..a1b68f4ad3 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java
@@ -605,9 +605,11 @@ public class SchemaRegionSchemaFileImpl implements ISchemaRegion {
// info
// in tagFile to recover index directly
tagManager.recoverIndex(offset, leafMNode);
+ mtree.pinMNode(leafMNode);
} else if (plan.getTags() != null) {
// tag key, tag value
tagManager.addIndex(plan.getTags(), leafMNode);
+ mtree.pinMNode(leafMNode);
}
// write log
@@ -758,11 +760,13 @@ public class SchemaRegionSchemaFileImpl implements ISchemaRegion {
if (tagOffsets != null && !plan.getTagOffsets().isEmpty() && isRecovering) {
if (tagOffsets.get(i) != -1) {
tagManager.recoverIndex(plan.getTagOffsets().get(i), measurementMNodeList.get(i));
+ mtree.pinMNode(measurementMNodeList.get(i));
}
} else if (tagsList != null && !tagsList.isEmpty()) {
if (tagsList.get(i) != null) {
// tag key, tag value
tagManager.addIndex(tagsList.get(i), measurementMNodeList.get(i));
+ mtree.pinMNode(measurementMNodeList.get(i));
}
}
}
diff --git a/server/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionAliasAndTagTest.java b/server/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionAliasAndTagTest.java
index 6cdb78a1bf..9ce130114d 100644
--- a/server/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionAliasAndTagTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionAliasAndTagTest.java
@@ -31,7 +31,6 @@ import org.apache.iotdb.tsfile.utils.Pair;
import org.junit.Assert;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -357,11 +356,32 @@ public class SchemaRegionAliasAndTagTest extends AbstractSchemaRegionTest {
}
@Test
- @Ignore
public void testDropTagsOrAttributes() {
try {
+ // create timeseries with tags and attributes
prepareTimeseries();
- Set<String> keySet = new HashSet<>(Arrays.asList("tag1", "tag2", "attr1", "attr2"));
+ // add tags and attributes after create
+ Set<String> keySet =
+ new HashSet<>(Arrays.asList("tag1", "tag2", "tag3", "attr1", "attr2", "attr3"));
+ Map<String, String> newTags =
+ new HashMap<String, String>() {
+ {
+ put("tag2", "new2");
+ put("tag3", "new3");
+ }
+ };
+ schemaRegion.addTags(newTags, new PartialPath("root.sg.wf01.wt01.v1.s1"));
+ schemaRegion.addTags(newTags, new PartialPath("root.sg.wf01.aligned_device1.s1"));
+ Map<String, String> newAttributes =
+ new HashMap<String, String>() {
+ {
+ put("attr2", "new2");
+ put("attr3", "new3");
+ }
+ };
+ schemaRegion.addAttributes(newAttributes, new PartialPath("root.sg.wf01.wt01.v1.s1"));
+ schemaRegion.addAttributes(newAttributes, new PartialPath("root.sg.wf01.aligned_device1.s1"));
+ // drop all tags and attributes then check
List<String> fullPaths =
Arrays.asList(
"root.sg.wf01.wt01.v1.s1",