Skip to content

Commit dd6cb78

Browse files
committed
core: add runtime endBlock completion check
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.
1 parent df73b96 commit dd6cb78

File tree

1 file changed

+14
-0
lines changed
  • core/src/amp_subgraph/runner

1 file changed

+14
-0
lines changed

core/src/amp_subgraph/runner/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,20 @@ where
127127
}
128128
}
129129

130+
// Check if the Amp Flight server has data covering through every data
131+
// source's endBlock. This handles the case where endBlock has no entity
132+
// data — the persisted block pointer never advances to endBlock, but the
133+
// server's latest block confirms all queries have been served.
134+
if latest_block >= cx.max_end_block() {
135+
cx.metrics.deployment_synced.record(true);
136+
137+
debug!(cx.logger, "Indexing completed; endBlock reached via server latest block";
138+
"latest_block" => latest_block,
139+
"max_end_block" => cx.max_end_block()
140+
);
141+
return Ok(());
142+
}
143+
130144
debug!(cx.logger, "Completed indexing iteration";
131145
"latest_synced_block_ptr" => ?cx.latest_synced_block_ptr()
132146
);

0 commit comments

Comments
 (0)