{"record":{"id":"e891ab781c4bead9","repo":"apache/druid","slug":"failed-to-delete-pending-segments-for-datasource","errorCode":null,"errorMessage":"Failed to delete pending segments for datasource[%s] and interval[%s].","messagePattern":"Failed to delete pending segments for datasource\\[(.+?)\\] and interval\\[(.+?)\\]\\.","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/OverlordResource.java","lineNumber":680,"sourceCode":"        authorizerMapper\n    );\n\n    if (!authResult.allowAccessWithNoRestriction()) {\n      throw new ForbiddenException(authResult.getErrorMessage());\n    }\n\n    if (overlord.isLeader()) {\n      try {\n        final int numDeleted = indexerMetadataStorageAdapter.deletePendingSegments(dataSource, deleteInterval);\n        return Response.ok().entity(ImmutableMap.of(\"numDeleted\", numDeleted)).build();\n      }\n      catch (DruidException e) {\n        return Response.status(e.getStatusCode())\n                       .entity(ImmutableMap.<String, Object>of(\"error\", e.getMessage()))\n                       .build();\n      }\n      catch (Exception e) {\n        log.warn(\n            e,\n            \"Failed to delete pending segments for datasource[%s] and interval[%s].\",\n            dataSource,\n            deleteInterval\n        );\n        return Response.status(Status.INTERNAL_SERVER_ERROR)\n                       .entity(ImmutableMap.<String, Object>of(\"error\", e.getMessage()))\n                       .build();\n      }\n    } else {\n      return Response.status(Status.SERVICE_UNAVAILABLE)\n                     .entity(ImmutableMap.of(\"error\", \"overlord is not the leader or not initialized yet\"))\n                     .build();\n    }\n  }\n\n  @GET\n  @Path(\"/workers\")","sourceCodeStart":662,"sourceCodeEnd":698,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/OverlordResource.java#L662-L698","documentation":"The Overlord REST endpoint for killing pending segments (DELETE /druid/indexer/v1/pendingSegments) failed with a non-DruidException error while deleting pending segments for the given datasource and interval. The server logs the exception and returns HTTP 500.","triggerScenarios":"POST/DELETE to the pendingSegments kill endpoint when the underlying metadata storage delete (via IndexerMetadataStorageCoordinator.deletePendingSegments) throws a generic Exception.","commonSituations":"Metadata store (e.g. MySQL/PostgreSQL) connectivity problems; lock contention or timeout acquiring datasource/interval locks; datasource metadata not initialized; transient DB errors.","solutions":["Check the Overlord log for the full stack trace above this warning","Verify metadata storage connectivity and health (connection pools, DB availability)","Retry the kill call; ensure the coordinator can acquire segment locks for the interval","Confirm the datasource exists and pending segments are stored in the configured metadata store"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Pre-check datasource exists before calling kill pending segments\n// GET /druid/indexer/v1/datasources/{ds} returns 200","typeGuard":null,"tryCatchPattern":"try { killPendingSegments(ds, interval); } catch (WebApplicationException e) { if (e.getResponse().getStatus() == 500) { /* retry with backoff after checking metadata store health */ } }","preventionTips":["Verify metadata store connectivity before kill operations","Avoid killing pending segments during lock contention windows","Retry transient 500s with exponential backoff"],"tags":["rest-api","metadata-store","pending-segments"],"backgroundTag":"database-write-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}