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/06/03 16:15:15 UTC

[iotdb] branch upgradeBugv6 created (now 285ab65)

This is an automated email from the ASF dual-hosted git repository.

haonan pushed a change to branch upgradeBugv6
in repository https://gitbox.apache.org/repos/asf/iotdb.git.


      at 285ab65  Fix upgrade NPE and DeadLock

This branch includes the following new commits:

     new 285ab65  Fix upgrade NPE and DeadLock

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[iotdb] 01/01: Fix upgrade NPE and DeadLock

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch upgradeBugv6
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 285ab65fe5217c62243480b4053bb53872c8823d
Author: HTHou <hh...@outlook.com>
AuthorDate: Fri Jun 4 00:14:42 2021 +0800

    Fix upgrade NPE and DeadLock
---
 .../java/org/apache/iotdb/db/engine/upgrade/UpgradeTask.java     | 9 ++-------
 .../org/apache/iotdb/tsfile/write/chunk/ChunkWriterImpl.java     | 3 ++-
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/engine/upgrade/UpgradeTask.java b/server/src/main/java/org/apache/iotdb/db/engine/upgrade/UpgradeTask.java
index 3d4aa76..078165d 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/upgrade/UpgradeTask.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/upgrade/UpgradeTask.java
@@ -61,13 +61,8 @@ public class UpgradeTask extends WrappedRunnable {
         logger.info("find upgraded file for {}", upgradeResource.getTsFile());
         upgradedResources = findUpgradedFiles();
       }
-      upgradeResource.writeLock();
-      try {
-        upgradeResource.setUpgradedResources(upgradedResources);
-        upgradeResource.getUpgradeTsFileResourceCallBack().call(upgradeResource);
-      } finally {
-        upgradeResource.writeUnlock();
-      }
+      upgradeResource.setUpgradedResources(upgradedResources);
+      upgradeResource.getUpgradeTsFileResourceCallBack().call(upgradeResource);
       UpgradeSevice.setCntUpgradeFileNum(UpgradeSevice.getCntUpgradeFileNum() - 1);
       logger.info(
           "Upgrade completes, file path:{} , the remaining upgraded file num: {}",
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/write/chunk/ChunkWriterImpl.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/chunk/ChunkWriterImpl.java
index 2c00f4a..39e5f79 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/write/chunk/ChunkWriterImpl.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/chunk/ChunkWriterImpl.java
@@ -294,7 +294,8 @@ public class ChunkWriterImpl implements IChunkWriter {
       if (numOfPages == 0) { // record the firstPageStatistics
         this.firstPageStatistics = pageWriter.getStatistics();
         this.sizeWithoutStatistic = pageWriter.writePageHeaderAndDataIntoBuff(pageBuffer, true);
-      } else if (numOfPages == 1) { // put the firstPageStatistics into pageBuffer
+      } else if (numOfPages == 1
+          && firstPageStatistics != null) { // put the firstPageStatistics into pageBuffer
         byte[] b = pageBuffer.toByteArray();
         pageBuffer.reset();
         pageBuffer.write(b, 0, this.sizeWithoutStatistic);