Skip to content

Commit

Permalink
indexer: let checkpoint keep polling new checkpoints (MystenLabs#7670)
Browse files Browse the repository at this point in the history
  • Loading branch information
gegaowp authored Jan 25, 2023
1 parent 46e4023 commit b026630
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions crates/sui-indexer/src/handlers/checkpoint_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,27 @@ impl CheckpointHandler {
self.checkpoint_handler_metrics
.total_checkpoint_requested
.inc();
let checkpoint = self
let mut checkpoint = self
.rpc_client
.read_api()
.get_checkpoint_summary(next_cursor_sequence_number as u64)
.await
.map_err(|e| {
IndexerError::FullNodeReadingError(format!(
"Failed to get checkpoint with sequence {} error: {:?}",
next_cursor_sequence_number, e
))
})?;
.await;
// this happens very often b/c checkpoint indexing is faster than checkpoint
// generation. Ideally we will want to differentiate between a real error and
// a checkpoint not generated yet.
while checkpoint.is_err() {
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
checkpoint = self
.rpc_client
.read_api()
.get_checkpoint_summary(next_cursor_sequence_number as u64)
.await;
}
self.checkpoint_handler_metrics
.total_checkpoint_received
.inc();
commit_checkpoint(&mut pg_pool_conn, checkpoint)?;
// unwrap here is safe because we checked for error above
commit_checkpoint(&mut pg_pool_conn, checkpoint.unwrap())?;
info!("Checkpoint {} committed", next_cursor_sequence_number);
self.checkpoint_handler_metrics
.total_checkpoint_processed
Expand Down

0 comments on commit b026630

Please sign in to comment.