openai/codex · error · anyhow::Error

failed to read backfill state at

Error message

failed to read backfill state at {} after startup backfill: {err}

What it means

Raised in wait_for_backfill_gate after a forced startup backfill pass: re-reading the backfill state from the state DB failed, so completion cannot be confirmed. The state db under codex_home is the input at fault.

Solutions

  1. Verify the state db is writable and not locked by another Codex process
  2. Repair or rebuild the state db if it is corrupt
  3. Retry startup once the conflicting process exits
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at codex-rs/rollout/src/state_db.rs:161 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/ddb008b3bb9bb91d. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/rollout/src/state_db.rs:161

            )
        })?;
        if backfill_state.status == codex_state::BackfillStatus::Complete {
            return Ok(());
        }

        if let Some(backfill_lease_seconds) = backfill_lease_seconds {
            metadata::backfill_sessions_with_lease(
                runtime,
                codex_home,
                default_model_provider_id,
                backfill_lease_seconds,
            )
            .await;
        } else {
            metadata::backfill_sessions(runtime, codex_home, default_model_provider_id).await;
        }
        let backfill_state = runtime.get_backfill_state().await.map_err(|err| {
            anyhow::anyhow!(
                "failed to read backfill state at {} after startup backfill: {err}",
                codex_home.display()
            )
        })?;
        if backfill_state.status == codex_state::BackfillStatus::Complete {
            return Ok(());
        }
        if wait_started.elapsed() >= STARTUP_BACKFILL_WAIT_TIMEOUT {
            return Err(anyhow::anyhow!(
                "timed out waiting for state db backfill at {} after {:?} (status: {})",
                codex_home.display(),
                STARTUP_BACKFILL_WAIT_TIMEOUT,
                backfill_state.status.as_str()
            ));
        }

        let message = format!(
            "state db backfill is {} at {}; waiting up to {:?} before retrying startup initialization",

View on GitHub (pinned to 339751715c)