{"record":{"id":"d4db14c454db8760","repo":"apache/druid","slug":"asked-to-remove-data-segment-that-doesn-t-exist","errorCode":null,"errorMessage":"Asked to remove data segment that doesn't exist!? server[%s], segment[%s]","messagePattern":"Asked to remove data segment that doesn't exist!\\? server\\[(.+?)\\], segment\\[(.+?)\\]","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/src/main/java/org/apache/druid/client/DruidServer.java","lineNumber":330,"sourceCode":"        (dataSourceName, dataSource) -> {\n          if (dataSource == null) {\n            log.warn(\n                \"Asked to remove data segment from a data source that doesn't exist!? server[%s], segment[%s]\",\n                getName(),\n                segmentId\n            );\n            // Returning null from the lambda here makes the ConcurrentHashMap to not record any entry.\n            return null;\n          }\n          DataSegment removed = dataSource.removeSegment(segmentId);\n          if (removed != null) {\n            segmentRemoved[0] = removed;\n            // Use effectiveSizeOf (loadedBytes when the value is a DataSegmentAndLoadProfile, else segment size)\n            // so the books balance against what we added.\n            currSize.addAndGet(-DataSegmentAndLoadProfile.effectiveSizeOf(removed));\n            totalSegments.decrementAndGet();\n          } else {\n            log.warn(\"Asked to remove data segment that doesn't exist!? server[%s], segment[%s]\", getName(), segmentId);\n          }\n          // Returning null from the lambda here makes the ConcurrentHashMap to remove the current entry.\n          return dataSource.isEmpty() ? null : dataSource;\n        }\n    );\n    return segmentRemoved[0];\n  }\n\n  public DruidDataSource getDataSource(String dataSource)\n  {\n    return dataSources.get(dataSource);\n  }\n\n  public Collection<DruidDataSource> getDataSources()\n  {\n    return dataSources.values();\n  }\n","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/client/DruidServer.java#L312-L348","documentation":"In removeDataSegment, when the data source exists but contains no segment matching the given id, dataSource.removeSegment returns null and this warning is logged; currSize/totalSegments are left untouched. Removal is a no-op and the returned removed segment is null.","triggerScenarios":"removeSegment called with a segment id not present in that DruidServer's data source — duplicate removal, or removal before the add was processed.","commonSituations":"Race between segment load and drop, duplicated unannounce events, coordinator retrying a drop the view already handled.","solutions":["Check for duplicate segmentRemove events in coordinator/inventory logs","Ensure the segment's add event completed (announced and synced) before its removal","Ignore one-off warnings after historical restarts; investigate repeats for the same segment id","If size accounting looks wrong, restart the view process to rebuild from a full server inventory sync"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (server.getSegment(segmentId) == null) { log.info(\"segment absent; skip removal\"); return null; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Deduplicate removal events by segment id","Confirm segment announcement before drop","Treat post-restart warnings as transient noise","Reconcile totalSegments periodically"],"tags":["cluster","segment-lifecycle","duplicate-event"],"backgroundTag":"record-not-found","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"}