apache/druid · warning

Asked to remove data segment from a data source that…

Error message

Asked to remove data segment from a data source that doesn't exist!? server[%s], segment[%s]

What it means

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.

Solutions

  1. Verify the datasource was announced to this server before removal events (check historical announce logs)
  2. Confirm inventory event ordering; ensure HttpServerInventoryView sync completed before drops
  3. Treat isolated occurrences as benign; persistent warnings suggest duplicated/stale event sources
  4. Rebuild the view state by restarting coordinator/broker if accounting becomes inconsistent
Defensive patterns

Strategy: validation

Validate before calling

if (server.getDataSource(segmentId.getDataSource()) == null) { log.info("datasource absent; skip removal"); return; }

Prevention

When it happens

Trigger: 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).

Common situations: Historical dropped the datasource before the view processed removal, coordinator replaying stale drop requests, reordered add/remove events during restart.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/a653874af56366af. Report an issue: GitHub.

Appendix: source

Thrown at server/src/main/java/org/apache/druid/client/DruidServer.java:314

          currSize.addAndGet(newEffectiveSize - oldEffectiveSize);
          updated[0] = true;
          return dataSource;
        }
    );
    return updated[0];
  }

  @Nullable
  public DataSegment removeDataSegment(SegmentId segmentId)
  {
    // To pass result from inside the lambda.
    DataSegment[] segmentRemoved = new DataSegment[1];
    // ConcurrentHashMap.compute() ensures that all actions for specific dataSource are linearizable.
    dataSources.compute(
        segmentId.getDataSource(),
        (dataSourceName, dataSource) -> {
          if (dataSource == null) {
            log.warn(
                "Asked to remove data segment from a data source that doesn't exist!? server[%s], segment[%s]",
                getName(),
                segmentId
            );
            // Returning null from the lambda here makes the ConcurrentHashMap to not record any entry.
            return null;
          }
          DataSegment removed = dataSource.removeSegment(segmentId);
          if (removed != null) {
            segmentRemoved[0] = removed;
            // Use effectiveSizeOf (loadedBytes when the value is a DataSegmentAndLoadProfile, else segment size)
            // so the books balance against what we added.
            currSize.addAndGet(-DataSegmentAndLoadProfile.effectiveSizeOf(removed));
            totalSegments.decrementAndGet();
          } else {
            log.warn("Asked to remove data segment that doesn't exist!? server[%s], segment[%s]", getName(), segmentId);
          }
          // Returning null from the lambda here makes the ConcurrentHashMap to remove the current entry.

View on GitHub (pinned to 9b90983fd2)