Pending task queue has been nonempty for ms which is longer than the warn threshold of ms – How to solve this Elasticsearch error

Opster Team

Aug-23, Version: 7.15-7.15

Briefly, this error occurs when tasks in Elasticsearch’s queue are not being processed quickly enough, causing a backlog. This could be due to high load, insufficient resources, or slow queries. To resolve this, you can optimize your queries, increase your cluster’s resources, or adjust the thread pool settings. Also, consider checking for any hardware issues that might be slowing down task processing.

This guide will help you check for common problems that cause the log ” pending task queue has been nonempty for [{}/{}ms] which is longer than the warn threshold of [{}ms]; ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: cluster, threshold, task, queue.

Log Context

Log “pending task queue has been nonempty for [{}/{}ms] which is longer than the warn threshold of [{}ms];” classname is MasterService.java.
We extracted the following from Elasticsearch source code for those seeking an in-depth context :

                nonemptyDurationMillis = nowMillis - nonemptySinceMillis;
            }

            final PrioritizedEsThreadPoolExecutor threadPoolExecutor = threadPoolExecutorSupplier.get();
            final TimeValue maxTaskWaitTime = threadPoolExecutor.getMaxTaskWaitTime();
            logger.warn("pending task queue has been nonempty for [{}/{}ms] which is longer than the warn threshold of [{}ms];" +
                    " there are currently [{}] pending tasks; the oldest of which has age [{}/{}ms]";
                TimeValue.timeValueMillis(nonemptyDurationMillis);
                nonemptyDurationMillis;
                warnThreshold;
                threadPoolExecutor.getNumberOfPendingTasks();

 

 [ratemypost]