{"record":{"id":"87f73b63b0090d11","repo":"apache/druid","slug":"some-locks-for-task-s-are-already-revoked","errorCode":null,"errorMessage":"Some locks for task[%s] are already revoked","messagePattern":"Some locks for task\\[(.+?)\\] are already revoked","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"indexing-service/src/main/java/org/apache/druid/indexing/common/actions/SegmentMetadataUpdateAction.java","lineNumber":80,"sourceCode":"  @Override\n  public Void perform(Task task, TaskActionToolbox toolbox)\n  {\n    TaskLocks.checkLockCoversSegments(task, toolbox.getTaskLockbox(), segments);\n\n    try {\n      toolbox.getTaskLockbox().doInCriticalSection(\n          task,\n          segments.stream().map(DataSegment::getInterval).collect(Collectors.toSet()),\n          CriticalAction.builder()\n                        .onValidLocks(\n                            () -> {\n                              toolbox.getIndexerMetadataStorageCoordinator().updateSegmentMetadata(segments);\n                              return null;\n                            }\n                        )\n                        .onInvalidLocks(\n                            () -> {\n                              throw new ISE(\"Some locks for task[%s] are already revoked\", task.getId());\n                            }\n                        )\n                        .build()\n      );\n    }\n    catch (Exception e) {\n      throw new RuntimeException(e);\n    }\n\n    // Emit metrics\n    final ServiceMetricEvent.Builder metricBuilder = new ServiceMetricEvent.Builder();\n    IndexTaskUtils.setTaskDimensions(metricBuilder, task);\n\n    for (DataSegment segment : segments) {\n      metricBuilder.setDimension(DruidMetrics.INTERVAL, segment.getInterval().toString());\n      toolbox.getEmitter().emit(metricBuilder.setMetric(\"segment/moved/bytes\", segment.getSize()));\n    }\n","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/indexing-service/src/main/java/org/apache/druid/indexing/common/actions/SegmentMetadataUpdateAction.java#L62-L98","documentation":"SegmentMetadataUpdateAction.perform() wraps metadata updates in a CriticalAction whose onInvalidLocks callback fires when the task's locks have been revoked (preempted by another task) before the update runs. Since updating segment metadata under invalid locks would corrupt state, Druid throws this ISE. The calling task is expected to fail and retry with fresh locks.","triggerScenarios":"A task calls SEGMENT_METADATA_UPDATE (e.g. during publish/cleanup) after another higher-priority task revoked its time-sharing locks for the overlapping intervals.","commonSituations":"Compaction/overwrite tasks preempting a still-running ingestion task; long-running tasks whose locks expired or were revoked mid-flight; manual kill/append tasks with higher priority overlapping the same interval.","solutions":["Let the task fail and retry; on retry it will reacquire valid locks.","Reschedule the higher-priority (compaction/overwrite) task to avoid overlapping the running task's intervals.","Check task lock dashboards/logs to identify which task revoked the locks and adjust lock priorities.","Reduce task runtimes so locks are used promptly after acquisition."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check lock validity before issuing the action where possible:\n// if (toolbox.getTaskLockbox().isLockRevokedOrMissing(task)) fail fast;","typeGuard":null,"tryCatchPattern":"try { result = action.perform(task, toolbox); } catch (ISE e) { if (e.getMessage().contains(\"already revoked\")) { /* task fails; retry with fresh locks */ } else throw e; }","preventionTips":["Schedule compaction so it does not preempt running ingestion tasks.","Use appropriate lock priorities for task types.","Keep the gap between lock acquisition and metadata update short.","Alert on revoked-lock messages in task logs."],"tags":["druid","locking","metadata-update","preemption"],"backgroundTag":"segment-lock-revoked","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"}