Skip to content

Commit 12c91aa

Browse files
committed
core, graph, store: Pause failed subgraphs instead of unassigning
Unassigning subgraphs has a number of unwanted side-effects, e.g., canceling copies. Pausing is safer alternative to avoid spending cycles on a subgraph we know will not make progress.
1 parent a322a63 commit 12c91aa

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

core/src/subgraph/runner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ where
527527
let store = &self.inputs.store;
528528
if !ENV_VARS.disable_fail_fast && !store.is_deployment_synced() {
529529
store
530-
.unassign_subgraph()
530+
.pause_subgraph()
531531
.map_err(|e| ProcessingError::Unknown(e.into()))?;
532532

533533
// Use `Canceled` to avoiding setting the subgraph health to failed, an error was

graph/src/components/store/traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ pub trait WritableStore: ReadStore + DeploymentCursorTracker {
395395
/// Cheap, cached operation.
396396
fn is_deployment_synced(&self) -> bool;
397397

398-
fn unassign_subgraph(&self) -> Result<(), StoreError>;
398+
fn pause_subgraph(&self) -> Result<(), StoreError>;
399399

400400
/// Load the dynamic data sources for the given deployment
401401
async fn load_dynamic_data_sources(

store/postgres/src/writable.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,17 @@ impl SyncStore {
358358
})
359359
}
360360

361+
fn pause_subgraph(&self, site: &Site) -> Result<(), StoreError> {
362+
retry::forever(&self.logger, "unassign_subgraph", || {
363+
let mut pconn = self.store.primary_conn()?;
364+
pconn.transaction(|conn| -> Result<_, StoreError> {
365+
let mut pconn = primary::Connection::new(conn);
366+
let changes = pconn.pause_subgraph(site)?;
367+
self.store.send_store_event(&StoreEvent::new(changes))
368+
})
369+
})
370+
}
371+
361372
async fn load_dynamic_data_sources(
362373
&self,
363374
block: BlockNumber,
@@ -1722,8 +1733,8 @@ impl WritableStoreTrait for WritableStore {
17221733
self.is_deployment_synced.load(Ordering::SeqCst)
17231734
}
17241735

1725-
fn unassign_subgraph(&self) -> Result<(), StoreError> {
1726-
self.store.unassign_subgraph(&self.store.site)
1736+
fn pause_subgraph(&self) -> Result<(), StoreError> {
1737+
self.store.pause_subgraph(&self.store.site)
17271738
}
17281739

17291740
async fn load_dynamic_data_sources(

store/test-store/tests/graph/entity_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl WritableStore for MockStore {
141141
unimplemented!()
142142
}
143143

144-
fn unassign_subgraph(&self) -> Result<(), StoreError> {
144+
fn pause_subgraph(&self) -> Result<(), StoreError> {
145145
unimplemented!()
146146
}
147147

0 commit comments

Comments
 (0)