Skip to content

Commit

Permalink
core: check sync status from state instead of making calls to DB
Browse files Browse the repository at this point in the history
  • Loading branch information
seem-less authored and leoyvens committed Feb 20, 2024
1 parent bd1b86d commit 408a227
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions core/src/subgraph/instance_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,15 @@ impl<S: SubgraphStore> SubgraphInstanceManager<S> {
stream: block_stream_metrics,
};

let is_deployment_synced = inputs.store.is_deployment_synced().await?;

Ok(SubgraphRunner::new(
inputs,
ctx,
logger.cheap_clone(),
metrics,
env_vars,
is_deployment_synced,
))
}

Expand Down
7 changes: 4 additions & 3 deletions core/src/subgraph/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ where
logger: Logger,
metrics: RunnerMetrics,
env_vars: Arc<EnvVars>,
synced: bool
) -> Self {
Self {
inputs: Arc::new(inputs),
ctx,
state: IndexingState {
should_try_unfail_non_deterministic: true,
synced: false,
synced,
skip_ptr_updates_timer: Instant::now(),
backoff: ExponentialBackoff::with_jitter(
(MINUTE * 2).min(env_vars.subgraph_error_retry_ceil),
Expand Down Expand Up @@ -597,7 +598,7 @@ where

// To prevent a buggy pending version from replacing a current version, if errors are
// present the subgraph will be unassigned.
if has_errors && !ENV_VARS.disable_fail_fast && !store.is_deployment_synced().await? {
if has_errors && !ENV_VARS.disable_fail_fast && !self.state.synced {
store
.unassign_subgraph()
.map_err(|e| BlockProcessingError::Unknown(e.into()))?;
Expand Down Expand Up @@ -1311,7 +1312,7 @@ where

// To prevent a buggy pending version from replacing a current version, if errors are
// present the subgraph will be unassigned.
if has_errors && !ENV_VARS.disable_fail_fast && !store.is_deployment_synced().await? {
if has_errors && !ENV_VARS.disable_fail_fast && !self.state.synced {
store
.unassign_subgraph()
.map_err(|e| BlockProcessingError::Unknown(e.into()))?;
Expand Down

0 comments on commit 408a227

Please sign in to comment.