{"record":{"id":"a653874af56366af","repo":"apache/druid","slug":"asked-to-remove-data-segment-from-a-data-source-th","errorCode":null,"errorMessage":"Asked to remove data segment from a data source that doesn't exist!? server[%s], segment[%s]","messagePattern":"Asked to remove data segment from a data source 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":314,"sourceCode":"          currSize.addAndGet(newEffectiveSize - oldEffectiveSize);\n          updated[0] = true;\n          return dataSource;\n        }\n    );\n    return updated[0];\n  }\n\n  @Nullable\n  public DataSegment removeDataSegment(SegmentId segmentId)\n  {\n    // To pass result from inside the lambda.\n    DataSegment[] segmentRemoved = new DataSegment[1];\n    // ConcurrentHashMap.compute() ensures that all actions for specific dataSource are linearizable.\n    dataSources.compute(\n        segmentId.getDataSource(),\n        (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.","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/client/DruidServer.java#L296-L332","documentation":"DruidServer.removeDataSegment looks up the segment's dataSource in the dataSources map via ConcurrentHashMap.compute; if the data source is absent it logs this warning and returns no removed segment. It signals a removal event for a data source this server never tracked.","triggerScenarios":"removeDataSegment/removeSegment called with a SegmentId whose data source doesn't exist on this DruidServer (e.g. inventory events arriving out of order, or after the data source was emptied and evicted).","commonSituations":"Historical dropped the datasource before the view processed removal, coordinator replaying stale drop requests, reordered add/remove events during restart.","solutions":["Verify the datasource was announced to this server before removal events (check historical announce logs)","Confirm inventory event ordering; ensure HttpServerInventoryView sync completed before drops","Treat isolated occurrences as benign; persistent warnings suggest duplicated/stale event sources","Rebuild the view state by restarting coordinator/broker if accounting becomes inconsistent"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (server.getDataSource(segmentId.getDataSource()) == null) { log.info(\"datasource absent; skip removal\"); return; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Process segment adds before drops in event consumers","Avoid replaying stale coordinator drop requests","Verify inventory sync completed before issuing drops","Restart view holders if event ordering is suspected"],"tags":["cluster","segment-lifecycle","datasource"],"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"}