Briefly, this error occurs when you attempt to upgrade an Elasticsearch cluster that has already been upgraded to the desired version. This means that the current version of your Elasticsearch cluster is the same as the version you’re trying to upgrade to. To resolve this issue, you can either check your current Elasticsearch version to confirm if an upgrade is necessary or proceed with other operations if you’re already on the desired version. If you still want to upgrade, ensure you’re using the correct newer version for the upgrade process.
This guide will help you check for common problems that cause the log ” [{}] no upgrade needed – already upgraded ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: index and upgrade.
Overview
In Elasticsearch, an index (plural: indices) contains a schema and can have one or more shards and replicas. An Elasticsearch index is divided into shards and each shard is an instance of a Lucene index.
Indices are used to store the documents in dedicated data structures corresponding to the data type of fields. For example, text fields are stored inside an inverted index whereas numeric and geo fields are stored inside BKD trees.
Examples
Create index
The following example is based on Elasticsearch version 5.x onwards. An index with two shards, each having one replica will be created with the name test_index1
PUT /test_index1?pretty { "settings" : { "number_of_shards" : 2, "number_of_replicas" : 1 }, "mappings" : { "properties" : { "tags" : { "type" : "keyword" }, "updated_at" : { "type" : "date" } } } }
List indices
All the index names and their basic information can be retrieved using the following command:
GET _cat/indices?v
Index a document
Let’s add a document in the index with the command below:
PUT test_index1/_doc/1 { "tags": [ "opster", "elasticsearch" ], "date": "01-01-2020" }
Query an index
GET test_index1/_search { "query": { "match_all": {} } }
Query multiple indices
It is possible to search multiple indices with a single request. If it is a raw HTTP request, index names should be sent in comma-separated format, as shown in the example below, and in the case of a query via a programming language client such as python or Java, index names are to be sent in a list format.
GET test_index1,test_index2/_search
Delete indices
DELETE test_index1
Common problems
- It is good practice to define the settings and mapping of an Index wherever possible because if this is not done, Elasticsearch tries to automatically guess the data type of fields at the time of indexing. This automatic process may have disadvantages, such as mapping conflicts, duplicate data and incorrect data types being set in the index. If the fields are not known in advance, it’s better to use dynamic index templates.
- Elasticsearch supports wildcard patterns in Index names, which sometimes aids with querying multiple indices, but can also be very destructive too. For example, It is possible to delete all the indices in a single command using the following commands:
DELETE /*
To disable this, you can add the following lines in the elasticsearch.yml:
action.destructive_requires_name: true
Overview
Upgrade refers to migrating your Elasticsearch version to a newer version. The process of updating distributed systems like Elasticsearch can be intricate, given the extensive data quantities, the involvement of numerous nodes, and the diverse configurations that may exist within your cluster.
An upgrade of an existing cluster can be done in two ways: through a rolling upgrade and through a full cluster restart. The benefit of a rolling upgrade is having zero downtime.
Bear in mind that any changes to your system could lead to data loss if the instructions are not adhered to accurately. Thoroughly test and strategize your upgrade, and ensure you create a backup of your data prior to executing any updates.
For guides on how to upgrade specific versions, see:
- How to Upgrade Elasticsearch from Version 5 to Version 6
- How to Upgrade Elasticsearch from Version 6 to Version 7
- How to Upgrade Elasticsearch from Version 7 to Version 8
What should I check before upgrading versions?
Elasticsearch nodes cannot be downgraded after upgrading. Before starting the upgrade process you should:
- Check the deprecation log and resolve any issues.
- Review the breaking changes to make sure you know of any functionalities which may changes or disappear. This would mainly affect node configuration, index mappings and templates, and cluster settings.
- Check the ES plugin compatibility to ensure they are compatible with the new version.
- Set up a test environment to test the upgrade process in a testing or staging environment first before upgrading your production cluster to avoid any issues.
- Take a backup and snapshots from your data, as the only way to “reverse” a failed upgrade is to create a new cluster with the old version and restore the data from snapshots.
How to perform offline upgrades – full cluster restart upgrades
A complete cluster restart upgrade involves simultaneously stopping all Elasticsearch nodes, updating them, and subsequently restarting each one. Inevitably, this upgrade approach will necessitate the downtime of your Elasticsearch cluster throughout the entire process.
Generally, offline upgrades are simpler than online ones because there’s no need to handle a cluster with varying node versions concurrently.
The steps are:
- Disable shard allocation
- Stop all Elasticsearch nodes and upgrade them
- Upgrade any plugins
- Start the Elasticsearch cluster
- Re-enable shard allocation
- Upgrade client libraries to new version
- Restart master eligible nodes
- Restart non-master eligible nodes
Keep in mind that during a full cluster restart, the master nodes need to be initiated prior to the non-master nodes. This is essential for allowing the master nodes to establish the cluster so that other nodes can join, which is in contrast to a rolling upstart where non-master nodes should be upgraded before the master nodes.
How to perform online upgrades – rolling restart upgrades
A rolling restart upgrade allows for updating a cluster without incurring any downtime. In this scenario, every node is sequentially upgraded and rebooted, without ever halting the entire Elasticsearch cluster.
Rolling restart upgrades cannot be performed when there is a change in MAJOR versions, except for specific exceptions:
- Upgrading Elasticsearch version 5.6.16 to version 6.x.x
- Upgrading Elasticsearch version 6.8.23 to version 7.x.x
- Upgrading Elasticsearch version 7.17.5 to version 8.x.x
For this reason, when performing a rolling restart upgrade between major versions, it is imperative to ALWAYS utilize the most recent minor version as an intermediary step for upgrading to the subsequent major version. For instance, if you are operating Elasticsearch 5.x.x, you can first update to 5.6.16 and then proceed to 6.8.23.
How to upgrade nodes in a rolling upgrade
The process for upgrading your nodes is as follows, upgrading all NON master-eligible nodes first.
- Make sure your cluster status is green and stable
Ensure that all replicas are available so that shutting down the node will not cause data loss.
- Disable unnecessary indexing
Wherever possible, you should stop all indexing processes to increase the cluster’s stability.
- Disable shard allocation
It is important to disable shard allocation so that when you stop a node for upgrade the cluster does not reallocate shards to another node. (See command below).
- Stop Elasticsearch
Stop Elasticsearch before moving on to the next step.
- Upgrade Elasticsearch
The method used to upgrade will depend upon your installation method.
- Upgrade plugins
Elasticsearch will not start if the plugin is not the same version as Elasticsearch.
- Start Elasticsearch
Start Elasticsearch before moving on to the next step.
- Re-enable shard allocation
Using the command given below.
- Check that the upgraded node has rejoined the cluster
Using the command below, you can check how many nodes are in the cluster.
- Wait for cluster status to turn green
The command provided below will also show you the progress of the shard recovery process on the upgraded node, until the cluster reaches a green state.
- Repeat
Repeat the full process above for each node.
To disable shard allocation, run:
PUT _cluster/settings { "persistent": { "cluster.routing.allocation.enable": "primaries" } }
To re-enable shard allocation, run:
PUT _cluster/settings { "persistent": { "cluster.routing.allocation.enable": null } }
Get cluster status and see how many nodes are in the cluster using:
GET _cluster/health
Common problems and important points
- The major problem with upgrades is version incompatibility. Elasticsearch supports rolling upgrades only between minor versions. You need to make sure to go through the official documentation to see if your cluster can support a rolling upgrade, otherwise a complete reindexing is required.
- Once you upgrade an Elasticsearch node, a rollback cannot be done. You need to make sure to backup your data before an upgrade.
- Elasticsearch continuously removes or deprecates some of its features with every release, so keep an eye on the change logs of each version before planning an upgrade.
- While doing a rolling upgrade, it is important to disable shard allocation before stopping a node and enable the shard allocation when node is upgraded and restarted. This process helps in avoiding unnecessary IO load in the cluster.
Log Context
Log “[{}] no upgrade needed – already upgraded” classname is IndexFolderUpgrader.java.
We extracted the following from Elasticsearch source code for those seeking an in-depth context :
// in a node path; which needs upgrading; it is a no-op for subsequent node paths if (Files.exists(customLocationSource) // might not exist if no data was written for this index && Files.exists(customLocationTarget) == false) { upgrade(index; customLocationSource; customLocationTarget); } else { logger.info("[{}] no upgrade needed - already upgraded"; customLocationTarget); } } upgrade(index; indexFolderPath; indexFolderPath.resolveSibling(index.getUUID())); } else { logger.debug("[{}] no upgrade needed - already upgraded"; indexFolderPath);
[ratemypost]