Log Updating number_of_replicas to for indices – How To Solve Related Issues



Log Updating number_of_replicas to for indices – How To Solve Related Issues

Opster Team

Jan-20, Version: 1.7-8.0



Before you begin reading this guide, we recommend you try running the Elasticsearch Error Check-Up  which can resolve issues causing many log errors (free and no installation required)

 

This guide will help you check for common problems that cause the log “Updating number_of_replicas to for indices” to appear. It’s important to understand the issues related to the log, so to get started, read the general overview on common issues and tips related to the Elasticsearch concepts: allocation, cluster, indices, routing.


Advanced users might want to skip right to the common problems section in each concept or try running the Check-Up which analyses ES to discover the cause of many errors and provides suitable actionable recommendations. 

Overview


Elasticsearch replica shards can be updated dynamically both manually (by hitting API) or dynamically (based on the number of nodes and configuration) in order to improve search latency. A change in the number of replicas is a critical event, and Elasticsearch logs this event as below: updating number_of_replicas to {new replicas number} for indices {affected indices list}.
Manual update: 
Using Index update setting for existing indices or Index template for a future index. The Elasticsearch class for executing these changes is MetaDataUpdateSettingsService.java. 
Dynamic update: 
It’s common to upscale and downscale Elasticsearch clusters based on traffic, and for the same reason, having a fixed number of replicas isn’t very useful in cases like these. That’s why Elasticsearch came up with the concept of Index.auto_expand_replicas(default false), which can dynamically increase/decrease the number of replicas based on the configuration and number of nodes in the cluster. 
Example:
If configured (0-5), the number of allocated replicas will match the number of nodes you create. If you increase/decrease, these numbers will also be changed accordingly. Refer to Elasticsearch founder post and this official doc for more details. org.elasticsearch.cluster.routing.allocation.AllocationService#adaptAutoExpandReplicas This method handles dynamically updating the replicas.
Bottom Line: 
This log is solely for information purposes and there’s nothing much to worry about with them, but if it changes without your knowledge,  there is a scope to take appropriate actions like: Index.auto_expand_replicas : false or Changing the index template to make sure all future indices are not created with fixed settings

Log Context

Log”Updating number_of_replicas to [{}] for indices {}” classname is AllocationService.java
We extracted the following from Elasticsearch source code for those seeking an in-depth context :

                     final IndexMetaData indexMetaData = metaDataBuilder.get(index);
                    final IndexMetaData.Builder indexMetaDataBuilder =
                            new IndexMetaData.Builder(indexMetaData).settingsVersion(1 + indexMetaData.getSettingsVersion());
                    metaDataBuilder.put(indexMetaDataBuilder);
                }
                logger.info("updating number_of_replicas to [{}] for indices {}"; numberOfReplicas; indices);
            }
            final ClusterState fixedState = ClusterState.builder(clusterState).routingTable(routingTableBuilder.build())
                .metaData(metaDataBuilder).build();
            assert AutoExpandReplicas.getAutoExpandReplicaChanges(fixedState.metaData(); fixedState.nodes()).isEmpty();
            return fixedState;




 

Related issues to this log

We have gathered selected Q&A from the community and issues from Github, that can help fix related issues please review the following for further information :

1 How to (persistently) update the index.number_of_replicas setting in Elasticsearch without restarting the cluster? -views 6.66 K ,score 2

Updating the default index number_of_replicas setting for new indices -views   14.40 K,score 12

 

About Opster

Opster line of products and support services detects, prevents, optimizes and automates everything needed to manage mission-critical Elasticsearch.

Find Configuration Errors

Analyze Now