Skip to content

Fix stcscan offset recovery - #75

Draft
sanlee42 wants to merge 1 commit into
mainfrom
fix/stcscan-offset-recovery
Draft

Fix stcscan offset recovery#75
sanlee42 wants to merge 1 commit into
mainfrom
fix/stcscan-offset-recovery

Conversation

@sanlee42

Copy link
Copy Markdown
Member

Summary

  • recover StcScan block offset from already indexed blocks when the ES mapping tip is missing
  • detect clearly stale mapping tips conservatively before recovery
  • verify the recovered block hash against the chain before writing the mapping tip

Root cause

The indexer treated main.0727.blocks mapping _meta.tip as the only source of truth. If that mapping metadata disappeared or was read as null, the old startup path reset the tip to genesis, which could make alerts show cached heights like 0/200 even though block documents were already indexed near chain head.

Risk controls

  • recovery uses a conservative gap threshold: max(10000, bulkSize * 100)
  • stale recovery only happens when both chain head and indexed data are far ahead of the mapping tip
  • recovered indexed block hash must match the same height on chain
  • fork rollback remains able to lower offset normally when the gap is below the recovery threshold

Validation

  • nix-shell -p jdk11 --run './mvnw -pl starcoin-indexer -am -Dtest=IndexerHandleTest -DfailIfNoTests=false test'\n

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 27711a2c-ffb5-425f-baf7-6ca6d5b951f4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/stcscan-offset-recovery

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant