Search code examples
javadatabaseluceneconnection-pooling

Why does this exception happen? Lucene exception


Our application is crashing every 2 hours or so and we are seeing a spike in database connections right before it. have not isolated the issue yet.

Can someone respond what the exception below really mean and can it spike DB connection issues.

Thank you.

org.compass.core.engine.SearchEngineException: Failed to open writer for sub index [premiumobjectmessage]; nested exception is org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: SimpleFSLock@/opt/compass/index/premiumobjectmessage/lucene-9af515d29c67db8ae587aab2becbc6f3-write.lock
org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: SimpleFSLock@/opt/compass/index/premiumobjectmessage/lucene-9af515d29c67db8ae587aab2becbc6f3-write.lock
org.compass.core.engine.SearchEngineException: Failed to open writer for sub index [premiumobjectmessage]; nested exception is org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: SimpleFSLock@/opt/compass/index/premiumobjectmessage/lucene-9af515d29c67db8ae587aab2becbc6f3-write.lock
org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: SimpleFSLock@/opt/compass/index/premiumobjectmessage/lucene-9af515d29c67db8ae587aab2becbc6f3-write.lock
org.compass.core.engine.SearchEngineException: Failed to open writer for sub index [premiumobjectmessage]; nested exception is org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: SimpleFSLock@/opt/compass/index/premiumobjectmessage/lucene-9af515d29c67db8ae587aab2becbc6f3-write.lock
org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: SimpleFSLock@/opt/compass/index/premiumobjectmessage/lucene-9af515d29c67db8ae587aab2becbc6f3-write.lock

Solution

  • This stems from multiple threads/processes wanting to open the same FSDirectory. Maybe each thread that has its own DB connection also makes its own IndexReader, which would be a wrong approach. IndexReaders/IndexSearchers must be pooled just like the DB connections themselves, preferrably using NRTManager.