Encountered unexpected state currentState while indexing – How to solve this Elasticsearch error

Opster Team

Aug-23, Version: 6.8-8.9

Briefly, this error occurs when Elasticsearch encounters an unexpected state during the indexing process. This could be due to a variety of reasons such as a corrupted index, insufficient disk space, or network issues. To resolve this issue, you could try the following: 1) Check and free up disk space if necessary, 2) Verify network connectivity, 3) Try reindexing the data, 4) If the index is corrupted, consider deleting and recreating it. Always ensure to have a backup before performing any destructive operations.

This guide will help you check for common problems that cause the log ” Encountered unexpected state [” + currentState + “] while indexing ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: plugin, indexing.

Log Context

Log “Encountered unexpected state [” + currentState + “] while indexing” classname is AsyncTwoPhaseIndexer.java.
We extracted the following from Elasticsearch source code for those seeking an in-depth context :

                        logger.debug("Could not move from STARTED to INDEXING state because current state is [" + state.get() + "]");
                        return false;
                default -> {
                    logger.warn("Encountered unexpected state [" + currentState + "] while indexing");
                    throw new IllegalStateException("Job encountered an illegal state [" + currentState + "]");


How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?