Amp-powered subgraphs: Add runtime endBlock completion check#6369
Merged
Amp-powered subgraphs: Add runtime endBlock completion check#6369
Conversation
lutter
approved these changes
Feb 16, 2026
Add a runtime check in run_indexing that detects when the Amp Flight server's latest block covers through every data source's endBlock, even when no entity data exists at the endBlock itself. Previously, the only completion check compared the persisted block pointer (which only advances when data is written) against endBlock, causing an infinite polling loop when endBlock has no data. The check compares latest_block (min MAX(_block_num) across non-completed tables) against max_end_block (max end_block across all data sources). If latest_block >= max_end_block, all SQL queries have been served and indexing completes.
4cf1686 to
dd6cb78
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
endBlock.Problem
The existing
indexing_completedcheck (at the top of the loop) relies on the persisted block pointer (latest_synced_block) having advanced toendBlock. However, ifendBlockitself contains no entity data, the store's block pointer is never advanced to that block number, and the subgraph never reports as synced – it loops indefinitely waiting for a block pointer that will never be written.Solution
After consuming the data stream in each iteration, check whether the Amp Flight server's
latest_blockalready covers throughmax_end_block(). If so, mark the deployment as synced and return, bypassing the need for the persisted block pointer to reachendBlockexactly. This is safe because the server's latest block confirms all queries throughendBlockhave been served.Future Improvements
This will be replaced by persistent completion (to avoid executing queries on restarts to confirm completion) once the Amp-based block cache or the Amp Admin API is integrated into the graph-node.