{"record":{"id":"24cb7884b23cb334","repo":"apache/druid","slug":"couldn-t-delete-segments-from-azure-see-the-task","errorCode":null,"errorMessage":"Couldn't delete segments from Azure. See the task logs for more details.","messagePattern":"Couldn't delete segments from Azure\\. See the task logs for more details\\.","errorType":"exception","errorClass":"SegmentLoadingException","httpStatus":null,"severity":"error","filePath":"extensions-core/azure-extensions/src/main/java/org/apache/druid/storage/azure/AzureDataSegmentKiller.java","lineNumber":107,"sourceCode":"      );\n      keysToDelete.add(blobPath);\n    }\n\n    boolean shouldThrowException = false;\n    for (Map.Entry<String, List<String>> containerToKeys : containerToKeysToDelete.entrySet()) {\n      boolean batchSuccessful = azureStorage.batchDeleteFiles(\n              containerToKeys.getKey(),\n              containerToKeys.getValue(),\n              null\n      );\n\n      if (!batchSuccessful) {\n        shouldThrowException = true;\n      }\n    }\n\n    if (shouldThrowException) {\n      throw new SegmentLoadingException(\n          \"Couldn't delete segments from Azure. See the task logs for more details.\"\n      );\n    }\n  }\n\n\n  @Override\n  public void kill(DataSegment segment) throws SegmentLoadingException\n  {\n    log.info(\"Killing segment [%s]\", segment);\n\n    Map<String, Object> loadSpec = segment.getLoadSpec();\n    final String containerName = MapUtils.getString(loadSpec, \"containerName\");\n    final String blobPath = MapUtils.getString(loadSpec, \"blobPath\");\n    final String dirPath = Paths.get(blobPath).getParent().toString();\n\n    try {\n      azureStorage.emptyCloudBlobDirectory(containerName, dirPath);","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/azure-extensions/src/main/java/org/apache/druid/storage/azure/AzureDataSegmentKiller.java#L89-L125","documentation":"AzureDataSegmentKiller.kill aggregates per-batch segment deletions; if any batch or individual delete failed (batchSuccessful false or an exception was caught), it throws this generic SegmentLoadingException pointing the operator at task logs. The actual per-segment failure reason is logged, not carried in this exception.","triggerScenarios":"kill() or killBatch() fails to delete one or more segment blobs: emptyCloudBlobDirectory or deleteBlob throws (BlobStorageException, missing blob directory, permissions), or a batch reports partial failure.","commonSituations":"Killing segments whose files were already deleted (concurrent kill), storage account key lacking delete permission, or transient Azure 412/409 conflicts during batch kills.","solutions":["Inspect the task/service logs for the per-segment BlobStorageException logged before this throw","Re-run the kill; failures are often transient or caused by already-deleted segments","Verify the Azure credentials have delete (blob write) permissions on the container","Check no concurrent kill tasks operate on the same segments"],"exampleFix":"// before\nif (shouldThrowException) {\n  throw new SegmentLoadingException(\"Couldn't delete segments from Azure. See the task logs for more details.\");\n}\n// after\nif (shouldThrowException) {\n  throw new SegmentLoadingException(null, \"Couldn't delete segments from Azure; last error: %s\", lastErrorMessage);\n}","handlingStrategy":"try-catch","validationCode":"// verify permissions up front\nboolean canDelete = testDeletePermission(container, prefix); // list + attempt small delete with a probe blob","typeGuard":null,"tryCatchPattern":"try { killer.kill(segment); } catch (SegmentLoadingException e) { log.error(\"Azure kill failed, see cause logs: %s\", e.getMessage()); /* retry later or alert */ }","preventionTips":["Grant delete permissions on the container to the Druid storage account","Avoid concurrent kill tasks on the same segments","Enable idempotent retry of kills; deletes are safe to re-run","Check task logs immediately — this exception deliberately omits the root cause"],"tags":["azure","segment-deletion","deep-storage"],"backgroundTag":"http-error-response","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"}