apache/druid · error · IllegalStateException

Stage[%d] output partitions not available

Error message

Stage[%d] output partitions not available

What it means

StageInputSpecSlicer.sliceStatic reads a map from stage number to that stage's ReadablePartitions. When the map has no entry for the requested stage, the stage's output partition info is not yet available (or never recorded), and this ISE is thrown.

Source

Thrown at multi-stage-query/src/main/java/org/apache/druid/msq/input/stage/StageInputSpecSlicer.java:69

    this.stageOutputChannelModeMap = stageOutputChannelModeMap;
  }

  @Override
  public boolean canSliceDynamic(InputSpec inputSpec)
  {
    return false;
  }

  @Override
  public List<InputSlice> sliceStatic(InputSpec inputSpec, @Nullable SegmentPruner segmentPruner, int maxNumSlices)
  {
    final StageInputSpec stageInputSpec = (StageInputSpec) inputSpec;

    final ReadablePartitions stagePartitions = stagePartitionsMap.get(stageInputSpec.getStageNumber());
    final OutputChannelMode outputChannelMode = stageOutputChannelModeMap.get(stageInputSpec.getStageNumber());

    if (stagePartitions == null) {
      throw new ISE("Stage[%d] output partitions not available", stageInputSpec.getStageNumber());
    }

    if (outputChannelMode == null) {
      throw new ISE("Stage[%d] output mode not available", stageInputSpec.getStageNumber());
    }

    // Decide how many workers to use, and assign inputs.
    final List<ReadablePartitions> workerPartitions = stagePartitions.split(maxNumSlices);
    final List<InputSlice> retVal = new ArrayList<>();

    for (final ReadablePartitions partitions : workerPartitions) {
      retVal.add(
          new StageInputSlice(
              stageInputSpec.getStageNumber(),
              partitions,
              outputChannelMode
          )
      );

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Confirm the referenced stage number exists in the query's stage DAG and that its output is generated before slicing.
  2. Check the WorkerStagePhases/counter map construction to ensure every consuming stage has a producer entry.
  3. If this appears intermittently during query execution, collect controller logs and file a Druid MSQ bug - it indicates a kernel sequencing bug.

Example fix

// before: slicing inputs before producer stage counters are known
slicer.sliceStatic(inputSpec, maxSlices); // map lacks stage 2
// after: only slice stage inputs once producer stage output is published
if (stagePartitionsMap.containsKey(stageNumber)) {
  slicer.sliceStatic(inputSpec, maxSlices);
}
Defensive patterns

Strategy: validation

Validate before calling

if (!stagePartitionsMap.containsKey(stageNumber)) {
  throw new IllegalStateException("Producer stage " + stageNumber + " output not available yet");
}
slicer.sliceStatic(inputSpec, maxSlices);

Try / catch

try {
  slicer.sliceStatic(inputSpec, maxSlices);
} catch (IllegalStateException e) {
  if (e.getMessage() != null && e.getMessage().contains("output partitions not available")) {
    log.error(e, "Stage output missing; check kernel stage ordering");
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: sliceStatic on a StageInputSpec referencing stageNumber N where stagePartitionsMap.get(N) returns null - the upstream stage hasn't finished/published output, or the slicer was built without info for that stage.

Common situations: Query kernel bugs where a stage's inputs are sliced before the producer stage completes; incorrect stage numbering after DAG construction changes; attempting to slice a stage that reads from itself or a not-yet-created stage.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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