Skip to content

Commit d331975

Browse files
authored
[IOTDB-2478] Try to fix IoTDBRemovePartitionIT and CompactionSchedulerTest (apache#4967)
1 parent fd85d8a commit d331975

File tree

5 files changed

+378
-143
lines changed

5 files changed

+378
-143
lines changed

integration/src/test/java/org/apache/iotdb/db/integration/IoTDBRemovePartitionIT.java

+15-5
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@
1919

2020
package org.apache.iotdb.db.integration;
2121

22+
import org.apache.iotdb.db.conf.IoTDBDescriptor;
2223
import org.apache.iotdb.db.engine.StorageEngine;
2324
import org.apache.iotdb.db.exception.metadata.IllegalPathException;
2425
import org.apache.iotdb.db.metadata.path.PartialPath;
2526
import org.apache.iotdb.db.utils.EnvironmentUtils;
2627
import org.apache.iotdb.itbase.category.LocalStandaloneTest;
2728
import org.apache.iotdb.jdbc.Config;
2829

29-
import ch.qos.logback.classic.Level;
3030
import org.junit.After;
3131
import org.junit.Before;
3232
import org.junit.Test;
3333
import org.junit.experimental.categories.Category;
34+
import org.slf4j.Logger;
3435
import org.slf4j.LoggerFactory;
3536

3637
import java.sql.Connection;
@@ -47,14 +48,12 @@
4748
@Category({LocalStandaloneTest.class})
4849
public class IoTDBRemovePartitionIT {
4950

51+
private static final Logger logger = LoggerFactory.getLogger(IoTDBRemovePartitionIT.class);
52+
5053
private static int partitionInterval = 100;
5154

5255
@Before
5356
public void setUp() throws Exception {
54-
ch.qos.logback.classic.Logger rootLogger =
55-
(ch.qos.logback.classic.Logger)
56-
LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
57-
rootLogger.setLevel(Level.toLevel("trace"));
5857
EnvironmentUtils.envSetUp();
5958
StorageEngine.setEnablePartition(true);
6059
StorageEngine.setTimePartitionInterval(partitionInterval);
@@ -70,6 +69,7 @@ public void tearDown() throws Exception {
7069

7170
@Test
7271
public void testRemoveNoPartition() throws IllegalPathException {
72+
logger.warn("running testRemoveNoPartition");
7373
StorageEngine.getInstance()
7474
.removePartitions(
7575
new PartialPath("root.test1"), (storageGroupName, timePartitionId) -> false);
@@ -94,6 +94,7 @@ public void testRemoveNoPartition() throws IllegalPathException {
9494

9595
@Test
9696
public void testRemovePartialPartition() throws IllegalPathException {
97+
logger.warn("running testRemovePartialPartition");
9798
StorageEngine.getInstance()
9899
.removePartitions(
99100
new PartialPath("root.test1"),
@@ -133,6 +134,7 @@ public void testRemovePartialPartition() throws IllegalPathException {
133134

134135
@Test
135136
public void testRemoveAllPartition() throws IllegalPathException {
137+
logger.warn("running testRemoveAllPartition");
136138
StorageEngine.getInstance()
137139
.removePartitions(
138140
new PartialPath("root.test1"), (storageGroupName, timePartitionId) -> true);
@@ -151,6 +153,7 @@ public void testRemoveAllPartition() throws IllegalPathException {
151153

152154
@Test
153155
public void testSQLRemovePartition() {
156+
logger.warn("running testSQLRemovePartition");
154157
try (Connection connection =
155158
DriverManager.getConnection(
156159
Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
@@ -172,6 +175,7 @@ public void testSQLRemovePartition() {
172175

173176
@Test
174177
public void testRemoveOnePartitionAndInsertData() {
178+
logger.warn("running testRemoveOnePartitionAndInsertData");
175179
try (Connection connection =
176180
DriverManager.getConnection(
177181
Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
@@ -196,6 +200,7 @@ public void testRemoveOnePartitionAndInsertData() {
196200

197201
@Test
198202
public void testRemovePartitionAndInsertUnSeqDataAndMerge() {
203+
logger.warn("running testRemovePartitionAndInsertUnSeqDataAndMerge");
199204
try (Connection connection =
200205
DriverManager.getConnection(
201206
Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
@@ -225,6 +230,7 @@ public void testRemovePartitionAndInsertUnSeqDataAndMerge() {
225230

226231
@Test
227232
public void testRemovePartitionAndInsertUnSeqDataAndUnSeqDataMerge() {
233+
logger.warn("running testRemovePartitionAndInsertUnSeqDataAndUnSeqDataMerge");
228234
try (Connection connection =
229235
DriverManager.getConnection(
230236
Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
@@ -254,6 +260,7 @@ public void testRemovePartitionAndInsertUnSeqDataAndUnSeqDataMerge() {
254260

255261
@Test
256262
public void testFlushAndRemoveOnePartitionAndInsertData() {
263+
logger.warn("running testFlushAndRemoveOnePartitionAndInsertData");
257264
try (Connection connection =
258265
DriverManager.getConnection(
259266
Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
@@ -312,6 +319,9 @@ private static void insertData() throws ClassNotFoundException {
312319
}
313320
}
314321
Class.forName(Config.JDBC_DRIVER_NAME);
322+
IoTDBDescriptor.getInstance().getConfig().setEnableSeqSpaceCompaction(false);
323+
IoTDBDescriptor.getInstance().getConfig().setEnableUnseqSpaceCompaction(false);
324+
IoTDBDescriptor.getInstance().getConfig().setEnableCrossSpaceCompaction(false);
315325
try (Connection connection =
316326
DriverManager.getConnection(
317327
Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");

server/src/main/java/org/apache/iotdb/db/engine/compaction/CompactionTaskManager.java

+5
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,13 @@ public synchronized void submitTask(
346346
* corresponding storage group.
347347
*/
348348
public void abortCompaction(String fullStorageGroupName) {
349+
logger.warn("Aborting compaction task for {}", fullStorageGroupName);
349350
Set<Future<Void>> subTasks =
350351
storageGroupTasks.getOrDefault(fullStorageGroupName, Collections.emptySet());
352+
logger.warn("Compaction task queue is {}", candidateCompactionTaskQueue);
353+
candidateCompactionTaskQueue.clear();
354+
logger.warn("the task map is {}", storageGroupTasks);
355+
logger.warn("the size of compaction task of {} is {}", fullStorageGroupName, subTasks.size());
351356
Iterator<Future<Void>> subIterator = subTasks.iterator();
352357
while (subIterator.hasNext()) {
353358
Future<Void> next = subIterator.next();

server/src/main/java/org/apache/iotdb/db/engine/storagegroup/VirtualStorageGroupProcessor.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -3054,8 +3054,10 @@ public void removePartitions(TimePartitionFilter filter) {
30543054
// this requires blocking all other activities
30553055
writeLock("removePartitions");
30563056
try {
3057+
tsFileManager.setAllowCompaction(false);
30573058
// abort ongoing comapctions and merges
3058-
CompactionTaskManager.getInstance().abortCompaction(logicalStorageGroupName);
3059+
CompactionTaskManager.getInstance()
3060+
.abortCompaction(logicalStorageGroupName + "-" + virtualStorageGroupId);
30593061
// close all working files that should be removed
30603062
removePartitions(filter, workSequenceTsFileProcessors.entrySet(), true);
30613063
removePartitions(filter, workUnsequenceTsFileProcessors.entrySet(), false);

server/src/main/java/org/apache/iotdb/db/utils/datastructure/FixedPriorityBlockingQueue.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ public void clear() {
137137
final ReentrantLock lock = this.lock;
138138
lock.lock();
139139
try {
140-
queue.clear();
140+
while (queue.size() != 0) {
141+
this.pollLast();
142+
}
141143
} finally {
142144
lock.unlock();
143145
}
@@ -180,4 +182,9 @@ public int getMaxSize() {
180182
public interface PollLastHook<T> {
181183
void apply(T x);
182184
}
185+
186+
@Override
187+
public String toString() {
188+
return queue.toString();
189+
}
183190
}

0 commit comments

Comments
 (0)