Skip to content

Commit

Permalink
indexer grpc fullnode now consider both indexer ledger version + tabl…
Browse files Browse the repository at this point in the history
…e info version to have strong consistency.
  • Loading branch information
larry-aptos committed Oct 24, 2024
1 parent ad0b8eb commit 6272cf4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,17 @@ impl IndexerStreamCoordinator {

pub fn set_highest_known_version(&mut self) -> anyhow::Result<()> {
let info = self.context.get_latest_ledger_info_wrapped()?;
self.highest_known_version = info.ledger_version.0;
let latest_table_info_version = self
.context
.indexer_reader
.as_ref()
.expect("Table info reader not set")
.get_latest_table_info_ledger_version()?
.expect("Table info ledger version not set");

self.highest_known_version =
std::cmp::min(info.ledger_version.0, latest_table_info_version);

Ok(())
}

Expand Down
7 changes: 7 additions & 0 deletions storage/indexer/src/indexer_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ impl IndexerReader for IndexerReaders {
anyhow::bail!("DB indexer reader is not available")
}

fn get_latest_table_info_ledger_version(&self) -> anyhow::Result<Option<Version>> {
if let Some(table_info_reader) = &self.table_info_reader {
return Ok(Some(table_info_reader.next_version()));
}
anyhow::bail!("Table info reader is not available")
}

fn get_events(
&self,
event_key: &EventKey,
Expand Down
1 change: 1 addition & 0 deletions types/src/indexer/indexer_db_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub trait IndexerReader: Send + Sync {
) -> Result<Box<dyn Iterator<Item = Result<(StateKey, StateValue)>> + '_>>;

fn get_latest_internal_indexer_ledger_version(&self) -> Result<Option<Version>>;
fn get_latest_table_info_ledger_version(&self) -> Result<Option<Version>>;

#[cfg(any(test, feature = "fuzzing"))]
fn wait_for_internal_indexer(&self, version: Version) -> Result<()> {
Expand Down

0 comments on commit 6272cf4

Please sign in to comment.