apache/druid · error · SegmentMissingException

No results found for segments

Error message

No results found for segments[%s]

What it means

RetryQueryRunner's Sequence iterator retries queries when servers report missing segments. If after exhausting maxNumRetries segments are still missing and the query context does not allow partial results, hasNext() throws SegmentMissingException 'No results found for segments[...]'. This surfaces to the client as a query failure indicating some segments could not be served.

Solutions

  1. Restore availability of the missing segments: fix/restart the down historical or wait for segment load.
  2. Set 'returnPartialResults': true in the query context to get partial results instead of failure.
  3. Increase retryCount/numTries in RetryQueryRunnerConfig so more retry attempts happen before failing.
  4. Check Coordinator replication rules and segment availability status to see why segments are missing.

Example fix

// before
{"queryType":"timeseries", ...}
// after
{"queryType":"timeseries", ..., "context":{"returnPartialResults":true}}
Defensive patterns

Strategy: try-catch

Validate before calling

// check segment availability before issuing the query:
// GET /druid/coordinator/v1/datasources/{ds}/intervals?full
// confirm all needed intervals are loaded on available servers

Try / catch

try {
  results = query.run();
} catch (SegmentMissingException e) {
  // segments unavailable: set context returnPartialResults=true or resubmit later
}

Prevention

When it happens

Trigger: Missing segments (e.g., a historical that should serve them is down, segments not loaded within 'awaitSegmentAvailability' window, or segments genuinely absent) persisting past config.getNumTries() retries with returnPartialResults not enabled in the query context.

Common situations: Under-replicated cluster with a dead historical; recently submitted segments not yet loaded; druid.segment.loading.numTries exhausted during quick restarts; real-time data with unavailable realtime servers.

Related errors


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

Appendix: source

Thrown at server/src/main/java/org/apache/druid/query/RetryQueryRunner.java:225

      this.sequence = baseSequence;
    }

    @Override
    public boolean hasNext()
    {
      if (sequence != null) {
        return true;
      } else {
        final QueryContext queryContext = queryPlus.getQuery().context();
        final List<SegmentDescriptor> missingSegments = getMissingSegments(queryPlus, context);
        final int maxNumRetries = queryContext.getNumRetriesOnMissingSegments(
            config.getNumTries()
        );
        if (missingSegments.isEmpty()) {
          return false;
        } else if (retryCount >= maxNumRetries) {
          if (!queryContext.allowReturnPartialResults(config.isReturnPartialResults())) {
            throw new SegmentMissingException("No results found for segments[%s]", missingSegments);
          } else {
            return false;
          }
        } else {
          retryCount++;
          LOG.info("[%,d] missing segments found. Retry attempt [%,d]", missingSegments.size(), retryCount);

          context.initializeMissingSegments();
          final QueryPlus<T> retryQueryPlus = queryPlus.withQuery(
              Queries.withSpecificSegments(queryPlus.getQuery(), missingSegments)
          );
          sequence = retryRunnerCreateFn.apply(retryQueryPlus.getQuery(), missingSegments).run(retryQueryPlus, context);
          return true;
        }
      }
    }

    @Override

View on GitHub (pinned to 9b90983fd2)