Skip to content

Commit 6ce0ff2

Browse files
committed
store: Asyncify most methods in deployment_store
1 parent b1701f2 commit 6ce0ff2

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

store/postgres/src/deployment_store.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ impl DeploymentStore {
303303
layout.query(&logger, conn, query).await
304304
}
305305

306-
fn check_intf_uniqueness(
306+
async fn check_intf_uniqueness(
307307
&self,
308308
conn: &mut PgConnection,
309309
layout: &Layout,
@@ -326,7 +326,7 @@ impl DeploymentStore {
326326
Ok(())
327327
}
328328

329-
fn apply_entity_modifications<'a>(
329+
async fn apply_entity_modifications<'a>(
330330
&self,
331331
conn: &mut PgConnection,
332332
layout: &Layout,
@@ -345,7 +345,7 @@ impl DeploymentStore {
345345
section.end();
346346

347347
let section = stopwatch.start_section("check_interface_entity_uniqueness");
348-
self.check_intf_uniqueness(conn, layout, group)?;
348+
self.check_intf_uniqueness(conn, layout, group).await?;
349349
section.end();
350350

351351
let section = stopwatch.start_section("apply_entity_modifications_insert");
@@ -414,20 +414,20 @@ impl DeploymentStore {
414414
}
415415

416416
/// Panics if `idx` is not a valid index for a read only pool.
417-
fn read_only_conn(
417+
async fn read_only_conn(
418418
&self,
419419
idx: usize,
420420
) -> Result<PooledConnection<ConnectionManager<PgConnection>>, Error> {
421421
self.read_only_pools[idx].get().map_err(Error::from)
422422
}
423423

424-
pub(crate) fn get_replica_conn(
424+
pub(crate) async fn get_replica_conn(
425425
&self,
426426
replica: ReplicaId,
427427
) -> Result<PooledConnection<ConnectionManager<PgConnection>>, Error> {
428428
let conn = match replica {
429429
ReplicaId::Main => self.get_conn()?,
430-
ReplicaId::ReadOnly(idx) => self.read_only_conn(idx)?,
430+
ReplicaId::ReadOnly(idx) => self.read_only_conn(idx).await?,
431431
};
432432
Ok(conn)
433433
}
@@ -615,7 +615,7 @@ impl DeploymentStore {
615615

616616
// Only used for tests
617617
#[cfg(debug_assertions)]
618-
pub(crate) fn drop_all_metadata(&self) -> Result<(), StoreError> {
618+
pub(crate) async fn drop_all_metadata(&self) -> Result<(), StoreError> {
619619
// Delete metadata entities in each shard
620620

621621
// This needs to touch all the tables in the subgraphs schema
@@ -1161,12 +1161,14 @@ impl DeploymentStore {
11611161
let layout = self.layout(conn, site.clone()).await?;
11621162

11631163
let section = stopwatch.start_section("apply_entity_modifications");
1164-
let count = self.apply_entity_modifications(
1165-
conn,
1166-
layout.as_ref(),
1167-
batch.groups(),
1168-
stopwatch,
1169-
)?;
1164+
let count = self
1165+
.apply_entity_modifications(
1166+
conn,
1167+
layout.as_ref(),
1168+
batch.groups(),
1169+
stopwatch,
1170+
)
1171+
.await?;
11701172
section.end();
11711173

11721174
layout.rollup(conn, last_rollup, &batch.block_times).await?;

store/postgres/src/query_store.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ impl QueryStoreTrait for QueryStore {
4848
let mut conn = self
4949
.store
5050
.get_replica_conn(self.replica_id)
51+
.await
5152
.map_err(|e| QueryExecutionError::StoreError(e.into()))?;
5253
let wait = start.elapsed();
5354
self.store

store/postgres/src/subgraph_store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ impl Inner {
848848
}
849849

850850
for store in self.stores.values() {
851-
store.drop_all_metadata()?;
851+
store.drop_all_metadata().await?;
852852
}
853853
self.clear_caches().await;
854854
Ok(())

0 commit comments

Comments
 (0)