Could not get shard stats for primary of index leaderIndex on leader cluster – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 7.1-8.9

Briefly, this error occurs when Elasticsearch is unable to retrieve shard statistics for the primary shard of a specified index on the leader cluster. This could be due to network issues, insufficient permissions, or the shard or index being unavailable. To resolve this, ensure the network connectivity is stable, the necessary permissions are granted, and the shard and index are available and not in a faulty state. Also, check the cluster health and ensure it’s green. If the issue persists, consider reindexing or relocating the shard.

This guide will help you check for common problems that cause the log ” Could not get shard stats for primary of index ” + leaderIndex + ” on leader cluster ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: plugin, cluster, shard, index, repository.

Log Context

Log “Could not get shard stats for primary of index ” + leaderIndex + ” on leader cluster” class name is CcrRepository.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 // we only care about the shard size here for shard allocation; populate the rest with dummy values
 final long totalSize = shardStats.getStats().getStore().getSizeInBytes();
 return IndexShardSnapshotStatus.newDone(0L; 0L; 1; 1; totalSize; totalSize; DUMMY_GENERATION);
 }
 }
 throw new ElasticsearchException("Could not get shard stats for primary of index " + leaderIndex + " on leader cluster");
 }  @Override
 public void updateState(ClusterState state) {}

 

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?