@@ -1737,12 +1737,24 @@ impl DeploymentStore {
17371737 }
17381738
17391739 async fn create_index (
1740+ logger : & Logger ,
17401741 store : & DeploymentStore ,
17411742 layout : & Layout ,
17421743 site : & Site ,
17431744 idx : & CreateIndex ,
17441745 ) -> Result < ( ) , StoreError > {
1745- let mut conn = store. pool . get_permitted ( ) . await ?;
1746+ let mut last_log = Instant :: now ( ) - Duration :: from_mins ( 2 ) ;
1747+ // We (ab)use the fdw pool here since `create index` can take a
1748+ // very long time; with many subgraphs creating indexes, we
1749+ // might starve the main connection pool which would block the
1750+ // progress of many subgraphs.
1751+ let mut conn = store. pool . get_fdw ( logger, move || {
1752+ if last_log. elapsed ( ) > Duration :: from_mins ( 1 ) {
1753+ debug ! ( logger, "Waiting for a connection to become available so we can create index" ; "index_name" => idx. name( ) . unwrap_or( "<unknown>" ) ) ;
1754+ last_log = Instant :: now ( ) ;
1755+ }
1756+ false
1757+ } ) . await ?;
17461758 let schema_name = site. namespace . as_str ( ) ;
17471759
17481760 // A previous run that was interrupted (e.g. by a node
@@ -1790,7 +1802,7 @@ impl DeploymentStore {
17901802
17911803 wait_for_concurrent_index_creation ( & logger, & store, & site) . await ?;
17921804
1793- create_index ( & store, & layout, & site, & idx) . await ?;
1805+ create_index ( & logger , & store, & layout, & site, & idx) . await ?;
17941806
17951807 debug ! ( logger, "Created index" ;
17961808 "index_name" => idx. name( ) . unwrap_or( "<unknown>" ) ,
0 commit comments