Skip to content

[Backend] indexer-state.ts singleton row has no migration guard against concurrent first-insert race #1022

Description

@grantfox-oss

Join our community: https://t.me/+DOylgFv1jyJlNzM0

Why this matters

backend/src/lib/indexer-state.ts creates the singleton indexer_state row on first access; if the worker and an admin reset endpoint both start cold at the same time, two concurrent inserts can race on the same conceptual singleton before the unique constraint kicks in, and the failure path is not handled gracefully.

Acceptance criteria

  • Wrap the first-insert logic in a catch that treats a unique-constraint violation as success and re-reads the row
  • Add a test simulating a duplicate insert and asserting it does not throw

Files to touch

  • backend/src/lib/indexer-state.ts

Out of scope

Does not change the indexer_state schema.

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend related tasksbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions