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 2021/08/26 09:48:27 UTC

[iotdb] branch rel/0.12 updated: [To rel/0.12] [IOTDB-1594] Fix show timeseries returns incorrect tag value (#3842)

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 2a0b6ef  [To rel/0.12] [IOTDB-1594] Fix show timeseries returns incorrect tag value (#3842)
2a0b6ef is described below

commit 2a0b6efd911e1f6e06364a844b9268773ec55ea3
Author: zyk990424 <38...@users.noreply.github.com>
AuthorDate: Thu Aug 26 17:48:02 2021 +0800

    [To rel/0.12] [IOTDB-1594] Fix show timeseries returns incorrect tag value (#3842)
---
 .../java/org/apache/iotdb/db/metadata/logfile/TagLogFile.java    | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/logfile/TagLogFile.java b/server/src/main/java/org/apache/iotdb/db/metadata/logfile/TagLogFile.java
index e2731f4..f82d9b7 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/logfile/TagLogFile.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/logfile/TagLogFile.java
@@ -93,10 +93,13 @@ public class TagLogFile implements AutoCloseable {
 
   public long write(Map<String, String> tagMap, Map<String, String> attributeMap)
       throws IOException, MetadataException {
-    long offset = fileChannel.position();
     ByteBuffer byteBuffer = convertMapToByteBuffer(tagMap, attributeMap);
-    fileChannel.write(byteBuffer);
-    return offset;
+    synchronized (this) {
+      // get offset and write data should be atomic operation
+      long offset = fileChannel.position();
+      fileChannel.write(byteBuffer);
+      return offset;
+    }
   }
 
   /** This method does not modify this file's current position. */