Log Lock assertion failed – How To Solve Related Issues



Log Lock assertion failed – How To Solve Related Issues

Opster Team

April-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 “Lock assertion failed” 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: node.


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 stores its data (shards, cluster state, etc.) on the file system and uses the path.data (config) to determine its data store location. There can be more than one Elaticsearch installation on the same node (host), and this error is thrown at startup time as part of the bootstrap checks to make sure there is no data corruption.

Potential causes for this error:

  1. Multiple Elasticsearch installations using the same data location.
  2. The node.max_local_storage_nodes setting is not set properly in the case of multiple Elasticsearch installations using the same location.
  3. An existing orphaned Elasticsearch process is already running, which uses the same location, and you are trying to start the new process.
  4. Elasticsearch doesn’t have write access to the data folder.

Exception message:

 
maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])
 

Troubleshooting steps: 

  1. If you do not have multiple installations on the same machine, check if there is already an Elasticsearch process running by using ps aux | grep elastic, on *nix based system, and kill the process if it is  not needed.
  2. To allow for more than one node (e.g., on your development machine, not recommended in production), use the setting node.max_local_storage_nodes and set this to a positive integer according to your requirement. Find more info in this official doc.
  3. Ensure the Elasticsearch process has write permission for the  path.data location.

Disclaimer: 

node.max_local_storage_nodes setting is deprecated in 7.x and will be removed in version 8.0.

Log Context

Log”Lock assertion failed” classname is NodeEnvironment.java
We extracted the following from Elasticsearch source code for those seeking an in-depth context :

         if (!closed.get() && locks != null) {
            for (Lock lock : locks) {
                try {
                    lock.ensureValid();
                } catch (IOException e) {
                    logger.warn("lock assertion failed"; e);
                    throw new IllegalStateException("environment is not locked"; e);
                }
            }
        }
    }




 

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 Elasticsearch, Failed to obtain node lock, is the following location writable -views 38.79 K ,score 50

elasticsearch fail to start gives erorr -views   3.97 K,score 4

 

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