How To Solve Issues Related to Log – Unexpected error during the primary phase for action ; request

Prevent Your Next ELK Incident

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

Fix Issue

Updated: Feb-20

In-Page Navigation (click to jump) :

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 error during the primary phase for action ; request” it’s important to understand common problems related to Elasticsearch concepts: replication, request. See detailed explanations below complete with common problems, examples and useful tips.

Replication in Elasticsearch

What it is

Replication refers to storing the redundant copy of the data. Starting from version 7.x, Elasticsearch creates one primary shard with a replication factor set to 1.  Replicas never get assigned on the same node on which primary shards are assigned, which means you should have at least two nodes in the cluster to assign the replicas. If a primary shard goes down, the replica automatically acts as a primary shard.

What it is used for

Replicas are used to provide high availability and failover. A higher number of replicas is also helpful for faster searches.

Examples

Update replication count

PUT /api-logs/_settings?pretty
{
    "index" : {
        "number_of_replicas" : 2
    }
}
Common problems
  • By default, If free disk space usage reaches 85%, the replicas of newly created indices are not assigned on that node and Elasticsearch throws a warning.
  • Creating too many replicas may cause a problem if there are not enough resources available in the cluster. 


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 Primary Index Randomly Getting Dele  

2Github Issue Number 21448  


Log Context

Log ”unexpected error during the primary phase for action [{}]; request [{}]” classname is TransportReplicationAction.java
We have extracted the following from Elasticsearch source code to get an in-depth context :

                 assert false : "finishAsFailed called but operation is already finished";
            }
        }

        void finishWithUnexpectedFailure(Throwable failure) {
            logger.warn("unexpected error during the primary phase for action [{}]; request [{}]"; failure; actionName; request);
            if (finished.compareAndSet(false; true)) {
                setPhase(task; "failed");
                listener.onFailure(failure);
            } else {
                assert false : "finishWithUnexpectedFailure called but operation is already finished";






About Opster

Opster identifies and predicts root causes of Elasticsearch problems, provides recommendations and can automatically perform various actions to prevent issues, optimize performance and save resources.

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

Need help with any Elasticsearch issue ? Contact Opster