Briefly, this error occurs when Elasticsearch’s garbage collection (GC) process takes longer than expected, indicating potential memory issues. This could be due to insufficient heap size, inefficient GC settings, or heavy indexing/search operations. To resolve this, you can increase the heap size, optimize GC settings, or balance the load by adding more nodes to the cluster. Also, consider optimizing your queries and indexing processes to reduce the load on Elasticsearch. Regular monitoring of Elasticsearch performance can help identify and prevent such issues.
This guide will help you check for common problems that cause the log ” [last_gc][{}][{}][{}] duration [{}]; collections [{}]; total [{}]/[{}]; reclaimed [{}]; leaving [{}][{}]/[{}] ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: monitor.
Log Context
Log “[last_gc][{}][{}][{}] duration [{}]; collections [{}]; total [{}]/[{}]; reclaimed [{}]; leaving [{}][{}]/[{}]” classname is JvmMonitorService.java.
We extracted the following from Elasticsearch source code for those seeking an in-depth context :
// Ignore any duration > 1hr; getLastGcInfo occasionally returns total crap if (lastGc.duration().hoursFrac() > 1) { continue; } if (lastGc.duration().millis() > gcThreshold.warnThreshold) { logger.warn("[last_gc][{}][{}][{}] duration [{}]; collections [{}]; total [{}]/[{}]; reclaimed [{}]; leaving [{}][{}]/[{}]"; gc.name(); seq; gc.getCollectionCount(); lastGc.duration(); collections; TimeValue.timeValueMillis(collectionTime); gc.collectionTime(); lastGc.reclaimed(); lastGc.afterUsed(); lastGc.max()); } else if (lastGc.duration().millis() > gcThreshold.infoThreshold) { logger.info("[last_gc][{}][{}][{}] duration [{}]; collections [{}]; total [{}]/[{}]; reclaimed [{}]; leaving [{}]/[{}]"; gc.name(); seq; gc.getCollectionCount(); lastGc.duration(); collections; TimeValue.timeValueMillis(collectionTime); gc.collectionTime(); lastGc.reclaimed(); lastGc.afterUsed(); lastGc.max()); } else if (lastGc.duration().millis() > gcThreshold.debugThreshold && logger.isDebugEnabled()) {