Dangling index exists on local file system but not in cluster metadata auto import to cluster state – How to solve this Elasticsearch error

Opster Team

Aug-23, Version: 2.3-2.3

Briefly, this error occurs when Elasticsearch detects indices on the local file system that are not present in the cluster metadata. This could be due to a node restart or a failed deletion. To resolve this, you can manually delete the dangling index files from the data directory of the node. Alternatively, you can use the Elasticsearch API to import the dangling index into the cluster if the data is still needed. Lastly, you can adjust the “gateway.auto_import_dangling_indices” setting to automatically import these indices, but this may have performance implications.

This guide will help you check for common problems that cause the log ” [{}] dangling index; exists on local file system; but not in cluster metadata; auto import to cluster state ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: cluster, dangling, discovery-file and indices.

Log Context

Log “[{}] dangling index; exists on local file system; but not in cluster metadata; auto import to cluster state” classname is DanglingIndicesState.java.
We extracted the following from Elasticsearch source code for those seeking an in-depth context :

         for (String indexName : indices) {
            if (metaData.hasIndex(indexName) == false && danglingIndices.containsKey(indexName) == false) {
                try {
                    IndexMetaData indexMetaData = metaStateService.loadIndexState(indexName);
                    if (indexMetaData != null) {
                        logger.info("[{}] dangling index; exists on local file system; but not in cluster metadata; auto import to cluster state"; indexName);
                        if (!indexMetaData.getIndex().equals(indexName)) {
                            logger.info("dangled index directory name is [{}]; state name is [{}]; renaming to directory name"; indexName; indexMetaData.getIndex());
                            indexMetaData = IndexMetaData.builder(indexMetaData).index(indexName).build();
                        }
                        newIndices.put(indexName; indexMetaData);




 

 [ratemypost]