You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2022/02/15 02:36:09 UTC
[iotdb] branch rel/0.12 updated: [To rel/0.12][IOTDB-2544] Fix tag info sync error during metadata sync (#5056)
This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch rel/0.12
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/rel/0.12 by this push:
new d7aae86 [To rel/0.12][IOTDB-2544] Fix tag info sync error during metadata sync (#5056)
d7aae86 is described below
commit d7aae8639406153b8c600691fae84f17a0ed5aad
Author: Marcos_Zyk <38...@users.noreply.github.com>
AuthorDate: Tue Feb 15 10:35:20 2022 +0800
[To rel/0.12][IOTDB-2544] Fix tag info sync error during metadata sync (#5056)
---
.../org/apache/iotdb/db/metadata/MManager.java | 5 ++--
.../iotdb/db/metadata/MManagerBasicTest.java | 33 ++++++++++++++++++++++
2 files changed, 36 insertions(+), 2 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 01843e4..d106bf5 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
@@ -419,8 +419,9 @@ public class MManager {
// update tag index
Map<String, String> tagMap = null;
- if (offset != -1) {
- // offset != -1 means the timeseries has already been created and now system is recovering
+ if (offset != -1 && isRecovering) {
+ // the timeseries has already been created and now system is recovering, using the tag info
+ // in tagFile to recover index directly
tagMap = tagLogFile.readTag(config.getTagAttributeTotalSize(), offset);
} else if (plan.getTags() != null) {
// the tags only in plan means creating timeseries
diff --git a/server/src/test/java/org/apache/iotdb/db/metadata/MManagerBasicTest.java b/server/src/test/java/org/apache/iotdb/db/metadata/MManagerBasicTest.java
index 0d215f6..1a239aa 100644
--- a/server/src/test/java/org/apache/iotdb/db/metadata/MManagerBasicTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/metadata/MManagerBasicTest.java
@@ -1420,4 +1420,37 @@ public class MManagerBasicTest {
resultTag = results.get(0).getTag();
assertEquals("newValue", resultTag.get("description"));
}
+
+ @Test
+ public void testTagCreationViaMLogPlanDuringMetadataSync() throws Exception {
+ MManager manager = IoTDB.metaManager;
+
+ PartialPath path = new PartialPath("root.sg.d.s");
+ Map<String, String> tags = new HashMap<>();
+ tags.put("type", "test");
+ CreateTimeSeriesPlan plan =
+ new CreateTimeSeriesPlan(
+ path,
+ TSDataType.valueOf("INT32"),
+ TSEncoding.valueOf("RLE"),
+ compressionType,
+ null,
+ tags,
+ null,
+ null);
+ // mock that the plan has already been executed on sender and receiver will redo this plan
+ plan.setTagOffset(10);
+
+ manager.operation(plan);
+
+ ShowTimeSeriesPlan showTimeSeriesPlan =
+ new ShowTimeSeriesPlan(new PartialPath("root.sg.d.s"), true, "type", "test", 0, 0, false);
+ List<ShowTimeSeriesResult> results =
+ manager.showTimeseries(showTimeSeriesPlan, new QueryContext());
+ assertEquals(1, results.size());
+ Map<String, String> resultTag = results.get(0).getTag();
+ assertEquals("test", resultTag.get("type"));
+
+ assertEquals(0, ((MeasurementMNode) manager.getNodeByPath(path)).getOffset());
+ }
}