Skip to content

Commit 544d698

Browse files
store: Fixes and refactor error handling
Signed-off-by: Maksim Dimitrov <[email protected]>
1 parent 76757b4 commit 544d698

File tree

2 files changed

+41
-17
lines changed

2 files changed

+41
-17
lines changed

store/postgres/src/deployment_store.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -782,9 +782,9 @@ impl DeploymentStore {
782782
#[diesel(sql_type = diesel::sql_types::Text)]
783783
table_name: String,
784784
}
785-
let result = self
786-
.with_conn(move |conn, _| {
787-
let query = r#"
785+
786+
let mut conn = self.pool.get().await?;
787+
let query = r#"
788788
SELECT
789789
stats.subgraph,
790790
stats.table_name
@@ -798,13 +798,12 @@ impl DeploymentStore {
798798
AND ts.is_account_like IS NOT TRUE
799799
"#;
800800

801-
diesel::sql_query(query)
802-
.bind::<diesel::sql_types::BigInt, _>(min_versions as i64)
803-
.bind::<diesel::sql_types::Double, _>(ratio)
804-
.load::<TableStat>(conn)
805-
.map_err(Into::into)
806-
})
807-
.await;
801+
let result = diesel::sql_query(query)
802+
.bind::<diesel::sql_types::BigInt, _>(min_versions as i64)
803+
.bind::<diesel::sql_types::Double, _>(ratio)
804+
.load::<TableStat>(&mut conn)
805+
.await
806+
.map_err(Into::into);
808807

809808
result.map(|tables| {
810809
tables

store/postgres/src/subgraph_store.rs

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,9 +1284,21 @@ impl Inner {
12841284
ratio: f64,
12851285
) -> Result<(), StoreError> {
12861286
for (_shard, store) in &self.stores {
1287-
let candidates = store
1287+
let candidates = match store
12881288
.identify_account_like_candidates(min_records, ratio)
1289-
.await?;
1289+
.await
1290+
{
1291+
Ok(candidates) => candidates,
1292+
Err(e) => {
1293+
graph::slog::error!(
1294+
logger,
1295+
"Failed to identify account-like candidates in shard {}",
1296+
_shard;
1297+
"error" => e.to_string()
1298+
);
1299+
continue;
1300+
}
1301+
};
12901302

12911303
graph::slog::debug!(
12921304
logger,
@@ -1303,11 +1315,24 @@ impl Inner {
13031315
subgraph
13041316
);
13051317

1306-
let hash = DeploymentHash::new(subgraph.clone()).map_err(|_| {
1307-
anyhow!("Failed to create deployment hash for subgraph: {subgraph}")
1308-
})?;
1309-
let (store, site) = self.store(&hash)?;
1310-
store.set_account_like(site, &table_name, true).await?;
1318+
let res = async {
1319+
let hash = DeploymentHash::new(subgraph.clone()).map_err(|_| {
1320+
anyhow!("Failed to create deployment hash for subgraph: {subgraph}")
1321+
})?;
1322+
let (store, site) = self.store(&hash).await?;
1323+
store.set_account_like(site, &table_name, true).await
1324+
}
1325+
.await;
1326+
1327+
if let Err(e) = res {
1328+
graph::slog::error!(
1329+
logger,
1330+
"Failed to set table {} as account-like for deployment {}",
1331+
table_name,
1332+
subgraph;
1333+
"error" => e.to_string()
1334+
);
1335+
}
13111336
}
13121337
}
13131338

0 commit comments

Comments
 (0)