{"record":{"id":"c0194ee9bed579b1","repo":"apache/druid","slug":"interval-s-to-compact-is-not-aligned-with-segmen","errorCode":null,"errorMessage":"Interval[%s] to compact is not aligned with segmentGranularity[%s]","messagePattern":"Interval\\[(.+?)\\] to compact is not aligned with segmentGranularity\\[(.+?)\\]","errorType":"exception","errorClass":"IAE","httpStatus":null,"severity":"error","filePath":"indexing-service/src/main/java/org/apache/druid/indexing/common/task/NativeCompactionRunner.java","lineNumber":194,"sourceCode":"\n  private static ParallelIndexIOConfig createMajorCompactionIoConfig(\n      TaskToolbox toolbox,\n      DataSchema dataSchema,\n      Interval inputInterval,\n      CoordinatorClient coordinatorClient,\n      SegmentCacheManagerFactory segmentCacheManagerFactory,\n      CompactionIOConfig compactionIOConfig\n  )\n  {\n    if (!compactionIOConfig.isAllowNonAlignedInterval()) {\n      final Granularity segmentGranularity = dataSchema.getGranularitySpec().getSegmentGranularity();\n      final Interval widenedInterval = Intervals.utc(\n          segmentGranularity.bucketStart(inputInterval.getStart()).getMillis(),\n          segmentGranularity.bucketEnd(inputInterval.getEnd().minus(1)).getMillis()\n      );\n\n      if (!inputInterval.equals(widenedInterval)) {\n        throw new IAE(\n            \"Interval[%s] to compact is not aligned with segmentGranularity[%s]\",\n            inputInterval,\n            segmentGranularity\n        );\n      }\n    }\n\n    return new ParallelIndexIOConfig(\n        new DruidInputSource(\n            dataSchema.getDataSource(),\n            inputInterval,\n            null,\n            null,\n            null,\n            null,\n            toolbox.getIndexIO(),\n            coordinatorClient,\n            segmentCacheManagerFactory,","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/indexing-service/src/main/java/org/apache/druid/indexing/common/task/NativeCompactionRunner.java#L176-L212","documentation":"Major compaction requires the compaction interval to align exactly to segmentGranularity buckets: the interval start must be a bucket start and the end must be a bucket end. If the user-supplied interval doesn't equal the widened bucket-aligned interval, createMajorCompactionIoConfig throws IAE.","triggerScenarios":"Submitting a compaction task (native runner) whose inputInterval is not bucket-aligned with the configured segmentGranularity — e.g. interval 2024-01-01T05/2024-01-02 with day granularity.","commonSituations":"Manually typed compaction intervals not snapped to midnight; auto-compaction configs with partial-day intervals after changing segmentGranularity; DST/timezone offsets making an interval appear misaligned.","solutions":["Adjust the compaction interval to bucket boundaries, e.g. Intervals.utc(bucketStart, bucketEnd) via Granularity.bucketStart/bucketEnd","Compute the interval from the target segments' actual min/max times then align it with segmentGranularity","If alignment isn't possible, lower segmentGranularity for that compaction to match the interval"],"exampleFix":"// before\nIntervals.of(\"2024-01-01T05:00:00/2024-01-02\")  // with segmentGranularity=day\n// after\nIntervals.of(\"2024-01-01/2024-01-02\")","handlingStrategy":"validation","validationCode":"Interval aligned = Intervals.utc(\n  segmentGranularity.bucketStart(input.getStart()).getMillis(),\n  segmentGranularity.bucketEnd(input.getEnd().minus(1)).getMillis());\nif (!input.equals(aligned)) { input = aligned; }","typeGuard":null,"tryCatchPattern":"try { submitCompaction(cfg); } catch (IAE e) { if (e.getMessage().contains(\"not aligned with segmentGranularity\")) { submitCompaction(withAlignedInterval(cfg)); } else { throw e; } }","preventionTips":["Always derive compaction intervals with bucketStart/bucketEnd for the chosen granularity","Review compaction configs after changing segmentGranularity","Watch for timezone/DST-induced misalignment in hand-written intervals"],"tags":["druid","compaction","intervals","validation"],"backgroundTag":"invalid-argument-value","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"}