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

The time range of device in resource file may be larger than the actual time range in tsfile #14712

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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 @@ -187,9 +187,8 @@ private void checkAlignedDeviceSeries(
new TimeRange(
timeseriesMetadata.getStatistics().getStartTime(),
timeseriesMetadata.getStatistics().getEndTime());
if (checkTsFileResource && !timeseriesTimeRange.equals(deviceTimeRangeInResource)) {
throw new CompactionStatisticsCheckFailedException(
device, deviceTimeRangeInResource, timeseriesTimeRange);
if (checkTsFileResource) {
compareDeviceTimeRange(device, deviceTimeRangeInResource, timeseriesTimeRange);
}

long actualTimeseriesStartTime = Long.MAX_VALUE;
Expand Down Expand Up @@ -283,10 +282,27 @@ private void checkNonAlignedDeviceSeries(
if (!checkTsFileResource || actualDeviceStartTime > actualDeviceEndTime) {
return;
}
TimeRange actualDeviceTimeRange = new TimeRange(actualDeviceStartTime, actualDeviceEndTime);
if (!actualDeviceTimeRange.equals(deviceTimeRangeInResource)) {
throw new CompactionStatisticsCheckFailedException(
device, deviceTimeRangeInResource, actualDeviceTimeRange);
compareDeviceTimeRange(
device,
deviceTimeRangeInResource,
new TimeRange(actualDeviceStartTime, actualDeviceEndTime));
}

private void compareDeviceTimeRange(
IDeviceID device, TimeRange deviceTimeRangeInResource, TimeRange actualDeviceTimeRange) {
long innerCompactionCount = resource.getTsFileID().getInnerCompactionCount();
if (innerCompactionCount == 0) {
// for the files generate by flush with deletions, the statistics may be larger than the
// actual
if (!deviceTimeRangeInResource.contains(actualDeviceTimeRange)) {
throw new CompactionStatisticsCheckFailedException(
device, deviceTimeRangeInResource, actualDeviceTimeRange);
}
} else {
if (!actualDeviceTimeRange.equals(deviceTimeRangeInResource)) {
throw new CompactionStatisticsCheckFailedException(
device, deviceTimeRangeInResource, actualDeviceTimeRange);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void testWrongChunkStatisticsWithAlignedSeries() throws IOException {

@Test
public void testWrongResourceStatistics() throws IOException {
TsFileResource resource = createEmptyFileAndResource(true);
TsFileResource resource = createEmptyFileAndResourceWithName("1-1-1-0", 0, true);
try (CompactionTestFileWriter writer = new CompactionTestFileWriter(resource)) {
writer.startChunkGroup("d1");
writer.generateSimpleAlignedSeriesToCurrentDeviceWithNullValue(
Expand Down
Loading