Shard is in primary mode and cannot perform segment replication as a replica – How to solve this OpenSearch error

Opster Team

Aug-23, Version: 2.6-2.9

Before you dig into reading this guide, have you tried asking OpsGPT what this log means? You’ll receive a customized analysis of your log.

Try OpsGPT now for step-by-step guidance and tailored insights into your OpenSearch operation.

Briefly, this error occurs when a shard in OpenSearch is in primary mode and is being asked to perform a task that only a replica shard can do, such as segment replication. This is likely due to a misconfiguration in your OpenSearch cluster. To resolve this issue, you can either change the shard’s mode to replica or assign the segment replication task to a replica shard. Additionally, ensure that your cluster’s settings and shard allocation are correctly configured to prevent such issues in the future.

For a complete solution to your to your search operation, try for free AutoOps for Elasticsearch & OpenSearch . With AutoOps and Opster’s proactive support, you don’t have to worry about your search operation – we take charge of it. Get improved performance & stability with less hardware.

This guide will help you check for common problems that cause the log ” Shard is in primary mode and cannot perform segment replication as a replica. ” to appear. To understand the issues related to this log, read the explanation below about the following OpenSearch concepts: index, replication, shard.

Log Context

Log “Shard is in primary mode and cannot perform segment replication as a replica.” classname is IndexShard.java.
We extracted the following from OpenSearch source code for those seeking an in-depth context :

        if (indexSettings.isSegRepEnabled() == false) {
            logger.warn("Attempting to perform segment replication when it is not enabled on the index");
            return false;
        }
        if (getReplicationTracker().isPrimaryMode()) {
            logger.warn("Shard is in primary mode and cannot perform segment replication as a replica.");
            return false;
        }
        if (this.routingEntry().primary()) {
            logger.warn("Shard routing is marked primary thus cannot perform segment replication as replica");
            return false;

 

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?

Get expert answers on Elasticsearch/OpenSearch