Skip to content

Commit 5d944c4

Browse files
committed
instance_manager: Clear entity cache when subgraph errors
1 parent 4bdb064 commit 5d944c4

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

core/src/subgraph/instance_manager.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,17 @@ where
673673

674674
// Handle unexpected stream errors by marking the subgraph as failed.
675675
Err(e) => {
676+
// Clear entity cache when a subgraph fails.
677+
//
678+
// This is done to be safe and sure that there's no state that's
679+
// out of sync from the database.
680+
//
681+
// Without it, POI changes on failure would be kept in the entity cache
682+
// and be transacted incorrectly in the next run.
683+
ctx.state.entity_lfu_cache = LfuCache::new();
684+
685+
deployment_failed.set(1.0);
686+
676687
let message = format!("{:#}", e).replace("\n", "\t");
677688
let err = anyhow!("{}, code: {}", message, LogCode::SubgraphSyncingFailure);
678689

@@ -683,7 +694,6 @@ where
683694
handler: None,
684695
deterministic: e.is_deterministic(),
685696
};
686-
deployment_failed.set(1.0);
687697

688698
store_for_err
689699
.fail_subgraph(error)

0 commit comments

Comments
 (0)