Shard routing is marked primary thus cannot perform segment replication as replica – How to solve this OpenSearch error

Opster Team

Aug-23, Version: 2.7-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 OpenSearch tries to replicate segments from a primary shard to a replica shard. However, the shard routing is marked as primary, which prevents it from acting as a replica. To resolve this issue, you can try the following: 1) Check your shard allocation settings and adjust them if necessary to ensure proper distribution of primary and replica shards. 2) You may need to manually reassign the primary status to another shard. 3) Ensure that your cluster has enough nodes to host both primary and replica shards.

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 routing is marked primary thus cannot perform segment replication as replica ” to appear. To understand the issues related to this log, read the explanation below about the following OpenSearch concepts: routing, index, replication, shard.

Log Context

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

        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;
        }
        if (state().equals(IndexShardState.STARTED) == false
            && (state() == IndexShardState.POST_RECOVERY && shardRouting.state() == ShardRoutingState.INITIALIZING) == false) {
            logger.warn(

 

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