Skip to content

core, graph, store: Pause failed subgraphs instead of unassigning #5971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/subgraph/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ where
let store = &self.inputs.store;
if !ENV_VARS.disable_fail_fast && !store.is_deployment_synced() {
store
.unassign_subgraph()
.pause_subgraph()
.map_err(|e| ProcessingError::Unknown(e.into()))?;

// Use `Canceled` to avoiding setting the subgraph health to failed, an error was
Expand Down
2 changes: 1 addition & 1 deletion graph/src/components/store/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ pub trait WritableStore: ReadStore + DeploymentCursorTracker {
/// Cheap, cached operation.
fn is_deployment_synced(&self) -> bool;

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

/// Load the dynamic data sources for the given deployment
async fn load_dynamic_data_sources(
Expand Down
15 changes: 13 additions & 2 deletions store/postgres/src/writable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,17 @@ impl SyncStore {
})
}

fn pause_subgraph(&self, site: &Site) -> Result<(), StoreError> {
retry::forever(&self.logger, "unassign_subgraph", || {
let mut pconn = self.store.primary_conn()?;
pconn.transaction(|conn| -> Result<_, StoreError> {
let mut pconn = primary::Connection::new(conn);
let changes = pconn.pause_subgraph(site)?;
self.store.send_store_event(&StoreEvent::new(changes))
})
})
}

async fn load_dynamic_data_sources(
&self,
block: BlockNumber,
Expand Down Expand Up @@ -1722,8 +1733,8 @@ impl WritableStoreTrait for WritableStore {
self.is_deployment_synced.load(Ordering::SeqCst)
}

fn unassign_subgraph(&self) -> Result<(), StoreError> {
self.store.unassign_subgraph(&self.store.site)
fn pause_subgraph(&self) -> Result<(), StoreError> {
self.store.pause_subgraph(&self.store.site)
}

async fn load_dynamic_data_sources(
Expand Down
2 changes: 1 addition & 1 deletion store/test-store/tests/graph/entity_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl WritableStore for MockStore {
unimplemented!()
}

fn unassign_subgraph(&self) -> Result<(), StoreError> {
fn pause_subgraph(&self) -> Result<(), StoreError> {
unimplemented!()
}

Expand Down