diff --git a/core/src/subgraph/registrar.rs b/core/src/subgraph/registrar.rs index 28e05282d5f..ae842334445 100644 --- a/core/src/subgraph/registrar.rs +++ b/core/src/subgraph/registrar.rs @@ -411,7 +411,7 @@ where hash: &DeploymentHash, node_id: &NodeId, ) -> Result<(), SubgraphRegistrarError> { - let locations = self.store.locators(hash)?; + let locations = self.store.locators(hash, true)?; let deployment = match locations.len() { 0 => return Err(SubgraphRegistrarError::DeploymentNotFound(hash.to_string())), 1 => locations[0].clone(), diff --git a/graph/src/components/store/traits.rs b/graph/src/components/store/traits.rs index 6a6ef2bc79d..b04dcaa5990 100644 --- a/graph/src/components/store/traits.rs +++ b/graph/src/components/store/traits.rs @@ -156,8 +156,12 @@ pub trait SubgraphStore: Send + Sync + 'static { async fn is_healthy(&self, id: &DeploymentHash) -> Result; - /// Find the deployment locators for the subgraph with the given hash - fn locators(&self, hash: &str) -> Result, StoreError>; + /// Find the deployment locators for the subgraph with the given hash. + /// If `only_active` is `true`, only the locator for the active + /// deployment will be returned. If it is `false`, locators for all + /// deployments with this hash will be returned. + fn locators(&self, hash: &str, only_active: bool) + -> Result, StoreError>; /// This migrates subgraphs that existed before the raw_yaml column was added. async fn set_manifest_raw_yaml( diff --git a/graphql/tests/query.rs b/graphql/tests/query.rs index c0169de0bad..4f3be3b17c9 100644 --- a/graphql/tests/query.rs +++ b/graphql/tests/query.rs @@ -138,7 +138,7 @@ async fn setup( global_init(); let id = DeploymentHash::new(id).unwrap(); - let loc = store.subgraph_store().locators(&id).unwrap().pop(); + let loc = store.subgraph_store().locators(&id, false).unwrap().pop(); match loc { Some(loc) if id_type.deployment_id() == loc.hash.as_str() => loc, diff --git a/node/src/manager/commands/run.rs b/node/src/manager/commands/run.rs index 2e3e1fa53d9..df77cb1d419 100644 --- a/node/src/manager/commands/run.rs +++ b/node/src/manager/commands/run.rs @@ -32,7 +32,7 @@ use graph_core::{ }; fn locate(store: &dyn SubgraphStore, hash: &str) -> Result { - let mut locators = store.locators(hash)?; + let mut locators = store.locators(hash, false)?; match locators.len() { 0 => bail!("could not find subgraph {hash} we just created"), 1 => Ok(locators.pop().unwrap()), diff --git a/store/postgres/src/subgraph_store.rs b/store/postgres/src/subgraph_store.rs index e8bba7a70bd..e71cd5f3990 100644 --- a/store/postgres/src/subgraph_store.rs +++ b/store/postgres/src/subgraph_store.rs @@ -1388,10 +1388,14 @@ impl SubgraphStoreTrait for SubgraphStore { } /// Find the deployment locators for the subgraph with the given hash - fn locators(&self, hash: &str) -> Result, StoreError> { + fn locators( + &self, + hash: &str, + only_active: bool, + ) -> Result, StoreError> { Ok(self .mirror - .find_sites(&[hash.to_string()], false)? + .find_sites(&[hash.to_string()], only_active)? .iter() .map(|site| site.into()) .collect()) diff --git a/tests/src/fixture/mod.rs b/tests/src/fixture/mod.rs index 7feaf6b5c58..bb91b056d44 100644 --- a/tests/src/fixture/mod.rs +++ b/tests/src/fixture/mod.rs @@ -442,7 +442,7 @@ pub fn cleanup( name: &SubgraphName, hash: &DeploymentHash, ) -> Result<(), Error> { - let locators = subgraph_store.locators(hash)?; + let locators = subgraph_store.locators(hash, false)?; subgraph_store.remove_subgraph(name.clone())?; for locator in locators { subgraph_store.remove_deployment(locator.id.into())?;