{"record":{"id":"2c782786bbf3fcab","repo":"apache/druid","slug":"failed-to-get-locks-for-intervals-s","errorCode":null,"errorMessage":"Failed to get locks for intervals[%s]","messagePattern":"Failed to get locks for intervals\\[(.+?)\\]","errorType":"exception","errorClass":"ISE","httpStatus":null,"severity":"error","filePath":"indexing-service/src/main/java/org/apache/druid/indexing/common/task/IndexTask.java","lineNumber":488,"sourceCode":"\n      // Initialize maxRowsPerSegment and maxTotalRows lazily\n      final IndexTuningConfig tuningConfig = ingestionSchema.tuningConfig;\n      final PartitionsSpec partitionsSpec = tuningConfig.getGivenOrDefaultPartitionsSpec();\n      final PartitionAnalysis partitionAnalysis = determineShardSpecs(\n          toolbox,\n          inputSource,\n          tmpDir,\n          partitionsSpec\n      );\n      final List<Interval> allocateIntervals = new ArrayList<>(partitionAnalysis.getAllIntervalsToIndex());\n      final DataSchema dataSchema;\n      if (determineIntervals) {\n        final boolean gotLocks = determineLockGranularityAndTryLock(\n            toolbox.getTaskActionClient(),\n            allocateIntervals\n        );\n        if (!gotLocks) {\n          throw new ISE(\"Failed to get locks for intervals[%s]\", allocateIntervals);\n        }\n\n        dataSchema = ingestionSchema.getDataSchema().withGranularitySpec(\n            ingestionSchema.getDataSchema()\n                           .getGranularitySpec()\n                           .withIntervals(JodaUtils.condenseIntervals(allocateIntervals))\n        );\n      } else {\n        dataSchema = ingestionSchema.getDataSchema();\n      }\n\n      ingestionState = IngestionState.BUILD_SEGMENTS;\n      return generateAndPublishSegments(\n          toolbox,\n          dataSchema,\n          inputSource,\n          tmpDir,\n          partitionAnalysis","sourceCodeStart":470,"sourceCodeEnd":506,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/indexing-service/src/main/java/org/apache/druid/indexing/common/task/IndexTask.java#L470-L506","documentation":"IndexTask.runTask, when intervals are being determined at run time (determineIntervals), attempts determineLockGranularityAndTryLock for the allocateIntervals and aborts with this ISE if the task could not obtain the necessary segment locks. Without locks the task cannot safely write segments for those intervals, so it fails immediately.","triggerScenarios":"Running an index task with appendToExisting/interval allocation while another task holds an overlapping time chunk lock, or segment allocation is configured such that intervals must be locked at run time and a competing task (e.g., a running supervisor's stream task or another batch task) already holds them.","commonSituations":"Overlapping batch tasks submitted for the same intervals; a Kafka/Kinesis supervisor holding locks for the same period; re-running a failed task while its locks were not yet released; lock priority too low to preempt the holder.","solutions":["Wait for the conflicting task to complete and release locks, then retry the index task","Cancel or kill the overlapping task holding the locks (GET /druid/indexer/v1/task then POST shutdown)","Increase the task's context \"taskLockType\"/priority or use exclusive/time-chunk locks as appropriate","Stagger interval allocation so concurrent tasks do not allocate the same intervals"],"exampleFix":"// before\n\"context\": { \"taskLockType\": \"append\" } // overlapping with a running task\n// after\n// first shut down the conflicting task, then submit:\n\"context\": { \"taskLockType\": \"replace\" }","handlingStrategy":"try-catch","validationCode":"Set<Interval> locked = overlord.getLockedIntervals();\nif (locked.stream().anyMatch(l -> l.overlaps(allocateIntervals))) {\n  waitOrAbort(); // don't submit task that will fail to acquire locks\n}","typeGuard":null,"tryCatchPattern":"try {\n  runIndexTask(spec);\n} catch (IllegalStateException e) {\n  if (e.getMessage().startsWith(\"Failed to get locks for intervals\")) {\n    // back off and retry after conflicting task finishes\n    Thread.sleep(backoffMillis);\n    runIndexTask(spec);\n  } else throw e;\n}","preventionTips":["Don't run overlapping batch tasks for the same intervals","Check active locks via /druid/indexer/v1/lockingEndpoint before submitting","Coordinate with supervisors holding stream locks","Use task priority/context to control lock acquisition"],"tags":["druid","ingestion","locking","concurrency"],"backgroundTag":"invalid-state-transition","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"}