apache/druid · error · ISE
No segments found for compaction. Please check that datasour
Error message
No segments found for compaction. Please check that datasource name and interval are correct.
What it means
CompactionTask's checkSegments validates that the segments currently returned by the coordinator for the requested datasource/interval are non-empty. If the interval resolves to no segments at all, this ISE is thrown. The library throws it because compaction has nothing to do and the most common cause is a wrong datasource name or interval in the spec.
Source
Thrown at indexing-service/src/main/java/org/apache/druid/indexing/common/task/CompactionTask.java:1402
}
List<DataSegment> findSegments(TaskActionClient actionClient) throws IOException
{
return new ArrayList<>(
actionClient.submit(
new RetrieveUsedSegmentsAction(
dataSource,
ImmutableList.of(interval),
EnumSet.of(SegmentDetail.LOAD_SPEC)
)
)
);
}
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. "
+ "Possibly new segments would have been added or some segments have been unpublished."
);
}
}
}
public static class Builder
{
private final String dataSource;
private final SegmentCacheManagerFactory segmentCacheManagerFactory;
@Nullable
private String id;
private CompactionIOConfig ioConfig;View on GitHub (pinned to 9b90983fd2)
Solutions
- Verify the datasource name against segments in the web console or GET /druid/coordinator/v1/datasources
- Verify the interval covers the segment metadata (check segment start/end dates)
- Query the coordinator for segment metadata of the interval before submitting the compaction spec
- Confirm retention rules did not drop the segments in that interval
Example fix
// before
"granularitySpec": { "interval": "2020-01-01/2020-02-01" } // no data there
// after
"granularitySpec": { "interval": "2022-01-01/2022-02-01" } // interval that contains segments Defensive patterns
Strategy: validation
Validate before calling
String ds = spec.getDataSource();
List<SegmentMeta> segs = coordinator.getDataSourceSegments(ds, interval);
if (segs.isEmpty()) throw new IllegalArgumentException("No segments for " + ds + " " + interval); Try / catch
try {
submitCompaction(spec);
} catch (IllegalStateException e) {
if (e.getMessage().startsWith("No segments found for compaction")) {
log.error("Check datasource {} and interval {} against coordinator metadata", spec.getDataSource(), spec.getInterval());
}
throw e;
} Prevention
- Verify datasource names via GET /druid/coordinator/v1/datasources before compaction
- Check actual segment intervals in the web console
- Beware timezone offsets when writing interval strings
- Confirm retention rules haven't dropped the data
When it happens
Trigger: Submitting a compaction spec (manual or automatic via the coordinator compaction config) whose dataSource has no segments, or whose interval covers a period with no data (wrong timezone/format, interval before data exists, datasource misspelled).
Common situations: Typo in the datasource name; interval given in the wrong timezone or with wrong granularity; data was killed/expired by retention rules before compaction ran; compaction of a brand new datasource before any ingestion completed.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- Failed to merge existing aggregators when generating metrics
- Failed to apply webClientOptions to WebClientOptions. Check
- S3StorageConfig cannot be null!
- Interval[%s] is empty, must specify a nonempty interval
- Conflicting segment granularities found %s(segmentGranularit
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/d7e1fe4ec9fc6ead.
Report an issue: GitHub.