You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2021/09/23 01:45:32 UTC

[GitHub] [iotdb] THUMarkLau opened a new pull request #4015: [to rel/0.12] Fix concurrency issue in compaction selection

THUMarkLau opened a new pull request #4015:
URL: https://github.com/apache/iotdb/pull/4015


   Currently, there are two submission entries for compaction tasks in IoTDB: one is triggered periodically, and the other is to manually execute the `merge` statement in the CLI. Under normal circumstances, these two portals will not submit merge tasks at the same time. But in some cases, these two entries are triggered together, it is possible to submit the same merge task, causing concurrency problems.
   ![1ef0deaf8a07b11cec0a360c1b68980](https://user-images.githubusercontent.com/37140360/134443508-04f641fa-cd45-42dd-8d82-57c17096c3be.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] HTHou merged pull request #4015: [To rel/0.12] [IOTDB-1723] Fix concurrency issue in compaction selection

Posted by GitBox <gi...@apache.org>.
HTHou merged pull request #4015:
URL: https://github.com/apache/iotdb/pull/4015


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] qiaojialin commented on pull request #4015: [To rel/0.12] [IOTDB-1723] Fix concurrency issue in compaction selection

Posted by GitBox <gi...@apache.org>.
qiaojialin commented on pull request #4015:
URL: https://github.com/apache/iotdb/pull/4015#issuecomment-928584588


   add release notes


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] qiaojialin commented on a change in pull request #4015: [To rel/0.12] [IOTDB-1723] Fix concurrency issue in compaction selection

Posted by GitBox <gi...@apache.org>.
qiaojialin commented on a change in pull request #4015:
URL: https://github.com/apache/iotdb/pull/4015#discussion_r716003305



##########
File path: server/src/test/java/org/apache/iotdb/db/engine/merge/ConcurrentMergeTest.java
##########
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.engine.merge;
+
+import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.constant.TestConstant;
+import org.apache.iotdb.db.engine.MetadataManagerHelper;
+import org.apache.iotdb.db.engine.compaction.CompactionStrategy;
+import org.apache.iotdb.db.engine.flush.TsFileFlushPolicy;
+import org.apache.iotdb.db.engine.merge.manage.MergeManager;
+import org.apache.iotdb.db.engine.querycontext.QueryDataSource;
+import org.apache.iotdb.db.engine.storagegroup.StorageGroupProcessor;
+import org.apache.iotdb.db.engine.storagegroup.StorageGroupProcessorTest;
+import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
+import org.apache.iotdb.db.exception.StorageGroupProcessorException;
+import org.apache.iotdb.db.metadata.PartialPath;
+import org.apache.iotdb.db.qp.physical.crud.InsertRowPlan;
+import org.apache.iotdb.db.query.context.QueryContext;
+import org.apache.iotdb.db.utils.EnvironmentUtils;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.write.record.TSRecord;
+import org.apache.iotdb.tsfile.write.record.datapoint.DataPoint;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ConcurrentMergeTest {
+  private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+  private static Logger logger = LoggerFactory.getLogger(StorageGroupProcessorTest.class);
+
+  private String storageGroup = "root.vehicle.d0";
+  private String systemDir = TestConstant.OUTPUT_DATA_DIR.concat("info");
+  private String deviceId = "root.vehicle.d0";
+  private String measurementId = "s0";
+  private StorageGroupProcessor processor;
+  private QueryContext context = EnvironmentUtils.TEST_QUERY_CONTEXT;
+
+  @Before
+  public void setUp() throws Exception {
+    config.setCompactionStrategy(CompactionStrategy.LEVEL_COMPACTION);
+    MetadataManagerHelper.initMetadata();
+    EnvironmentUtils.envSetUp();
+    processor = new ConcurrentMergeTest.DummySGP(systemDir, storageGroup);
+    MergeManager.getINSTANCE().start();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    processor.syncDeleteDataFiles();
+    EnvironmentUtils.cleanEnv();
+    EnvironmentUtils.cleanDir(TestConstant.OUTPUT_DATA_DIR);
+    MergeManager.getINSTANCE().stop();
+    EnvironmentUtils.cleanEnv();
+    config.setCompactionStrategy(CompactionStrategy.LEVEL_COMPACTION);
+  }
+
+  @Test
+  public void testConcurrentMerge() throws Exception {
+    for (int j = 21; j <= 30; j++) {
+      TSRecord record = new TSRecord(j, deviceId);
+      record.addTuple(DataPoint.getDataPoint(TSDataType.INT32, measurementId, String.valueOf(j)));
+      processor.insert(new InsertRowPlan(record));
+      processor.asyncCloseAllWorkingTsFileProcessors();
+    }
+    processor.syncCloseAllWorkingTsFileProcessors();
+
+    for (int j = 10; j >= 1; j--) {
+      TSRecord record = new TSRecord(j, deviceId);
+      record.addTuple(DataPoint.getDataPoint(TSDataType.INT32, measurementId, String.valueOf(j)));
+      processor.insert(new InsertRowPlan(record));
+      processor.asyncCloseAllWorkingTsFileProcessors();
+    }
+
+    processor.syncCloseAllWorkingTsFileProcessors();
+    Thread mergeThreadOne = new Thread(() -> processor.merge());
+    Thread mergeThreadTwo = new Thread(() -> processor.merge());
+    mergeThreadOne.start();
+    mergeThreadTwo.start();
+    try {
+      Thread.sleep(1000);
+    } catch (Exception e) {
+
+    }
+    while (processor.getTsFileManagement().isSeqMerging) {
+      // wait

Review comment:
       add  a sleep and timeout mechanism




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] qiaojialin commented on a change in pull request #4015: [To rel/0.12] [IOTDB-1723] Fix concurrency issue in compaction selection

Posted by GitBox <gi...@apache.org>.
qiaojialin commented on a change in pull request #4015:
URL: https://github.com/apache/iotdb/pull/4015#discussion_r716003350



##########
File path: server/src/test/java/org/apache/iotdb/db/integration/IoTDBMergeIT.java
##########
@@ -380,7 +380,7 @@ public void testShowMergeStatus() throws SQLException {
       }
       // it is uncertain whether the sub tasks are created at this time point, and we are only
       // sure that the main task is created
-      assertEquals(4, cnt);
+      assertEquals(0, cnt);

Review comment:
       why modify this




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] qiaojialin commented on pull request #4015: [To rel/0.12] [IOTDB-1723] Fix concurrency issue in compaction selection

Posted by GitBox <gi...@apache.org>.
qiaojialin commented on pull request #4015:
URL: https://github.com/apache/iotdb/pull/4015#issuecomment-928584588


   add release notes


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] HTHou merged pull request #4015: [To rel/0.12] [IOTDB-1723] Fix concurrency issue in compaction selection

Posted by GitBox <gi...@apache.org>.
HTHou merged pull request #4015:
URL: https://github.com/apache/iotdb/pull/4015


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org