Failed to obtain node locks

java.lang.IllegalStateException: failed to obtain node locks, tried [[C:\Users\AnilY\Downloads\sonarqube-8.8.0.42792\sonarqube-8.8.0.42792\data\es7]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
at org.elasticsearch.env.NodeEnvironment.(NodeEnvironment.java:292)
at org.elasticsearch.node.Node.(Node.java:351)
at org.elasticsearch.node.Node.(Node.java:278)
at org.elasticsearch.bootstrap.Bootstrap$5.(Bootstrap.java:216)
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:216)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:387)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159)
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150)
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:75)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:116)
at org.elasticsearch.cli.Command.main(Command.java:79)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:81)

Hi,

Welcome to the community!

I’ve moved your post to a new topic since the one you added to was 3 years old. Please add some details here. Simply dumping a partial stacktrace doesn’t help us help you.

 
Ann

Can someone pls help me with issue.
I am stuck since long time.

What more info is required.
Version:7.9.6
Java 11 is used.

Hi @Anil_Kumar1 ,

the error message you posted suggests that elasticsearch is not able to acquire a lock for its data directory (C:\Users\AnilY\Downloads\sonarqube-8.8.0.42792\sonarqube-8.8.0.42792\data\es7). this can be caused by a few circumstances as

  • there is another sonarqube instance already running that is holding this lock
  • the location is not writable by sonarqube
  • a sonarqube instance crashed so badly that it could not remove the lock

i assume that this is currently only a test instance without much data in there, so after checking that there is no other sonarqube instance running and that sonarqube is able to write to this folder, you can simply delete the es7 folder as it will be recreated by sonarqube on start.

if you have not switched your sonarqube version in the mean time i assume this is on version 8.0 and not 7.9.6 as 7.9.6 shipped es6

As @Tobias_Trabelsi mentioned you need to remove es7 folder in node lock situation, I just handle that by defining new extraInitContainer:

extraInitContainers: 
  - name: "fix-elastic-error-lock-issue"
      image: "busybox"
      imagePullPolicy: "IfNotPresent"
      command: ["rm", "-rf", "/opt/sonarqube/data/es7"]
      volumeMounts:
        - mountPath: /opt/sonarqube/data
          name: sonarqube
          subPath: es7
4 Likes

It worked for me . Thank you @Mehdi_Hosseini

1 Like