Better error message for compaction task when it sees no segments for compaction (#10728)

This commit is contained in:
Jihoon Son 2021-01-05 16:49:57 -08:00 committed by GitHub
parent 769c21cc87
commit ea2d51d61f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -832,6 +832,9 @@ public class CompactionTask extends AbstractBatchIndexTask
void checkSegments(LockGranularity lockGranularityInUse, List<DataSegment> latestSegments)
{
if (latestSegments.isEmpty()) {
throw new ISE("No segments found for compaction. Please check that datasource name and interval are correct.");
}
if (!inputSpec.validateSegments(lockGranularityInUse, latestSegments)) {
throw new ISE(
"Specified segments in the spec are different from the current used segments. "

View File

@ -546,6 +546,21 @@ public class CompactionTaskTest
Assert.assertEquals(expected.getContext(), actual.getContext());
}
@Test
public void testSegmentProviderFindSegmentsWithEmptySegmentsThrowException()
{
final SegmentProvider provider = new SegmentProvider(
"datasource",
new CompactionIntervalSpec(Intervals.of("2021-01-01/P1D"), null)
);
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage(
"No segments found for compaction. Please check that datasource name and interval are correct."
);
provider.checkSegments(LockGranularity.TIME_CHUNK, ImmutableList.of());
}
@Test
public void testCreateIngestionSchema() throws IOException, SegmentLoadingException
{