Skip to content

store: Return the error when rewind or truncate would move the head forward - #6825

Open
yash251 wants to merge 1 commit into
graphprotocol:masterfrom
yash251:yash/6803-rewind-direction-check
Open

yash251 wants to merge 1 commit into
graphprotocol:masterfrom
yash251:yash/6803-rewind-direction-check

Conversation

@yash251

@yash251 yash251 commented Nov 28, 2026

Copy link
Copy Markdown

DeploymentStore::rewind and truncate check the direction of the move, but they build the internal_error! without returning it. graphman rewind to a block above the current head therefore moves the head forward, and the blocks in between are never indexed.

Changes:

  • Return the error in both places.
  • Compare with < instead of <=, so only a target above the current head is rejected. Rewinding to the current head has always worked, and the file_data_sources runner test relies on it: it rewinds to the head to clear a failed state. With <= that test fails with rewind must go backwards, but would go from block 4 to block 4.
  • Change the message to "must not go forward" so it matches the check.
  • Add the store test rewind_and_truncate_refuse_to_move_forward. The deployment's head is at block 2. The test checks that rewind and truncate to block 4 both fail, that the head and the entity count stay the same, and that rewinding to block 2 still works.

Testing, run locally against Postgres 17 with THEGRAPH_STORE_POSTGRES_DIESEL_URL=postgresql://graph:graph@127.0.0.1:5432/graph-test:

  • cargo test -p test-store --test postgres -- store::rewind_and_truncate_refuse_to_move_forward: fails on master ("rewind to a later block must fail") and passes with the fix.
  • cargo test -p graph-store-postgres -p test-store: all pass (postgres suite: 113 passed).
  • cargo test -p graph-tests --test runner_tests: 16 passed.
  • just format, just lint (no warnings) and cargo check --release -p graph-store-postgres are clean.

Fixes #6803

…orward

The direction check in `rewind` and `truncate` built an `internal_error!`
but never returned it, so `graphman rewind` to a block above the current
head moved the head forward and skipped the blocks in between.

Return the error, and only reject targets above the current head.
Rewinding to the current head stays allowed since it is used to clear a
failed state.

Fixes graphprotocol#6803

This branch has not been deployed

No deployments
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.

[Bug] graphman rewind/truncate can move the head forward: direction check is never returned

1 participant