Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion store/postgres/src/block_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,23 @@ impl BlockStore {
shard,
);
}
// If the chain's shard has no pool (e.g. pool_size = 0), treat it as a
// misconfiguration and panic with an actionable message.
if !block_store.pools.contains_key(&chain.shard) {
panic!(
"chain '{0}' is configured for shard '{1}' which has no connection pool on this node; \
set pool_size > 0 for shard '{1}' or remove the chain from the config",
chain.name, chain.shard,
);
}

block_store.add_chain_store(chain, false).await?;
};
}

// There might be chains we have in the database that are not yet/
// no longer configured. Add a chain store for each of them, too
// no longer configured. Add a chain store for each of them, too.
// Ignore chains that are in the database, but have no pools for their shards.
let configured_chains = block_store
.stores
.read()
Expand All @@ -301,6 +312,16 @@ impl BlockStore {
.iter()
.filter(|chain| !configured_chains.contains(&chain.name))
{
if !block_store.pools.contains_key(&chain.shard) {
warn!(
&block_store.logger,
"Chain `{}` is stored in shard `{}` which has no connection pool on this node, skipping",
chain.name,
chain.shard,
);
continue;
}

block_store.add_chain_store(chain, false).await?;
}
Ok(block_store)
Expand Down
Loading