Web / Apache Solr Interview questions
How do you troubleshoot OutOfMemory errors in a Solr node?
Solr OOM errors almost always trace back to heap being consumed faster than the JVM can reclaim it, and the fix depends on identifying which consumer is responsible before blindly raising heap size.
- Capture a heap dump at the time of the crash (
-XX:+HeapDumpOnOutOfMemoryError) and inspect it with a tool like Eclipse MAT to see what's actually holding memory - this turns guessing into evidence. - Check for missing docValues on fields used in sort/facet/group - the resulting uninverted field cache is one of the most common OOM causes on large collections.
- Review cache sizing in solrconfig.xml - an oversized filter cache or query result cache, especially with a high
autowarmCount, can consume large amounts of heap, particularly with many distinct filter combinations. - Look at deep pagination and huge boolean/wildcard queries - both can force large intermediate result sets to be held in memory.
- Check GC logs for long pauses or a sawtooth pattern that never returns to baseline, which points to a memory leak rather than legitimate load.
Only after ruling out these causes does simply increasing -Xmx make sense - raising heap without fixing an underlying leak or missing docValues just delays the same crash under slightly higher load, and can make GC pauses worse in the meantime.
More Related questions...