Skip to content

[Backend] Indexer Dead-Letter Event Replay, Inspection & Triage Management API #1444

Description

@blurbeast

Overview & Background

The database model IndexerDeadLetterEvent captures Soroban events that failed processing (e.g. unexpected payload format, transient database lock, RPC timeout during processing). This ensures a single malformed event does not freeze the indexer worker cursor. However, currently there are no administrative endpoints to query, inspect, retry, or dismiss these dead-letter events.


Detailed Problem Statement

  1. Zero Visibility for Operators:
    • When events fail, they reside silently in the database without any alerting or administration UI.
  2. Manual Intervention Required:
    • Resolving dropped events currently requires executing raw SQL queries and manually reconstructing state mutations.
  3. No Controlled Replay Mechanism:
    • Once an indexer bug is patched and deployed, operators cannot trigger a clean replay of quarantined events.

Technical Specification & Architecture

1. Administrative Dead-Letter Endpoints

Implement in backend/src/routes/v1/admin.routes.ts:

  • GET /api/v1/admin/indexer/dead-letter:
    • Query parameters: page, limit, ledgerSequence, startDate, endDate.
    • Returns paginated list of dead-letter records with error logs and raw payloads.
  • POST /api/v1/admin/indexer/dead-letter/:id/replay:
    • Re-injects the dead-letter event payload into the indexer pipeline (indexer.service.ts).
    • If processing succeeds: deletes the dead-letter entry and creates corresponding StreamEvent and Stream records.
    • If processing fails: increments attempts counter and updates lastAttemptAt and errorMessage.
  • POST /api/v1/admin/indexer/dead-letter/replay-all:
    • Iterates and replays all pending dead-letter records sequentially.
  • DELETE /api/v1/admin/indexer/dead-letter/:id:
    • Permanently discards an unrecoverable event with audit log notation.

2. Authorization

  • Protected by requireAdminAuth JWT middleware.

Target Files

  • backend/src/routes/v1/admin.routes.ts
  • backend/src/controllers/admin.controller.ts
  • backend/src/services/indexer.service.ts
  • backend/tests/indexer-service.test.ts

Acceptance Criteria

  • Admin can retrieve paginated list of failed events with complete error diagnostics.
  • Single and batch replay successfully executes events through the pipeline and cleans up dead-letter table.
  • Protected by admin authentication; unauthorized requests receive 401/403.
  • Unit and integration tests verify error logging, replay execution, and deletion.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend related tasksdatabasePostgreSQL / Prismadrips-waveenhancementNew feature or requestindexerBlockchain data indexing

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions