Skip to content

Commit 202234a

Browse files
committed
core, graph, store: Log deployment hashes when removing a subgraph
Log all the deployment hashes associated with a subgraph name when removing the name
1 parent 2ca9b86 commit 202234a

3 files changed

Lines changed: 21 additions & 7 deletions

File tree

core/src/subgraph/registrar.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,12 @@ where
355355
}
356356

357357
async fn remove_subgraph(&self, name: SubgraphName) -> Result<(), SubgraphRegistrarError> {
358-
self.store.clone().remove_subgraph(name.clone()).await?;
358+
use itertools::Itertools;
359359

360-
debug!(self.logger, "Removed subgraph"; "subgraph_name" => name.to_string());
360+
let hashes = self.store.clone().remove_subgraph(name.clone()).await?;
361+
let hashes = hashes.into_iter().join(", ");
362+
363+
debug!(self.logger, "Removed subgraph"; "subgraph_name" => name.to_string(), "deployments" => format!("[{}]", hashes));
361364

362365
Ok(())
363366
}

graph/src/components/store/traits.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,13 @@ pub trait SubgraphStore: Send + Sync + 'static {
104104
/// subgraph
105105
async fn create_subgraph(&self, name: SubgraphName) -> Result<String, StoreError>;
106106

107-
/// Remove a subgraph and all its versions; if deployments that were used
108-
/// by this subgraph do not need to be indexed anymore, also remove
107+
/// Remove a subgraph and all its versions; if deployments that were
108+
/// used by this subgraph do not need to be indexed anymore, also remove
109109
/// their assignment, but keep the deployments themselves around
110-
async fn remove_subgraph(&self, name: SubgraphName) -> Result<(), StoreError>;
110+
///
111+
/// Returns the hashes of all deployments that were associated with the
112+
/// removed name
113+
async fn remove_subgraph(&self, name: SubgraphName) -> Result<Vec<DeploymentHash>, StoreError>;
111114

112115
/// Assign the subgraph with `id` to the node `node_id`. If there is no
113116
/// assignment for the given deployment, report an error.

store/postgres/src/subgraph_store.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,14 @@ impl SubgraphStoreTrait for SubgraphStore {
15401540
.await
15411541
}
15421542

1543-
async fn remove_subgraph(&self, name: SubgraphName) -> Result<(), StoreError> {
1543+
async fn remove_subgraph(&self, name: SubgraphName) -> Result<Vec<DeploymentHash>, StoreError> {
1544+
let deployments = self
1545+
.status(status::Filter::SubgraphName(name.to_string()))
1546+
.await?
1547+
.into_iter()
1548+
.filter_map(|info| DeploymentHash::new(info.subgraph).ok())
1549+
.collect::<Vec<_>>();
1550+
15441551
let mut pconn = self.primary_conn().await?;
15451552
pconn
15461553
.transaction(|pconn| {
@@ -1552,7 +1559,8 @@ impl SubgraphStoreTrait for SubgraphStore {
15521559
}
15531560
.scope_boxed()
15541561
})
1555-
.await
1562+
.await?;
1563+
Ok(deployments)
15561564
}
15571565

15581566
async fn reassign_subgraph(

0 commit comments

Comments
 (0)