Rejecting write requests for shard stale shards % shards – 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 rejects write requests due to stale shards. Stale shards are outdated or inconsistent copies of your data. This can happen due to network issues, node failures, or configuration problems. To resolve this, you can try the following: 1) Check the cluster health and identify any unassigned or stale shards. 2) Use the reroute API to manually assign the unassigned shards. 3) Ensure that your nodes are properly configured and network connectivity is stable. 4) If the issue persists, consider reindexing your data.

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 ” Rejecting write requests for shard; stale shards [{}%] shards: {} ” to appear. To understand the issues related to this log, read the explanation below about the following OpenSearch concepts: shards, index.

Log Context

Log “Rejecting write requests for shard; stale shards [{}%] shards: {}” classname is SegmentReplicationPressureService.java.
We extracted the following from OpenSearch source code for those seeking an in-depth context :

            // inSyncIds always considers the primary id; so filter it out.
            final float percentStale = staleReplicas.size() * 100f / (shard.getReplicationGroup().getInSyncAllocationIds().size() - 1);
            final double maxStaleLimit = maxAllowedStaleReplicas * 100f;
            if (percentStale >= maxStaleLimit) {
                tracker.incrementRejectionCount(shard.shardId());
                logger.warn("Rejecting write requests for shard; stale shards [{}%] shards: {}"; percentStale; staleReplicas);
                throw new OpenSearchRejectedExecutionException(
                    "rejected execution on primary shard: " + shard.shardId() + " Stale Replicas: " + staleReplicas + "]";
                    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