From 202234a239eae4f39aed3cf999d9adf608457921 Mon Sep 17 00:00:00 2001 From: David Lutterkort Date: Mon, 2 Mar 2026 11:45:22 -0800 Subject: [PATCH] core, graph, store: Log deployment hashes when removing a subgraph Log all the deployment hashes associated with a subgraph name when removing the name --- core/src/subgraph/registrar.rs | 7 +++++-- graph/src/components/store/traits.rs | 9 ++++++--- store/postgres/src/subgraph_store.rs | 12 ++++++++++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/core/src/subgraph/registrar.rs b/core/src/subgraph/registrar.rs index 9b0efe21abc..d718b4131f1 100644 --- a/core/src/subgraph/registrar.rs +++ b/core/src/subgraph/registrar.rs @@ -355,9 +355,12 @@ where } async fn remove_subgraph(&self, name: SubgraphName) -> Result<(), SubgraphRegistrarError> { - self.store.clone().remove_subgraph(name.clone()).await?; + use itertools::Itertools; - debug!(self.logger, "Removed subgraph"; "subgraph_name" => name.to_string()); + let hashes = self.store.clone().remove_subgraph(name.clone()).await?; + let hashes = hashes.into_iter().join(", "); + + debug!(self.logger, "Removed subgraph"; "subgraph_name" => name.to_string(), "deployments" => format!("[{}]", hashes)); Ok(()) } diff --git a/graph/src/components/store/traits.rs b/graph/src/components/store/traits.rs index fc77f5799a8..32fc1fbb81f 100644 --- a/graph/src/components/store/traits.rs +++ b/graph/src/components/store/traits.rs @@ -104,10 +104,13 @@ pub trait SubgraphStore: Send + Sync + 'static { /// subgraph async fn create_subgraph(&self, name: SubgraphName) -> Result; - /// Remove a subgraph and all its versions; if deployments that were used - /// by this subgraph do not need to be indexed anymore, also remove + /// Remove a subgraph and all its versions; if deployments that were + /// used by this subgraph do not need to be indexed anymore, also remove /// their assignment, but keep the deployments themselves around - async fn remove_subgraph(&self, name: SubgraphName) -> Result<(), StoreError>; + /// + /// Returns the hashes of all deployments that were associated with the + /// removed name + async fn remove_subgraph(&self, name: SubgraphName) -> Result, StoreError>; /// Assign the subgraph with `id` to the node `node_id`. If there is no /// assignment for the given deployment, report an error. diff --git a/store/postgres/src/subgraph_store.rs b/store/postgres/src/subgraph_store.rs index e5b9ee0a529..0d2e5009828 100644 --- a/store/postgres/src/subgraph_store.rs +++ b/store/postgres/src/subgraph_store.rs @@ -1540,7 +1540,14 @@ impl SubgraphStoreTrait for SubgraphStore { .await } - async fn remove_subgraph(&self, name: SubgraphName) -> Result<(), StoreError> { + async fn remove_subgraph(&self, name: SubgraphName) -> Result, StoreError> { + let deployments = self + .status(status::Filter::SubgraphName(name.to_string())) + .await? + .into_iter() + .filter_map(|info| DeploymentHash::new(info.subgraph).ok()) + .collect::>(); + let mut pconn = self.primary_conn().await?; pconn .transaction(|pconn| { @@ -1552,7 +1559,8 @@ impl SubgraphStoreTrait for SubgraphStore { } .scope_boxed() }) - .await + .await?; + Ok(deployments) } async fn reassign_subgraph(