Skip to content

fix(api): indexer stalls and falls behind, restart can deadlock #2162

Description

@tony8713

Symptom

The Starknet indexer (apps/api, built on @snapshot-labs/checkpoint) periodically halts and falls thousands of blocks behind chain tip (recently observed ~17k blocks behind). When it stalls, downstream data goes stale: voting numbers on the interface stop updating until the indexer is manually recovered.

This has recurred (it has happened before on a network and was flagged to investigate), so it is not a one-off.

Constraint: cannot be naively auto-restarted

We currently restart it manually. It cannot be safely auto-restarted because the indexing path does not run inside DB transactions, so a restart can leave it in an inconsistent state and end up in a deadlock. Quote from the discussion: "we dont have transactions so when we restart there is a chance we end up in deadlock."

Goal

  1. Investigate the root cause of the stalls (why the indexer head stops advancing).
  2. Make restart safe and idempotent so recovery (manual or automated) cannot deadlock. Options to consider:
    • Transactional checkpointing (wrap block-write + checkpoint cursor in a single DB transaction so a restart resumes cleanly).
    • A documented safe-restart procedure / lock handling if full transactions are not feasible short term.

Infra context

DigitalOcean hosts; Cloudflare domains (api-arb1 / api-indexer-2.snapshot.box, some old/killed); Checkpoint console at console.checkpoint.box.

Notes

Filed in sx-monorepo since apps/api is the deployed indexer service that consumes Checkpoint. If the fix turns out to be in the framework itself, the related repo is snapshot-labs/checkpoint.

Related: monitoring/alerting tracked in #2163

To handle next week.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions