How To Solve Issues Related to Log – Unexpected failure during ; current state:n

Prevent Your Next ELK Incident

Try our free Check Up to test if your ES issues are caused from misconfigured settings

Fix Issue

Updated: Jan-20

In Page Navigation (click to jump) :
Troubleshooting Background       
Related Issues  
Log Context
About Opster

Opster Offer’s World-Class Elasticsearch Expertise In One Powerful Product
Try Our Free ES Check-Up   Prevent Incident

Troubleshooting background

To troubleshoot Elasticsearch log “Unexpected failure during ; current state:n” it’s important to understand common problems related to Elasticsearch concepts: cluster, routing. See detailed explanations below complete with common problems, examples and useful tips.

Routing in Elasticsearch

What it is

In Elasticsearch, routing refers to document routing. When you index a document, Elasticsearch will determine which shard will be used to index the document to. 

The shard is selected based on the following formula:

shard = hash(_routing) % number_of_primary_shards

Where the default value of _routing is _id.
It is important to know which shard the document is routed to, because Elasticsearch will need to determine where to find that document later on for document retrieval requests. 


In twitter index with 2 primary shards, the document with _id equal to “440” gets routed to the shard number:   

shard = hash( 440 ) % 2
PUT twitter/_doc/440

  • In order to improve search performance speed you can create custom routing. For example, you can enable custom routing that will ensure only a single shard is queried (the shard that contains your data).
  • To create custom routing in Elasticsearch, you will need to configure and define  that not all routing will be completed by default settings. ( v <= 5.0)
PUT my_index/customer/_mapping
  •  This will ensure that every document in the “customer” type must specify a custom routing.  For elasticsearch 6 or above you will need to update the same mapping as:
PUT my_index/_mapping

To help troubleshoot related issues we have gathered selected Q&A from the community and issues from Github , please review the following for further information :

1 Github Issue Number 23199  

2 No Cluster Health With 2 Nodes  

Log Context

Log ”Unexpected failure during [{}]; current state:n{}” classname is
We have extracted the following from Elasticsearch source code to get an in-depth context :

                    public void onFailure(String source; Exception e) {
                        ClusterState state = clusterService.state();
                        if (logger.isTraceEnabled()) {
                            logger.error(() -> new ParameterizedMessage("unexpected failure during [{}]; current state:\n{}";
                                source; state); e);
                        } else {
                            logger.error(() -> new ParameterizedMessage("unexpected failure during [{}]; current state version [{}]";
                                source; state.version()); e);

About Opster

Incorporating deep knowledge and broad history of Elasticsearch issues. Opster’s solution identifies and predicts root causes of Elasticsearch problems, provides recommendations and can automatically perform various actions to manage, troubleshoot and prevent issues.

Learn more: Glossary | Blog| Troubleshooting guides | Error Repository

Need help with any Elasticsearch issue ? Contact Opster

Did this page help you?