Skip to content

Add ledger gap detection and replay trigger to the indexer #420

@Chucks1093

Description

@Chucks1093

Summary

If the indexer process crashes, restarts slowly, or the Stellar RPC node has a temporary outage, the server can silently miss ledger ranges. Missed buy or sell events corrupt the key ownership read model without any visible error. The indexer needs to detect gaps in its processed ledger sequence and either replay the missing range automatically or surface an alert that makes the gap actionable.

Scope

  • Track the highest contiguously processed ledger sequence in a persistent store (database row or config table)
  • On startup and periodically during operation, compare the tracked sequence against the current Stellar network ledger
  • If a gap is detected (non-contiguous jump in processed ledgers), log a structured warning with the gap range
  • Provide a manual replay trigger (e.g. an admin endpoint or CLI command) that re-fetches and processes events for a given ledger range
  • Replay must be idempotent: reprocessing an already-indexed event should not create duplicate records

Acceptance Criteria

  • Indexer persists the last contiguously processed ledger after each batch
  • Gap detection runs on startup and logs a warning when a gap is found
  • Replay can be triggered for any ledger range without duplicating data
  • Integration test simulates a gap (skip ledgers) and confirms detection fires
  • Idempotency test confirms replaying an already-processed range produces no duplicates

Coordinate on Telegram

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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