{"record":{"id":"d7e1fe4ec9fc6ead","repo":"apache/druid","slug":"no-segments-found-for-compaction-please-check-tha","errorCode":null,"errorMessage":"No segments found for compaction. Please check that datasource name and interval are correct.","messagePattern":"No segments found for compaction\\. Please check that datasource name and interval are correct\\.","errorType":"exception","errorClass":"ISE","httpStatus":null,"severity":"error","filePath":"indexing-service/src/main/java/org/apache/druid/indexing/common/task/CompactionTask.java","lineNumber":1402,"sourceCode":"    }\n\n    List<DataSegment> findSegments(TaskActionClient actionClient) throws IOException\n    {\n      return new ArrayList<>(\n          actionClient.submit(\n              new RetrieveUsedSegmentsAction(\n                  dataSource,\n                  ImmutableList.of(interval),\n                  EnumSet.of(SegmentDetail.LOAD_SPEC)\n              )\n          )\n      );\n    }\n\n    void checkSegments(LockGranularity lockGranularityInUse, List<DataSegment> latestSegments)\n    {\n      if (latestSegments.isEmpty()) {\n        throw new ISE(\"No segments found for compaction. Please check that datasource name and interval are correct.\");\n      }\n      if (!inputSpec.validateSegments(lockGranularityInUse, latestSegments)) {\n        throw new ISE(\n            \"Specified segments in the spec are different from the current used segments. \"\n            + \"Possibly new segments would have been added or some segments have been unpublished.\"\n        );\n      }\n    }\n  }\n\n  public static class Builder\n  {\n    private final String dataSource;\n    private final SegmentCacheManagerFactory segmentCacheManagerFactory;\n\n    @Nullable\n    private String id;\n    private CompactionIOConfig ioConfig;","sourceCodeStart":1384,"sourceCodeEnd":1420,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/indexing-service/src/main/java/org/apache/druid/indexing/common/task/CompactionTask.java#L1384-L1420","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\n\"granularitySpec\": { \"interval\": \"2020-01-01/2020-02-01\" } // no data there\n// after\n\"granularitySpec\": { \"interval\": \"2022-01-01/2022-02-01\" } // interval that contains segments","handlingStrategy":"validation","validationCode":"String ds = spec.getDataSource();\nList<SegmentMeta> segs = coordinator.getDataSourceSegments(ds, interval);\nif (segs.isEmpty()) throw new IllegalArgumentException(\"No segments for \" + ds + \" \" + interval);","typeGuard":null,"tryCatchPattern":"try {\n  submitCompaction(spec);\n} catch (IllegalStateException e) {\n  if (e.getMessage().startsWith(\"No segments found for compaction\")) {\n    log.error(\"Check datasource {} and interval {} against coordinator metadata\", spec.getDataSource(), spec.getInterval());\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["druid","compaction","configuration","no-data"],"backgroundTag":"empty-result-set","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}