Skip to content

Commit 77d2043

Browse files
committed
store: Avoid deadlocking on connection pool
The start_subgraph code called load_indexes while holding a connection; load_indexes tries to get another connection. If the pool is exhausted because many subgraphs are starting, we end up in a deadlock.
1 parent f914287 commit 77d2043

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

store/postgres/src/deployment_store.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ impl DeploymentStore {
750750
Ok(indexes.into_iter().map(CreateIndex::parse).collect())
751751
}
752752

753+
/// Do not use this while already holding a connection as that can lead
754+
/// to deadlocks
753755
pub(crate) async fn load_indexes(&self, site: Arc<Site>) -> Result<IndexList, StoreError> {
754756
let store = self.clone();
755757
let mut conn = self.pool.get_permitted().await?;
@@ -1608,8 +1610,9 @@ impl DeploymentStore {
16081610

16091611
let mut conn = self.pool.get_permitted().await?;
16101612
if ENV_VARS.postpone_attribute_index_creation {
1611-
// check if all indexes are valid and recreate them if they aren't
1612-
self.load_indexes(site.clone())
1613+
// Check if all indexes are valid and recreate them if they
1614+
// aren't.
1615+
IndexList::load(&mut conn, site, self.cheap_clone())
16131616
.await?
16141617
.recreate_invalid_indexes(&mut conn, &dst)
16151618
.await?;

0 commit comments

Comments
 (0)