Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some files were not added to TsFileResourceManager #14246

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3063,9 +3063,6 @@ private boolean loadTsFileToUnSequence(
PipeInsertionDataNodeListener.getInstance()
.listenToTsFile(dataRegionId, databaseName, tsFileResource, true, isGeneratedByPipe);

// help tsfile resource degrade
tsFileResourceManager.registerSealedTsFileResource(tsFileResource);

tsFileManager.add(tsFileResource, false);

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ public void removeAll(List<TsFileResource> tsFileResourceList, boolean sequence)
try {
for (TsFileResource resource : tsFileResourceList) {
remove(resource, sequence);
TsFileResourceManager.getInstance().removeTsFileResource(resource);
}
} finally {
writeLock("removeAll");
Expand All @@ -187,6 +186,7 @@ public void removeAll(List<TsFileResource> tsFileResourceList, boolean sequence)
*/
public void insertToPartitionFileList(
TsFileResource tsFileResource, long timePartition, boolean sequence, int insertPos) {
registerTsFileResourceToResourceManager(tsFileResource);
writeLock("add");
try {
Map<Long, TsFileResourceList> selectedMap = sequence ? sequenceFiles : unsequenceFiles;
Expand All @@ -204,6 +204,7 @@ public void insertToPartitionFileList(
}

public void add(TsFileResource tsFileResource, boolean sequence) {
registerTsFileResourceToResourceManager(tsFileResource);
writeLock("add");
try {
Map<Long, TsFileResourceList> selectedMap = sequence ? sequenceFiles : unsequenceFiles;
Expand All @@ -221,6 +222,7 @@ public void add(TsFileResource tsFileResource, boolean sequence) {
}

public void keepOrderInsert(TsFileResource tsFileResource, boolean sequence) throws IOException {
registerTsFileResourceToResourceManager(tsFileResource);
writeLock("keepOrderInsert");
try {
Map<Long, TsFileResourceList> selectedMap = sequence ? sequenceFiles : unsequenceFiles;
Expand Down Expand Up @@ -248,6 +250,13 @@ public void addAll(List<TsFileResource> tsFileResourceList, boolean sequence) {
}
}

private void registerTsFileResourceToResourceManager(TsFileResource resource) {
TsFileResourceStatus status = resource.getStatus();
if (status != TsFileResourceStatus.UNCLOSED && status != TsFileResourceStatus.DELETED) {
TsFileResourceManager.getInstance().registerSealedTsFileResource(resource);
}
}

/** This method is called after compaction to update memory. */
public void replace(
List<TsFileResource> seqFileResources,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public void setUp()
enableInsertionCrossSpaceCompaction =
IoTDBDescriptor.getInstance().getConfig().isEnableCrossSpaceCompaction();
IoTDBDescriptor.getInstance().getConfig().setEnableCrossSpaceCompaction(true);
TsFileResourceManager.getInstance().clear();
}

@After
Expand All @@ -80,6 +81,7 @@ public void tearDown() throws IOException, StorageEngineException {
.getConfig()
.setEnableCrossSpaceCompaction(enableInsertionCrossSpaceCompaction);
super.tearDown();
TsFileResourceManager.getInstance().clear();
}

@Test
Expand Down Expand Up @@ -127,6 +129,9 @@ public void test1() throws IOException, InterruptedException {
long timestamp = TsFileNameGenerator.getTsFileName(targetFile.getTsFile().getName()).getTime();
Assert.assertEquals(2, timestamp);
Assert.assertTrue(tsFileManager.getTsFileList(false).isEmpty());
Assert.assertEquals(
tsFileManager.size(true) + tsFileManager.size(false),
TsFileResourceManager.getInstance().getPriorityQueueSize());
}

@Test
Expand Down Expand Up @@ -168,6 +173,9 @@ public void test2() throws IOException, InterruptedException {
TsFileResource targetFile = tsFileManager.getTsFileList(true).get(1);
long timestamp = TsFileNameGenerator.getTsFileName(targetFile.getTsFile().getName()).getTime();
Assert.assertEquals(2, timestamp);
Assert.assertEquals(
tsFileManager.size(true) + tsFileManager.size(false),
TsFileResourceManager.getInstance().getPriorityQueueSize());
}

@Test
Expand Down Expand Up @@ -209,6 +217,9 @@ public void test3() throws IOException, InterruptedException {
TsFileResource targetFile = tsFileManager.getTsFileList(true).get(0);
long timestamp = TsFileNameGenerator.getTsFileName(targetFile.getTsFile().getName()).getTime();
Assert.assertEquals(0, timestamp);
Assert.assertEquals(
tsFileManager.size(true) + tsFileManager.size(false),
TsFileResourceManager.getInstance().getPriorityQueueSize());
}

@Test
Expand Down Expand Up @@ -256,6 +267,9 @@ public void test4() throws IOException, InterruptedException {
long timestamp = TsFileNameGenerator.getTsFileName(targetFile.getTsFile().getName()).getTime();
Assert.assertEquals(4, timestamp);
Assert.assertTrue(tsFileManager.getTsFileList(false).isEmpty());
Assert.assertEquals(
tsFileManager.size(true) + tsFileManager.size(false),
TsFileResourceManager.getInstance().getPriorityQueueSize());
}

@Test
Expand Down Expand Up @@ -291,6 +305,9 @@ public void test5() throws IOException, InterruptedException {
TsFileResource targetFile = tsFileManager.getTsFileList(true).get(0);
long timestamp = TsFileNameGenerator.getTsFileName(targetFile.getTsFile().getName()).getTime();
Assert.assertEquals(2, timestamp);
Assert.assertEquals(
tsFileManager.size(true) + tsFileManager.size(false),
TsFileResourceManager.getInstance().getPriorityQueueSize());
}

@Test
Expand Down Expand Up @@ -340,6 +357,9 @@ public void testInsertionCompactionSchedule() throws IOException, InterruptedExc
TsFileResource targetFile2 = tsFileManager.getTsFileList(true).get(2);
timestamp = TsFileNameGenerator.getTsFileName(targetFile2.getTsFile().getName()).getTime();
Assert.assertEquals(6, timestamp);
Assert.assertEquals(
tsFileManager.size(true) + tsFileManager.size(false),
TsFileResourceManager.getInstance().getPriorityQueueSize());
}

@Test
Expand Down Expand Up @@ -378,6 +398,9 @@ public void testInsertionCompactionScheduleWithEmptySeqSpace()
TsFileResource targetFile3 = tsFileManager.getTsFileList(true).get(2);
timestamp = TsFileNameGenerator.getTsFileName(targetFile3.getTsFile().getName()).getTime();
Assert.assertEquals(4, timestamp);
Assert.assertEquals(
tsFileManager.size(true) + tsFileManager.size(false),
TsFileResourceManager.getInstance().getPriorityQueueSize());
}

@Test
Expand Down Expand Up @@ -423,6 +446,9 @@ public void testInsertionCompactionScheduleWithEmptySeqSpace2()
TsFileResource targetFile2 = tsFileManager.getTsFileList(true).get(1);
timestamp = TsFileNameGenerator.getTsFileName(targetFile2.getTsFile().getName()).getTime();
Assert.assertEquals(2, timestamp);
Assert.assertEquals(
tsFileManager.size(true) + tsFileManager.size(false),
TsFileResourceManager.getInstance().getPriorityQueueSize());
}

@Test
Expand Down Expand Up @@ -473,6 +499,9 @@ public void testInsertionCompactionScheduleWithMultiTimePartitions()
TsFileResource targetFile3 = tsFileManager.getOrCreateSequenceListByTimePartition(2808).get(0);
timestamp = TsFileNameGenerator.getTsFileName(targetFile3.getTsFile().getName()).getTime();
Assert.assertEquals(4, timestamp);
Assert.assertEquals(
tsFileManager.size(true) + tsFileManager.size(false),
TsFileResourceManager.getInstance().getPriorityQueueSize());
}

@Test
Expand Down Expand Up @@ -526,6 +555,9 @@ public void testInsertionCompactionUpdateFileMetrics() throws IOException {
Assert.assertEquals(seqFileNumBeforeCompaction, FileMetrics.getInstance().getFileCount(true));
Assert.assertEquals(
unseqFileNumBeforeCompaction, FileMetrics.getInstance().getFileCount(false));
Assert.assertEquals(
tsFileManager.size(true) + tsFileManager.size(false),
TsFileResourceManager.getInstance().getPriorityQueueSize());
}

public TsFileResource generateSingleNonAlignedSeriesFileWithDevices(
Expand Down
Loading