FE OOM due to partitionCache loading all partitions eagerly for Iceberg tables with millions of partitions
I have an FE cluster running on a 40 GB pod with 24 GB JVM memory, and I am experiencing FE OOM crashes. This is primarily due to the following issues when using Iceberg catalogs with tables containing millions of partitions:
getPartitions() eagerly loads all partitions. For tables with 6.6M+ partitions (in my case), this results in the creation of millions of in-memory objects, leading to excessive heap usage.
partitionCache uses maximumSize instead of maximumWeight. This limits the number of tables cached rather than the number of partitions, allowing unbounded memory growth when individual tables have extremely high partition counts.
getPartitionsByNames() internally calls getPartitions(), which forces a full partition load even when only a small subset of partitions is requested.
Impact:
- When query planner needs partition info (e.g., for partition pruning), it calls
getPartitionsByNames() - Even if query only needs 10 partitions,
getPartitionsByNames()loads ALL 6.6M partitions first - This happens during query planning, not just background refresh
- Any query with partition predicates triggers this → OOM during query planning
Evidence:
- Planner timeout:
StarRocks planner use long time 37631 ms in memo phase - OOM occurs during query execution, not just background refresh
- Background refresh makes it worse (additional partition loads), but isn't required to reproduce
Steps to reproduce the behavior (Required)
- Create an Iceberg catalog with a table containing millions of partitions(i've a table with 6.6 million partitions)
- Run a SELECT query with partition predicate or any query that triggers partition pruning.
- Monitor FE heap memory - it will grow to 20GB+ and eventually OOM during query planning
Note: The issue occurs during query planning when the optimizer needs partition information. Background refresh is NOT required to reproduce - it just makes the problem worse by triggering additional partition loads.
Expected behavior (Required)
- FE should handle Iceberg tables with millions of partitions without OOM
- When a query needs specific partitions, only those partitions should be loaded
getPartitionsByNames()should load only requested partitions, not all partitionspartitionCacheshould limit memory by partition count, not just table count- Partitions should be loaded lazily (only when queried), not all at once
Real behavior (Required)
- During query planning, when partition information is needed:
getPartitionsByNames()callsgetPartitions()which loads ALL 6.6M partitions- Even if query only needs 10 partitions, all 6.6M are loaded into memory
- FE heap memory grows to 20GB+ and causes
OutOfMemoryError: Java heap space
- Query planning times out:
StarRocks planner use long time 37631 ms in memo phase - FE pod crashes and restarts
- Background refresh makes it worse (if enabled):
- Refresh operations never complete (take hours)
- Multiple overlapping refreshes accumulate memory
StarRocks version (Required)
- 3.5.9-49d8fe2
- Deployment: Kubernetes (GKE)
- JVM Heap: 24GB (
-Xmx24g)
Potential Fixes
FIX 1: Change partitionCache to use maximumWeight (partial fix). This helps prevent unbounded growth after load, but doesn't fix the initial load that loads all partitions. FIX 2: Make getPartitions() lazy/paginated. FIX 3: Optimize getPartitionsByNames() to not call getPartitions(), filter it at table scan level.
Source: StarRocks/starrocks