Skip to content

Commit 85ac00c

Browse files
committed
node, store: Actually setup databases in parallel
The previous code didn't parallelize setup, since setup makes blocking calls, and so databases still started up one after the other.
1 parent 1f24b38 commit 85ac00c

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

node/src/store_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl StoreBuilder {
5252
// attempt doesn't work for all of them because the database is
5353
// unavailable, they will try again later in the normal course of
5454
// using the pool
55-
join_all(pools.iter().map(|(_, pool)| async move { pool.setup() })).await;
55+
join_all(pools.iter().map(|(_, pool)| pool.setup())).await;
5656

5757
let chains = HashMap::from_iter(config.chains.chains.iter().map(|(name, chain)| {
5858
let shard = ShardName::new(chain.shard.to_string())

store/postgres/src/connection_pool.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,14 @@ impl ConnectionPool {
503503
/// # Panics
504504
///
505505
/// If any errors happen during the migration, the process panics
506-
pub fn setup(&self) {
507-
self.get_ready().ok();
506+
pub async fn setup(&self) {
507+
let pool = self.clone();
508+
graph::spawn_blocking_allow_panic(move || {
509+
pool.get_ready().ok();
510+
})
511+
.await
512+
// propagate panics
513+
.unwrap();
508514
}
509515

510516
pub(crate) async fn query_permit(&self) -> tokio::sync::OwnedSemaphorePermit {

0 commit comments

Comments
 (0)