Skip to content

Commit f27eb5f

Browse files
cargopetelutter
authored andcommitted
store: move pool_size = 0 filtering to existing_chains construction
1 parent 972a550 commit f27eb5f

1 file changed

Lines changed: 21 additions & 24 deletions

File tree

store/postgres/src/block_store.rs

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,27 @@ impl BlockStore {
253253
const CHAIN_HEAD_CACHE_TTL: Duration = Duration::from_secs(2);
254254

255255
let mirror = PrimaryMirror::new(&pools);
256-
let existing_chains = mirror.read_async(primary::load_chains).await?;
256+
// Treat a chain whose shard has no connection pool (i.e. a shard
257+
// configured with `pool_size = 0`, which `store_builder` drops) as if it
258+
// doesn't exist: skip it here so we neither create a chain store for it
259+
// nor fail startup. See issue #6195.
260+
let existing_chains: Vec<_> = mirror
261+
.read_async(primary::load_chains)
262+
.await?
263+
.into_iter()
264+
.filter(|chain| {
265+
let has_pool = pools.contains_key(&chain.shard);
266+
if !has_pool {
267+
warn!(
268+
&logger,
269+
"Ignoring chain `{}`: its shard `{}` has no connection pool (pool_size = 0)",
270+
chain.name,
271+
chain.shard,
272+
);
273+
}
274+
has_pool
275+
})
276+
.collect();
257277
let chain_head_cache = TimedCache::new(CHAIN_HEAD_CACHE_TTL);
258278
let chains = shards.clone();
259279

@@ -275,18 +295,6 @@ impl BlockStore {
275295
.iter()
276296
.find(|chain| chain.name == chain_name)
277297
{
278-
// A shard configured with `pool_size = 0` is intentionally
279-
// ignored and has no connection pool. Skip chains that live in
280-
// such a shard rather than failing startup. See issue #6195.
281-
if !block_store.pools.contains_key(&chain.shard) {
282-
warn!(
283-
&block_store.logger,
284-
"Skipping chain `{}`: its shard `{}` has no connection pool (pool_size = 0)",
285-
chain.name,
286-
chain.shard,
287-
);
288-
continue;
289-
}
290298
if chain.shard != shard {
291299
warn!(
292300
&block_store.logger,
@@ -312,17 +320,6 @@ impl BlockStore {
312320
.iter()
313321
.filter(|chain| !configured_chains.contains(&chain.name))
314322
{
315-
// Skip chains whose shard has no connection pool (pool_size = 0)
316-
// instead of failing startup. See issue #6195.
317-
if !block_store.pools.contains_key(&chain.shard) {
318-
warn!(
319-
&block_store.logger,
320-
"Skipping chain `{}`: its shard `{}` has no connection pool (pool_size = 0)",
321-
chain.name,
322-
chain.shard,
323-
);
324-
continue;
325-
}
326323
block_store.add_chain_store(chain, false).await?;
327324
}
328325
Ok(block_store)

0 commit comments

Comments
 (0)