{"record":{"id":"2e81716c682599f8","repo":"apache/druid","slug":"no-results-found-for-segments-s","errorCode":null,"errorMessage":"No results found for segments[%s]","messagePattern":"No results found for segments\\[(.+?)\\]","errorType":"exception","errorClass":"SegmentMissingException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/query/RetryQueryRunner.java","lineNumber":225,"sourceCode":"      this.sequence = baseSequence;\n    }\n\n    @Override\n    public boolean hasNext()\n    {\n      if (sequence != null) {\n        return true;\n      } else {\n        final QueryContext queryContext = queryPlus.getQuery().context();\n        final List<SegmentDescriptor> missingSegments = getMissingSegments(queryPlus, context);\n        final int maxNumRetries = queryContext.getNumRetriesOnMissingSegments(\n            config.getNumTries()\n        );\n        if (missingSegments.isEmpty()) {\n          return false;\n        } else if (retryCount >= maxNumRetries) {\n          if (!queryContext.allowReturnPartialResults(config.isReturnPartialResults())) {\n            throw new SegmentMissingException(\"No results found for segments[%s]\", missingSegments);\n          } else {\n            return false;\n          }\n        } else {\n          retryCount++;\n          LOG.info(\"[%,d] missing segments found. Retry attempt [%,d]\", missingSegments.size(), retryCount);\n\n          context.initializeMissingSegments();\n          final QueryPlus<T> retryQueryPlus = queryPlus.withQuery(\n              Queries.withSpecificSegments(queryPlus.getQuery(), missingSegments)\n          );\n          sequence = retryRunnerCreateFn.apply(retryQueryPlus.getQuery(), missingSegments).run(retryQueryPlus, context);\n          return true;\n        }\n      }\n    }\n\n    @Override","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/query/RetryQueryRunner.java#L207-L243","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Restore availability of the missing segments: fix/restart the down historical or wait for segment load.","Set 'returnPartialResults': true in the query context to get partial results instead of failure.","Increase retryCount/numTries in RetryQueryRunnerConfig so more retry attempts happen before failing.","Check Coordinator replication rules and segment availability status to see why segments are missing."],"exampleFix":"// before\n{\"queryType\":\"timeseries\", ...}\n// after\n{\"queryType\":\"timeseries\", ..., \"context\":{\"returnPartialResults\":true}}","handlingStrategy":"try-catch","validationCode":"// check segment availability before issuing the query:\n// GET /druid/coordinator/v1/datasources/{ds}/intervals?full\n// confirm all needed intervals are loaded on available servers","typeGuard":null,"tryCatchPattern":"try {\n  results = query.run();\n} catch (SegmentMissingException e) {\n  // segments unavailable: set context returnPartialResults=true or resubmit later\n}","preventionTips":["Set context {\"returnPartialResults\": true} for tolerant queries","Ensure adequate replication for datasources","Increase RetryQueryRunnerConfig.numTries for slower-loading clusters","Wait for recently-ingested segments to be announced before querying"],"tags":["segments","availability","query"],"backgroundTag":"segment-availability-timeout","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"}