Your indexer keys its rows by block number and transaction index, and the chain has a two-block reorg. What happens to your data?
- Nothing: the numbers are the same, so the data is equivalent. Different branch, different transactions and events at the same numbers.
- The indexer automatically re-processes affected blocks. Only if it tracks hashes and implements rollback.
- The database rejects the writes because of the primary key. A conflict may occur, but the underlying problem is stale rows from the orphan, which no constraint detects.
- Rows from the orphaned blocks stay in the database and new rows for the same numbers may conflict or be missed; without block hashes there is no way to identify which rows came from the discarded branch. Block number is not a stable identity across reorgs; block hash is.
Rows from the orphaned blocks stay in the database, and without block hashes you cannot tell which rows they are.
Track the parent-hash chain: on each new head, verify its parent matches the hash you stored; on mismatch, walk back to the common ancestor, invalidate rows for the orphaned hashes, and re-apply the new branch. Alternatively, index only finalized blocks.
Assuming a primary key or a timestamp will catch it. Neither identifies rows from an orphaned branch, so the stale rows sit there silently and the data diverges from the chain.