{"record":{"id":"9b57d5e7f01e00e0","repo":"apache/druid","slug":"could-not-retrieve-parent-segment-ids-using-task-a","errorCode":null,"errorMessage":"Could not retrieve parent segment ids using task action[retrieveUpgradedFromSegmentIds]. Stopping kill task to avoid data loss in case the segment files are shared by other segments.","messagePattern":"Could not retrieve parent segment ids using task action\\[retrieveUpgradedFromSegmentIds\\]\\. Stopping kill task to avoid data loss in case the segment files are shared by other segments\\.","errorType":"exception","errorClass":"ISE","httpStatus":null,"severity":"error","filePath":"indexing-service/src/main/java/org/apache/druid/indexing/common/task/KillUnusedSegmentsTask.java","lineNumber":418,"sourceCode":"   * it does not have an entry in the map.\n   */\n  protected Map<String, String> fetchParentIdsForSegments(\n      TaskToolbox toolbox,\n      Map<String, DataSegmentPlus> unusedIdToSegmentPlus\n  )\n  {\n    try {\n      return toolbox.getTaskActionClient().submit(\n          new RetrieveUpgradedFromSegmentIdsAction(getDataSource(), unusedIdToSegmentPlus.keySet())\n      ).getUpgradedFromSegmentIds();\n    }\n    catch (Exception e) {\n      // Do not proceed with killing these segments as we cannot be sure if their\n      // load spec is shared by any other segment or not. If load spec is shared,\n      // segment files cannot be deleted from deep store. If load spec is not\n      // shared, segments cannot be deleted from metadata store as that would\n      // leave deep store files orphaned, and they would never be cleaned up.\n      throw new ISE(\n          e,\n          \"Could not retrieve parent segment ids using task action[retrieveUpgradedFromSegmentIds].\"\n          + \" Stopping kill task to avoid data loss in case the segment files\"\n          + \" are shared by other segments.\"\n      );\n    }\n  }\n\n  /**\n   * Logs the given info message. Exposed here to allow embedded kill tasks to\n   * suppress info logs.\n   */\n  protected void logInfo(String message, Object... args)\n  {\n    LOG.info(message, args);\n  }\n\n  private NavigableMap<DateTime, List<TaskLock>> getNonRevokedTaskLockMap(TaskActionClient client) throws IOException","sourceCodeStart":400,"sourceCodeEnd":436,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/indexing-service/src/main/java/org/apache/druid/indexing/common/task/KillUnusedSegmentsTask.java#L400-L436","documentation":"Before killing segments from deep storage, the task must know each segment's parent (upgraded-from) segment IDs via the retrieveUpgradedFromSegmentIds task action, because replacement segments can share load specs/files. If the action call fails for any reason, the kill aborts deliberately to avoid deleting files still referenced by other segments.","triggerScenarios":"The retrieveUpgradedFromSegmentIds task action throws — metadata store outage, action client failure, timeout talking to the coordinator/overlord, or schema/serialization issues — while fetchParentIdsForSegments prepares the kill set.","commonSituations":"Metadata store (MySQL/PostgreSQL) temporarily down or saturated; network partition between middle manager and overlord during kill; very large kill sets making the action slow and timing out.","solutions":["Check metadata store connectivity/health and retry the kill task once the DB is reachable","Split the kill into smaller intervals/batches to reduce action payload and timeout risk","Inspect the underlying cause exception (attached to this ISE) and fix that failure first"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// pre-check metadata store reachability before submitting kill\ndbHealth = dataSource.getConnection().isValid(5);","typeGuard":null,"tryCatchPattern":"try { killTask.submit(); } catch (ISE e) { if (e.getMessage().contains(\"retrieveUpgradedFromSegmentIds\")) { scheduleRetryWithBackoff(e.getCause()); } else { throw e; } }","preventionTips":["Monitor metadata store health before running kill jobs","Split kills into smaller interval batches","Always read the attached cause exception to fix the root failure first"],"tags":["druid","kill-task","metadata-store","safety"],"backgroundTag":"database-query-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"}