Skip to content

fix: perform cleaning cache block store on /blocks call#1771

Draft
TarikGul wants to merge 1 commit intomasterfrom
tg-blocks-cache
Draft

fix: perform cleaning cache block store on /blocks call#1771
TarikGul wants to merge 1 commit intomasterfrom
tg-blocks-cache

Conversation

@TarikGul
Copy link
Member

@TarikGul TarikGul commented Sep 12, 2025

Fix OOM regression in BlocksController caching

Problem: Sidecar v19.3.1 crashes with OOM after ~20 hours due to unbounded cache growth.

Root Cause:

  • Polkadot.js cache capacity set to 0, disabling LRU eviction
  • Controller-level cache lacks cleanup mechanism

Fix:

  1. Restore polkadot.js cache capacity from 0 to 1000
  2. Add periodic cache cleanup every 1000 requests (removes 20% of entries when >80% full)
  3. Comprehensive test suite to prevent regression

Impact: Eliminates production OOM crashes while maintaining cache performance benefits.

Files Changed:

  • src/apiRegistry/index.ts - Restore cache capacity
  • src/controllers/blocks/BlocksController.ts - Add cleanup mechanism
  • src/controllers/blocks/*.spec.ts - Cache test suite
  • src/test/utils/cacheTestUtils.ts - Test utilities

Testing: 135 new tests covering memory leak prevention, performance, and edge cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant