Opster Team
Before you begin reading this guide, we recommend you run Elasticsearch Error Check-Up which analyzes 2 JSON files to detect many errors.
To easily locate the root cause and resolve this issue try AutoOps for Elasticsearch & OpenSearch. It diagnoses problems by analyzing hundreds of metrics collected by a lightweight agent and offers guidance for resolving them. Take a self-guided product tour to see for yourself (no registration required).
This guide will help you check for common problems that cause the log ” Failed to start working on role alias permisssion deprecation messages ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: alias, deprecation and plugin.
Quick links:
- Overview – Data Stream Aliases and Index Aliases
- Creating and removing aliases
- Alias use cases
- Notes and common problems
Overview
In Elasticsearch, an alias is a secondary name given that refers to a group of data streams or indices. Aliases can be created and removed dynamically using _aliases REST endpoint.
There are two types of aliases:
- Data Stream Aliases: An alias for a data stream refers to one or more data streams. The names of data streams will be referred to by data stream aliases. In the cluster state, data stream aliases are kept distinct from data streams.
- Index Aliases: An index alias points to one or more indices.
The master node manages the cluster state, which includes aliases.
Creating and removing aliases
Creating an alias on a single index:
POST /_aliases?pretty { "actions": [ { "add": { "index": "index_1", "alias": "alias_1" } } ] }
Creating an alias that is tied to more than one index:
POST /_aliases?pretty { "actions": [ { "add": { "index": "index_1", "alias": "alias_1" } }, { "add": { "index": "index_2", "alias": "alias_1" } } ] }
Listing out all of the available aliases in an Elasticsearch cluster:
GET _cat/aliases
Removing an alias:
POST /_aliases?pretty { "actions": [ { "remove": { "index": "index_2", "alias": "alias_1" } } ] }
Alias use cases
Aliases are used for multiple purposes such as to search across more than one index with a single name, perform the reindexing process with zero downtime and query data based on predefined filters. Below are 6 different use cases for aliases.
1. Filter-based aliases to limit access to data
One use case is making a filter-based alias, which is quite useful when you need to limit access to data. When a query is executed, an alias can apply a filter automatically.
For example, consider an index named `opster-idx`, having an alias that points to the groups that contain the `opster` company, so you can create an alias that handles this filtering automatically as shown in the steps below.
Index documents:
PUT /opster-idx/_doc/1 { "title": "Taking Care of Your Entire Search Operation", "company": "Opster" }
PUT /opster-idx/_doc/2 { "title": "Streaming service", "company": "XYZ" }
Add the query to the actions in the `filter` param to create a filter alias. The query here is used to limit the documents that the alias can access.
POST /_aliases?pretty { "actions": [ { "add": { "index": "opster-idx", "alias": "opster-alias", "filter": { "term": { "company": "opster" } } } } ] }
While you perform a match-all query on `opster-alias`, only the documents that match the term query (which was added when building filter alias, i.e. documents with company name equal to `opster`) will appear in the search results.
Search query:
GET opster-alias/_search { "query":{ "match_all":{} } }
Search response:
"hits": { "total": { "value": 1, "relation": "eq" }, "max_score": 1.0, "hits": [ { "_index": "opster-idx", "_id": "1", "_score": 1.0, "_source": { "title": "Taking Care of Your Entire Search Operation", "company": "Opster" } } ] }
Now if you try to query those documents that have the company name, “XYZ”, as follows:
GET opster-alias/_search { "query": { "match": { "company": "XYZ" } } }
The search response will be:
"hits": { "total": { "value": 0, "relation": "eq" }, "max_score": null, "hits": [] }
2. Combining routing with aliases
When searching and indexing, the following example will filter out the company `opster` and add `1` to the route to limit where searches are done.
Routing is a string value that is used to route indexing and search operations to a specific shard.
POST /_aliases?pretty { "actions": [ { "add": { "index": "index_1", "alias": "alias_2", "filter": { "term": { "company": "opster" } }, "routing": "1" } } ] }
3. Transitioning to new indices
You can use aliases when your application needs to seamlessly transition from an old index to a new index with no downtime.
4. Creating sliding windows into distinct indices
For example, if you construct daily indices for your data, you might wish to establish an alias named `last-7-days` to produce a sliding window of the data from the previous seven days. Then, each day, when you create a new daily index, you may add it to the alias and delete the 8-day old index at the same time.
5. Aliases and ILM for updating or deleting documents
You can use an index alias and index template with ILM to manage and roll over the alias’s indices if you need to update or delete existing documents across numerous indices frequently.
6. Querying data from a frozen index
When using ILM, If you still need to query data from a frozen index, you can use the alias to do so. Instead of searching for data directly through that index, you may run a search query on the alias, which will increase performance and allow you to get a response with fewer resources.
Notes
- An Alias cannot be used for the indexing process if it points to more than one index. If attempted, Elasticsearch will throw an exception.
- Deleting an alias does not delete the actual index.
Common problems
When you try to index a document into an alias that points to more than one index, Elasticsearch returns an error because it doesn’t know which concrete index the document should be indexed to.
You will get the following error message:
{ "error" : { "root_cause" : [ { "type" : "illegal_argument_exception", "reason" : "no write index is defined for alias [my-alias]. The write index may be explicitly disabled using is_write_index=false or the alias points to multiple indices without one being designated as a write index" } ], "type" : "illegal_argument_exception", "reason" : "no write index is defined for alias [my-alias]. The write index may be explicitly disabled using is_write_index=false or the alias points to multiple indices without one being designated as a write index" }, "status" : 400 }
For a full troubleshooting guide on how to resolve this error, see here.
Overview
Deprecation refers to processes and functions that are in the process of being eliminated and (possibly) replaced by newer ones.
Typically, a function will not disappear from one version to the next without warning. Normally this will happen across a number of versions. When you use a deprecated function in intermediate versions, it will continue to work as before, but you will receive warnings that the function in question is intended to disappear in the future.
How it works
There are a number of ways you can find out which functions have been deprecated, including: deprecation logs, reading the breaking pages documentation and paying attention to warnings.
In a deprecation log:
{"type": "deprecation", "timestamp": "2020-01-16T12:50:11,263+0000", "level": "WARN", "component": "o.e.d.r.a.d.RestDeleteAction", "cluster.name": "docker-cluster", "node.name": "es01", "cluster.uuid": "VGTYFgunQ_STTKVz6YHAGg", "node.id": "wh5J7TJ-RD-pJE4JOUjVpw", "message": "[types removal] Specifying types in document index requests is deprecated, use the typeless endpoints instead (/{index}/_doc/{id}, /{index}/_doc, or /{index}/_create/{id})." }
Reading the breaking changes documentation for each version:
https://www.elastic.co/guide/en/elasticsearch/reference/7.5/breaking-changes-7.0.html
In kibana you may also see a warning if you run a deprecated command in the development panel:
#! Deprecation: [types removal] Specifying types in document index requests is deprecated, use the typeless endpoints instead (/{index}/_doc/{id}, /{index}/_doc, or /{index}/_create/{id}).
It is important to act upon these warnings. Although your application still works, ignoring the warnings will almost certainly cause things to malfunction in a future upgrade.
Deprecation API
There is a depreciation API, which can help point you to deprecated functions on your cluster:
Version 5.6-6.8 | GET /_xpack/migration/deprecations |
Version 7 | GET /_migration/deprecations |
However, you should never depend on the deprecation API alone. Just because the API returns with no issues, it does not mean that everything in your setup will work out of the box when migrating! This is to be used in addition to looking through the deprecation log and breaking changes documentation.
Examples
- The removal of document types (“_type”) . Various document types were allowed in a single index in version 6, but this functionality has been removed. You will get warnings if you use document types in queries, and only 1 document type is allowed per index in version 7. The functionality is expected to be completely removed in version 8.
- The discovery.zen.minimum_master_nodes setting is permitted, but ignored, on 7.x nodes.
There are many more examples to be found in the breaking changes documentation.
Notes and good things to know
It is important to visit ALL the breaking changes for each minor version between the version you are using and the version you want to upgrade to.
https://www.elastic.co/guide/en/elasticsearch/reference/7.3/breaking-changes-7.3.html
Contains information that is not mentioned on the next page.
https://www.elastic.co/guide/en/elasticsearch/reference/7.5/breaking-changes-7.4.html
The best way is to go to the “breaking changes” page of the version you want to upgrade to, and then use the links to page look through all of the minor version pages down to the one you want to upgrade from, paying particular attention to the major version change (eg. 7.0 )
Opster supports all Elasticsearch versions so If you need help reach out
Overview
A plugin is used to enhance the core functionalities of Elasticsearch. Elasticsearch provides some core plugins as a part of their release installation. In addition to those core plugins, it is possible to write your own custom plugins as well. There are several community plugins available on GitHub for various use cases.
Examples
Get all of the instructions for the plugin:
sudo bin/elasticsearch-plugin -h
Installing the S3 plugin for storing Elasticsearch snapshots on S3:
sudo bin/elasticsearch-plugin install repository-s3
Removing a plugin:
sudo bin/elasticsearch-plugin remove repository-s3
Installing a plugin using the file’s path:
sudo bin/elasticsearch-plugin install file:///path/to/plugin.zip
Notes and good things to know
- Plugins are installed and removed using the elasticsearch-plugin script, which ships as a part of the Elasticsearch installation and can be found inside the bin/ directory of the Elasticsearch installation path.
- A plugin has to be installed on every node of the cluster and each of the nodes has to be restarted to make the plugin visible.
- You can also download the plugin manually and then install it using the elasticsearch-plugin install command, providing the file name/path of the plugin’s source file.
- When a plugin is removed, you will need to restart every Elasticsearch node in order to complete the removal process.
Common issues
- Managing permission issues during and after plugin installation is the most common problem. If Elasticsearch was installed using the DEB or RPM packages then the plugin has to be installed using the root user. Otherwise you can install the plugin as the user that owns all of the Elasticsearch files.
- In the case of DEB or RPM package installation, it is important to check the permissions of the plugins directory after you install it. You can update the permission if it has been modified using the following command:
chown -R elasticsearch:elasticsearch path_to_plugin_directory
- If your Elasticsearch nodes are running in a private subnet without internet access, you cannot install a plugin directly. In this case, you can simply download the plugins and copy the files inside the plugins directory of the Elasticsearch installation path on every node. The node has to be restarted in this case as well.
Log Context
Log “Failed to start working on role alias permisssion deprecation messages” classname is DeprecationRoleDescriptorConsumer.java.
We extracted the following from Elasticsearch source code for those seeking an in-depth context :
workerBusy = true; // just being paranoid :) try { threadPool.generic().execute(this); } catch (RejectedExecutionException e1) { workerBusy = false; logger.warn("Failed to start working on role alias permisssion deprecation messages"; e1); } } else { workerBusy = false; } }
Find & fix Elasticsearch problems
Opster AutoOps diagnoses & fixes issues in Elasticsearch based on analyzing hundreds of metrics.
Fix Your Cluster IssuesConnect in under 2 minutes
Billy McCarthy
Senior SysAdmin at Backblaze