Lucene deadlocks bring down the whole system

Hello there!

I am currently using Openfire 4.9.2 with openJDK 17 on Debian 12. According to my performance monitoring, my system experiences severe disk I/O spikes and system downtime whenever the following error occurs. I have not found any relevant configurations in the Openfire web console related to Lucene, even after removing all plugins, the issue persists.

Could anyone please advise on how to address this issue? Any guidance on potential causes or solutions would be greatly appreciated.

2025.04.25 00:52:12.275 e[1;31mERRORe[m [pool-monitoring1586]: org.jivesoftware.openfire.archive.ArchiveIndexer[CONVERSATION] - An exception occurred while updating the Lucene index.
org.apache.lucene.store.LockObtainFailedException: Lock held by this virtual machine: /usr/share/openfire/monitoring/search/write.lock
	at org.apache.lucene.store.NativeFSLockFactory.obtainFSLock(NativeFSLockFactory.java:139) ~[lucene-core-8.4.0.jar:8.4.0 bc02ab906445fcf4e297f4ef00ab4a54fdd72ca2 - jpountz - 2019-12-19 20:16:14]
	at org.apache.lucene.store.FSLockFactory.obtainLock(FSLockFactory.java:41) ~[lucene-core-8.4.0.jar:8.4.0 bc02ab906445fcf4e297f4ef00ab4a54fdd72ca2 - jpountz - 2019-12-19 20:16:14]
	at org.apache.lucene.store.BaseDirectory.obtainLock(BaseDirectory.java:45) ~[lucene-core-8.4.0.jar:8.4.0 bc02ab906445fcf4e297f4ef00ab4a54fdd72ca2 - jpountz - 2019-12-19 20:16:14]
	at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:729) ~[lucene-core-8.4.0.jar:8.4.0 bc02ab906445fcf4e297f4ef00ab4a54fdd72ca2 - jpountz - 2019-12-19 20:16:14]
	at org.jivesoftware.openfire.index.LuceneIndexer.updateIndex(LuceneIndexer.java:308) [monitoring-2.6.1.jar:?]
	at org.jivesoftware.openfire.index.LuceneIndexer$1.run(LuceneIndexer.java:184) [monitoring-2.6.1.jar:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
	at java.lang.Thread.run(Thread.java:840) [?:?]
2025.04.25 00:52:12.304 e[1;31mERRORe[m [pool-monitoring1592]: org.jivesoftware.openfire.archive.ArchiveIndexer[MESSAGE] - An exception occurred while updating the Lucene index.
org.apache.lucene.store.LockObtainFailedException: Lock held by this virtual machine: /usr/share/openfire/monitoring/msgsearch/write.lock
	at org.apache.lucene.store.NativeFSLockFactory.obtainFSLock(NativeFSLockFactory.java:139) ~[lucene-core-8.4.0.jar:8.4.0 bc02ab906445fcf4e297f4ef00ab4a54fdd72ca2 - jpountz - 2019-12-19 20:16:14]
	at org.apache.lucene.store.FSLockFactory.obtainLock(FSLockFactory.java:41) ~[lucene-core-8.4.0.jar:8.4.0 bc02ab906445fcf4e297f4ef00ab4a54fdd72ca2 - jpountz - 2019-12-19 20:16:14]
	at org.apache.lucene.store.BaseDirectory.obtainLock(BaseDirectory.java:45) ~[lucene-core-8.4.0.jar:8.4.0 bc02ab906445fcf4e297f4ef00ab4a54fdd72ca2 - jpountz - 2019-12-19 20:16:14]
	at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:729) ~[lucene-core-8.4.0.jar:8.4.0 bc02ab906445fcf4e297f4ef00ab4a54fdd72ca2 - jpountz - 2019-12-19 20:16:14]
	at org.jivesoftware.openfire.index.LuceneIndexer.updateIndex(LuceneIndexer.java:308) [monitoring-2.6.1.jar:?]
	at org.jivesoftware.openfire.index.LuceneIndexer$1.run(LuceneIndexer.java:184) [monitoring-2.6.1.jar:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
	at java.lang.Thread.run(Thread.java:840) [?:?]

Hi Jeff,

Sorry to hear about this. That’s concerning. Are you sure that this is a cause or consequence? Can you reproduce the behavior? Have you applied changes to the Openfire or Monitoring plugin source code that is running on your server?

Although it won’t prevent the issue, the way to resolve an occurrence is to shut down Openfire, then delete the file /usr/share/openfire/monitoring/search/write.lock (probably any *.lock file under /usr/share/openfire/monitoring/) and restart.