Problem
In interchain-indexer/interchain-indexer-logic/src/token_info/service.rs, the kickoff_token_fetch_for_stats_enrichment method (introduced in PR #1650) spawns one unbounded tokio::spawn per unique token key. A large startup backfill or a big flush batch can fan out into thousands of concurrent RPC calls and DB writes, which risks overwhelming RPC providers and starving normal indexing traffic.
Affected code: kickoff_token_fetch_for_stats_enrichment (~lines 272–312)
Suggested Fix
Limit concurrency by introducing a bounded semaphore or a buffered stream, for example:
- A
tokio::sync::Semaphore — acquire a permit before calling fetch_token_info_from_chain_and_persist, releasing it after the call.
- Or
futures::stream::iter(uniq).map(...).buffer_unordered(MAX_CONCURRENCY) — run the fetches inside the buffered stream so no more than MAX_CONCURRENCY concurrent RPC/DB tasks are active at once.
The existing in_flight_fetches deduplication should be kept; the bound is an additional guard on top of it.
References
Reported by @EvgenKor
Problem
In
interchain-indexer/interchain-indexer-logic/src/token_info/service.rs, thekickoff_token_fetch_for_stats_enrichmentmethod (introduced in PR #1650) spawns one unboundedtokio::spawnper unique token key. A large startup backfill or a big flush batch can fan out into thousands of concurrent RPC calls and DB writes, which risks overwhelming RPC providers and starving normal indexing traffic.Affected code:
kickoff_token_fetch_for_stats_enrichment(~lines 272–312)Suggested Fix
Limit concurrency by introducing a bounded semaphore or a buffered stream, for example:
tokio::sync::Semaphore— acquire a permit before callingfetch_token_info_from_chain_and_persist, releasing it after the call.futures::stream::iter(uniq).map(...).buffer_unordered(MAX_CONCURRENCY)— run the fetches inside the buffered stream so no more thanMAX_CONCURRENCYconcurrent RPC/DB tasks are active at once.The existing
in_flight_fetchesdeduplication should be kept; the bound is an additional guard on top of it.References
Reported by @EvgenKor