How To Solve Issues Related to Log – Refreshing metadata failed

Prevent ES settings related problems

Check if your ES issues are caused from misconfigured settings

Resolve Issue

Updated: Jan-20

In Page Navigation (click to jump) :
Troubleshooting Background       
Related Issues  
Log Context
About Opster

Opster Offer’s World-Class Elasticsearch Expertise In One Powerful Product
Try Our Free Check-Up   Prevent Incident

Troubleshooting background

To troubleshoot Elasticsearch log “Refreshing metadata failed” it’s important to understand common problems related to Elasticsearch concepts: metadata, plugin. See detailed explanations below complete with common problems, examples and useful tips.

Metadata in Elasticsearch

What it is

Metadata in Elasticsearch refers to storing some additional information for each document. This is achieved using the specific metadata fields available in Elasticsearch. The default behavior of some of these metadata fields can be customized during mapping creation.

Examples

Using _meta meta-field for storing application-specific information with the mapping:

PUT /my_index?pretty
{
  "mappings": {
    "_meta": { 
      "domain": "security",
      "release_information": {
        "date": "18-01-2020",
        "version": "7.5"
      }
    }
  }
}

Notes
  • In version 2.x, Elasticsearch had a total 13 meta fields available, which are: _index, _uid, _type, _id, _source, _size, _all, _field_names, _timestamp, _ttl, _parent, _routing, _meta
  • In version 5.x, _timestamp and _ttl meta fields were removed.
  • In version 6.x, the _parent meta field was removed.
  • In version 7.x, _uid and _all meta fields were removed.

Plugin in Elasticsearch

What it is

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 the instructions for the plugin usage
sudo bin/elasticsearch-plugin -h
  • Installing S3 plugin using URL 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 path
sudo bin/elasticsearch-plugin install file:///path/to/plugin.zip

Notes:
  • Plugins are installed and removed using the elasticsearch-plugin script, which ships as a part of 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 Problems:
  • Managing permission issues during and after plugin installation is the most common problem. If Elasticsearch was installed using the deb or rpm package then the plugin has to be installed using the root user, or else you can install the plugin as the user that owns all of the Elasticsearch files.
  • In case of deb or rpm package installation, it is important to check the permission of the plugins directory after plugin installation and 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 at once 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.

Refresh in Elasticsearch


What it is

When indexing data, Elasticsearch requires a “refresh” operation to make indexed information available for search. This means that there is a time delay between indexing and the updated information actually becoming available for the client applications.

How it works

Index operations occur in memory. The operations are accumulated in a buffer until refreshed, which requires that the buffer be transferred to a newly created lucene segment. Refresh happens by default every second, but it is also possible to change this frequency for a given index, or directly request a refresh through the refresh api.

Examples

You can set the refresh interval on an index like this:

PUT /my_index/_settings
{
    "index" : {
        "refresh_interval" : "30s"
    }
}

You can use a value of -1 to represent “no refresh” but remember to set it back once you’ve finished indexing!

You can force a refresh on a given index like this:

POST my_index/_refresh

You can also force a refresh at the end of an index operation by adding an extra parameter in the url like this:

POST /my_index/_index?refresh=waitfor

In this case, the “waitfor” parameter will force the client to wait for the refresh to complete before returning (useful in scripts), or you can use “true” to force the refresh without keeping the script waiting.

Notes and good things to know:

Refreshing is resource-intensive, so you can increase indexing speed by reducing the refresh rate. You can do this temporarily if you need to reload a lot of data, or for some logging applications it is perfectly acceptable to have, say, a 30s latency before data actually becomes available.

Beware of the refresh interval when scripting or updating. Scripts often work faster than the refresh interval, so if necessary, you might need to call a refresh before retrieving or updating data in your scripts, or use the waitfor parameter while indexing as described above.


To help troubleshoot related issues we have gathered selected Q&A from the community and issues from Github , please review the following for further information :

1 Elasticsearch One Shard Of The Inde  

2 Nullpointerexception Failed To Dyna    

Github Issue Number 2633


Log Context

Log ”Refreshing metadata failed” classname is TokenService.java
We have extracted the following from Elasticsearch source code to get an in-depth context :

             if (custom != null && custom.equals(getTokenMetaData()) == false) {
                logger.info("refresh keys");
                try {
                    refreshMetaData(custom);
                } catch (Exception e) {
                    logger.warn("refreshing metadata failed"; e);
                }
                logger.info("refreshed keys");
            }
        });
    }






About Opster

Incorporating deep knowledge and broad history of Elasticsearch issues. Opster’s solution identifies and predicts root causes of Elasticsearch problems, provides recommendations and can automatically perform various actions to manage, troubleshoot and prevent issues.

Learn more: Glossary | Blog| Troubleshooting guides | Error Repository

Need help with any Elasticsearch issue ? Contact Opster

Did this page help you?