Caused by: org.apache.solr.common.SolrException: Index locked for write for core
Asked Answered
R

9

25

We are using solr4.3 with master/slave setup, today I got the following error and solr stopped responding. What could be causing this,

 Caused by: org.apache.solr.common.SolrException: Index locked for write for core XXX
    at org.apache.solr.core.SolrCore.<init>(SolrCore.java:821)
    at org.apache.solr.core.SolrCore.<init>(SolrCore.java:618)
    at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:949)
    at org.apache.solr.core.CoreContainer.create(CoreContainer.java:984)
    at org.apache.solr.core.CoreContainer$2.call(CoreContainer.java:597)
    at org.apache.solr.core.CoreContainer$2.call(CoreContainer.java:592)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    ... 1 more
Caused by: org.apache.lucene.store.LockObtainFailedException: Index locked for write for core XX        at org.apache.solr.core.SolrCore.initIndex(SolrCore.java:484)
    at org.apache.solr.core.SolrCore.<init>(SolrCore.java:745)
    ... 13 more
Riant answered 3/7, 2013 at 9:35 Comment(0)
C
19

It seems the index has been locked during indexing.
Usually there would be a write.lock file within the index which needs to be removed to get it back.
The conditions can occur if the indexing breaks in between or other issues which may cause to lock file to be still in the index.

Check Forum

The write lock is due to the fact that an IndexWriter is always open in Solr even on the slaves.

Check for the Index Lock options which can handle the condition within configuration.

[An archived copy of the original link: https://web.archive.org/web/http://docs.lucidworks.com/display/solr/IndexConfig+in+SolrConfig ]

Cummine answered 3/7, 2013 at 9:54 Comment(4)
What I am unable to understand is this happened on the slave, I can understand the lock happening on the master. Why would a slave lock?Riant
Thanks Jayandra, I did read up the lockType and also the fact this might happen in an OOM situation. What lockType would you suggest for a slave which is being used by multipl webapps?Riant
you can check for unlockOnStartup which would remove the lock fine and prevent these issues.Cummine
Just to add to this, I was using kill -9 after issuing a ./shutdown.sh on tomcat, since tomcat was taking very long to shutdown. Still haven't found why tomcat is taking this long, but this seems to be adding to the behavior.Riant
M
25

Delete file write.lock in folder /data/index/ for your core then restart tomcat. It will work.

Magnitude answered 6/10, 2014 at 2:51 Comment(3)
how do I go to this path /data/indexThermogenesis
It's in your solr folder: /path/to/home/solr/your_core/data/index/Magnitude
This advice seems dubiously wise.Lvov
C
19

It seems the index has been locked during indexing.
Usually there would be a write.lock file within the index which needs to be removed to get it back.
The conditions can occur if the indexing breaks in between or other issues which may cause to lock file to be still in the index.

Check Forum

The write lock is due to the fact that an IndexWriter is always open in Solr even on the slaves.

Check for the Index Lock options which can handle the condition within configuration.

[An archived copy of the original link: https://web.archive.org/web/http://docs.lucidworks.com/display/solr/IndexConfig+in+SolrConfig ]

Cummine answered 3/7, 2013 at 9:54 Comment(4)
What I am unable to understand is this happened on the slave, I can understand the lock happening on the master. Why would a slave lock?Riant
Thanks Jayandra, I did read up the lockType and also the fact this might happen in an OOM situation. What lockType would you suggest for a slave which is being used by multipl webapps?Riant
you can check for unlockOnStartup which would remove the lock fine and prevent these issues.Cummine
Just to add to this, I was using kill -9 after issuing a ./shutdown.sh on tomcat, since tomcat was taking very long to shutdown. Still haven't found why tomcat is taking this long, but this seems to be adding to the behavior.Riant
P
1

If you are using Rails,

just add into solr.xml this line

<lockType>simple</lockType>

its works for me)

Pilose answered 5/7, 2017 at 18:25 Comment(5)
What does it do? Please provide some documentation about this configuration value. Does it have any side effects Techie should know about? What does it have to do with rails?Moller
documentation is here cwiki.apache.org/confluence/display/solr/… see "lockType" therePilose
I've added it to the post, but I still don't get what it has to do with rails. Solr is solr - Rails is a programming language.Moller
its works for me I think that I have some bug in my Solr config or installationPilose
Not using rails, but worked for me. Restarted solr and problem solved!Bureaucratic
S
1

In some times this occurs because current user dont have permission in directory. Try using root and using -force for start solr.

Save answered 19/12, 2017 at 17:54 Comment(1)
oh no! looks like you posted the answer before finishing your sentence! Not to worry, you can always edit it to finish it. If you already have, ignore this comment. Edits don't show up right away, they have to be reviewed first, even on your own posts, which is a little silly, so I and the OP can't see your edit yet if it exists.Multivalent
T
1

In my case this error occured when i try to create a new core in the path containing the index of an existing core e.g

/data/index/

This happened because i had changed the solrconfig.xml index data directory to move the default path to another location i called:

<dataDir>/data/index/</dataDir>

So reusing the solrconfig.xml to create a new core causes the error. Changing this to:

<dataDir>${solr.data.dir}/${solr.core.name}</dataDir>

Causes the index of a new core to be created in a path related to its core name and so write.lock permission issues with the index of an exisitng core are not encountered during the creation of the new core

Togliatti answered 19/1, 2022 at 9:53 Comment(0)
E
0

Try to use : container.shutdown() after the indexing, it works if you want to update/search again without removing the file "write.lock".

Explorer answered 27/2, 2018 at 9:23 Comment(0)
P
0

check if the permissions are for root and change the permissions of the core files

Patino answered 7/7, 2021 at 13:57 Comment(0)
V
0

Most likely this is due to files having the wrong ownership. Check permissions and ownerships.

If you still encounter error having done the above tasks, you may want to see the below;

Delete file write.lock in folder /data/index/ for your core then restart Tomcat Server.

Restart Tomcat Server in Linux:

<Tomcat Root>/bin>./catalina.sh stop

<Tomcat Root>/bin>./catalina.sh start
Venn answered 13/10, 2022 at 7:7 Comment(0)
A
0

As per the wso2 documentation,

It is not recommended to share the Solr directory between the Store and Publisher servers. You need to have separate Solr directories for each of the latter mentioned servers so that they will perform Solr indexing separately.

Reference: wso2am deployment documentation

So we can unmount the /solr directory if it's shared among the multiple nodes, that will solve the issue.

Ardolino answered 14/5 at 7:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.