Unable to start Confluence or enable the Usage Stats plugin due to 'Cannot forcefully unlock a NativeFSLock' error

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Problem

Confluence fails to start and the following (or similar) appears in the atlassian-confluence.log:

1 2 3 4 5 2020-04-02 02:06:18,396 ERROR [localhost-startStop-1] [springframework.web.context.ContextLoader] initWebApplicationContext Context initialization failed ... Caused by: org.apache.lucene.store.LockReleaseFailedException: Cannot forcefully unlock a NativeFSLock which is held by another indexer component: D:\Confluence\Confluence_Home\index\write.lock

Alternatively, Confluence does start up, but the Usage Stats plugin cannot be enabled. This results in missing 'Popular Content' or missing 'Usage Stats' macro, and the following (or similar) stack trace on the logs:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 2014-12-08 11:55:26,116 ERROR [localhost-startStop-1] [atlassian.plugin.manager.DefaultPluginManager] enableConfiguredPluginModule There was an error loading the descriptor 'Usage Index Manager' of plugin 'com.atlassian.confluence.ext.usage'. Disabling. com.atlassian.bonnie.LuceneException: org.apache.lucene.store.LockReleaseFailedException: Cannot forcefully unlock a NativeFSLock which is held by another indexer component: /var/local/confluencedata/index/plugin/usage/write.lock at com.atlassian.bonnie.LuceneConnection.<init>(LuceneConnection.java:112) at com.atlassian.bonnie.LuceneConnection.<init>(LuceneConnection.java:120) at com.atlassian.bonnie.LuceneConnection.<init>(LuceneConnection.java:135) at com.atlassian.bonnie.LuceneConnection.<init>(LuceneConnection.java:140) at com.atlassian.confluence.ext.usage.index.UsageIndexManager.enabled(UsageIndexManager.java:90) at com.atlassian.confluence.plugin.descriptor.ComponentModuleDescriptor.enabled(ComponentModuleDescriptor.java:84) at com.atlassian.plugin.manager.DefaultPluginManager.notifyModuleEnabled(DefaultPluginManager.java:1955) at com.atlassian.plugin.manager.DefaultPluginManager.enableConfiguredPluginModule(DefaultPluginManager.java:1747) at com.atlassian.plugin.manager.DefaultPluginManager.enableConfiguredPluginModules(DefaultPluginManager.java:1714) at com.atlassian.plugin.manager.DefaultPluginManager.addPlugins(DefaultPluginManager.java:1111) at com.atlassian.plugin.manager.DefaultPluginManager.lateStartup(DefaultPluginManager.java:483) at com.atlassian.confluence.plugin.ConfluencePluginManager.lateStartup(ConfluencePluginManager.java:136) at com.atlassian.plugin.manager.DefaultPluginManager.init(DefaultPluginManager.java:350) at com.atlassian.confluence.plugin.PluginFrameworkContextListener.contextInitialized(PluginFrameworkContextListener.java:59) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: org.apache.lucene.store.LockReleaseFailedException: Cannot forcefully unlock a NativeFSLock which is held by another indexer component: /var/local/confluencedata/index/plugin/usage/write.lock

Diagnosis

Unix users can run the lsof and ls commands to determine ownership of the file

1 2 3 4 5 6 $ lsof /var/local/confluencedata/index/plugin/usage/write.lock COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME java 9939 confluence 303uW REG 0,44 0 17040070 /var/local/confluencedata/index/plugin/usage/write.lock   $ ls -laF /var/local/confluencedata/index/plugin/usage/write.lock -rw-rw-r-- 1 confluence confluence 2460 Oct 9 10:34 /var/local/confluencedata/index/plugin/usage/write.lock

Cause

Confluence prevents multiple instances from running on the same server and as such, creates lock files for itself. However, when this error happens, it means Confluence is unable to write on the write.lock file. This can happen for two reasons:

  • Permission issues, such as on the Diagnosis section above - please ensure the permissions over the Confluence directories (and the write.lock file) are correct

  • These files aren't properly removed if Confluence is shut down using an alternative method other than using the stop-confluence script (if running Confluence manually), or stopping the service (if running Confluence as a service).

    • For example, this issue can happen if the server/application crashes, or the Confluence process is forcefully terminated. A restarting Confluence instance won't start if it detects these leftover lock files.

  • Such a problem has also been noticed whilst having multiple Confluence Windows Service running and writing in the Home Directory

Resolution

  1. Shutdown Confluence.

  2. Navigate to the path mentioned into the stack trace and delete the write.lock file.

    In the above stack traces, the paths would be 'D:\Confluence\Confluence_Home\index\write.lock', or '/var/local/confluencedata/index/plugin/usage/write.lock' for example.

  3. Check the permissions of the Confluence Home directory, to make sure they match the user running Confluence

  4. (Optional) If running on a Windows OS: Check that you don't have multiple services running on the same instance for the same Confluence site. Disable the duplicates services to only keep the most recent one created running

  5. Start Confluence.

  6. If the error persists:

    1. Shutdown Confluence again.

    2. Delete the file one more time.

    3. Run the steps of the Rebuilding Confluence Index from the scratch guide.

    4. Try starting Confluence one more and if the application starts go to Confluence Admin > Content Indexing.

    5. Click the Rebuild button.

Updated on April 16, 2025

Still need help?

The Atlassian Community is here for you.