risingwavelabs/risingwave · error · StreamExecutorError

iceberg pk-index writer {} expected matching {:?} context fo

Error message

iceberg pk-index writer {} expected matching {:?} context for task {}, got {:?}

What it means

When a compaction barrier arrives, the writer checks its embedded iceberg_pk_index_compaction context matches the current sink_id, task_id, and expected phase. This error means the context belongs to a different phase, task, or sink, so the writer cannot apply the barrier to its current compaction state machine.

Source

Thrown at src/stream/src/executor/iceberg_with_pk_index/writer.rs:332

    ) -> StreamExecutorResult<()> {
        if !barrier.is_checkpoint() || barrier.epoch.prev != expected_prev {
            bail!(
                "iceberg pk-index writer {} expected checkpoint {:?} starting at {}, got {:?}",
                self.sink_id,
                expected_phase,
                expected_prev,
                barrier
            );
        }
        match barrier.iceberg_pk_index_compaction() {
            Some(context)
                if context.sink_id == self.sink_id
                    && context.task_id == expected_task
                    && context.phase == expected_phase as i32 =>
            {
                Ok(())
            }
            _ => bail!(
                "iceberg pk-index writer {} expected matching {:?} context for task {}, got {:?}",
                self.sink_id,
                expected_phase,
                expected_task,
                barrier
            ),
        }
    }

    fn validate_aligned_barriers(
        &self,
        left: &Barrier,
        right: &Barrier,
    ) -> StreamExecutorResult<()> {
        if left.epoch != right.epoch || left.kind != right.kind || left.mutation != right.mutation {
            bail!(
                "iceberg pk-index writer {} received mismatched left/right barriers: left={:?}, right={:?}",
                self.sink_id,

View on GitHub (pinned to 6469eb736d)

Solutions

  1. Log the barrier's context (sink_id, task_id, phase) and compare with expected values to identify the mismatch kind.
  2. Restart from the last checkpoint to clear stale compaction task state.
  3. Check meta's compaction task assignment for duplicate or stale task ids.
  4. Ensure recovery doesn't reuse pre-restart compaction task ids.
  5. Report to maintainers with the context dump if it recurs on healthy clusters.
Defensive patterns

Strategy: validation

Validate before calling

// verify the barrier's compaction context before feeding it to the writer
if let Some(ctx) = barrier.iceberg_pk_index_compaction() {
    assert_eq!(ctx.sink_id, writer.sink_id);
    assert_eq!(ctx.task_id, expected_task);
}

Type guard

fn context_matches(barrier: &Barrier, sink_id: u32, task: IcebergCompactionTaskId, phase: Phase) -> bool {
    matches!(barrier.iceberg_pk_index_compaction(),
        Some(ctx) if ctx.sink_id == sink_id && ctx.task_id == task && ctx.phase == phase as i32)
}

Try / catch

match writer.execute_resolving_right(msg).await {
    Err(e) if e.to_string().contains("expected matching") => {
        error!("compaction context mismatch; restart fragment from checkpoint");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Raised in validate_compaction_barrier when the barrier's context fails the check context.sink_id == self.sink_id && context.task_id == expected_task && context.phase == expected_phase — e.g. a Begin barrier for a different task id, or an End/Apply barrier arriving while expecting Begin.

Common situations: Meta dispatched a compaction task to the wrong sink instance; stale compaction task ids after job restart/recovery; phase transitions racing so an old task's barrier arrives during a new task; actor migration reusing stale context.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11). Data as JSON: /api/errors/7d61cd6db0ce5fea. Report an issue: GitHub.