Skip to content

Commit 01c5255

Browse files
committed
store: Asyncify deployment::insert_subgraph_errors
1 parent a7e721a commit 01c5255

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

store/postgres/src/deployment.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,10 @@ pub async fn exists_and_synced(conn: &mut PgConnection, id: &str) -> Result<bool
815815
}
816816

817817
// Does nothing if the error already exists. Returns the error id.
818-
fn insert_subgraph_error(conn: &mut PgConnection, error: &SubgraphError) -> anyhow::Result<String> {
818+
async fn insert_subgraph_error(
819+
conn: &mut PgConnection,
820+
error: &SubgraphError,
821+
) -> anyhow::Result<String> {
819822
use subgraph_error as e;
820823

821824
let error_id = hex::encode(stable_hash_legacy::utils::stable_hash::<SetHasher, _>(
@@ -850,12 +853,12 @@ fn insert_subgraph_error(conn: &mut PgConnection, error: &SubgraphError) -> anyh
850853
Ok(error_id)
851854
}
852855

853-
pub fn fail(
856+
pub async fn fail(
854857
conn: &mut PgConnection,
855858
id: &DeploymentHash,
856859
error: &SubgraphError,
857860
) -> Result<(), StoreError> {
858-
let error_id = insert_subgraph_error(conn, error)?;
861+
let error_id = insert_subgraph_error(conn, error).await?;
859862

860863
update_deployment_status(conn, id, SubgraphHealth::Failed, Some(error_id), None)?;
861864

@@ -926,7 +929,7 @@ pub fn update_deployment_status(
926929
/// unhealthy. The `latest_block` is only used to check whether the subgraph
927930
/// is healthy as of that block; errors are inserted according to the
928931
/// `block_ptr` they contain
929-
pub(crate) fn insert_subgraph_errors(
932+
pub(crate) async fn insert_subgraph_errors(
930933
logger: &Logger,
931934
conn: &mut PgConnection,
932935
id: &DeploymentHash,
@@ -941,7 +944,7 @@ pub(crate) fn insert_subgraph_errors(
941944
);
942945

943946
for error in deterministic_errors {
944-
insert_subgraph_error(conn, error)?;
947+
insert_subgraph_error(conn, error).await?;
945948
}
946949

947950
check_health(logger, conn, id, latest_block)

store/postgres/src/deployment_store.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,8 @@ impl DeploymentStore {
11791179
&site.deployment,
11801180
&batch.deterministic_errors,
11811181
batch.block_ptr.number,
1182-
)?;
1182+
)
1183+
.await?;
11831184

11841185
if batch.is_non_fatal_errors_active {
11851186
debug!(
@@ -1489,11 +1490,9 @@ impl DeploymentStore {
14891490
error: SubgraphError,
14901491
) -> Result<(), StoreError> {
14911492
self.with_conn(async move |conn, _| {
1492-
conn.transaction_async(|conn| {
1493-
async { deployment::fail(conn, &id, &error) }.scope_boxed()
1494-
})
1495-
.await
1496-
.map_err(Into::into)
1493+
conn.transaction_async(|conn| deployment::fail(conn, &id, &error).scope_boxed())
1494+
.await
1495+
.map_err(Into::into)
14971496
})
14981497
.await?;
14991498
Ok(())

0 commit comments

Comments
 (0)