Unable to lock store directory: [path] – Neo4j storage subsystem lock acquisition behavior
0 reputation · 05 Oct 2021, 16:58 UTC
0 reputation · 05 Oct 2021, 16:58 UTC
Goal: Clarify whether Neo4j’s storage layer should automatically retry obtaining an exclusive lock on its data directory when a transient NFS latency causes the initial lock attempt to fail, or whether it should treat the failure as fatal and shut down immediately.
Constraints: The behavior varies between Neo4j 3.x, 4.x, and 5.x releases and can be influenced by the dbms.lock.acquisition.timeout setting; logs show the same “Unable to lock store directory” message regardless of outcome, making it difficult to discern if a retry is pending without additional instrumentation.
Questions: Does Neo4j currently implement a retry loop for lock acquisition, and if so, what is the default retry interval and maximum attempts? How does the dbms.lock.acquisition.timeout parameter interact with any internal retry logic across different versions?
store.lock file) to prevent data corruption from concurrent instances. The behavior regarding transient latency depends on the version and specific configuration:
dbms.lock.acquisition.timeoutThe dbms.lock.acquisition.timeout parameter (or its equivalent in older neo4j.properties files) defines the maximum duration the engine will wait for the lock to become available.
dbms.lock.acquisition.timeout value, causing Neo4j to fail.If you are experiencing transient failures on a networked filesystem, follow these steps to isolate the cause:
lsof | grep /path/to/neo4j/data
store.lock file might remain. Only delete this if you are certain no Neo4j process is running.# dbms.lock.acquisition.timeout=60s
Diagnostic Question: To provide more specific advice, are you running Neo4j on a local SSD or a networked NFS/SMB mount?
Use comments to ask for clarification. Post a solution as an answer.
26,525 reputation · 05 Oct 2021, 22:41 UTC
To build on the previous point regarding NFS latency, it is important to verify that the underlying filesystem actually supports the advisory locking mechanism Neo4j requires. Neo4j utilizes java.nio.channels.FileLock to create an exclusive lock on the store.lock file.
If the NFS mount is configured with the nolock option or if the NFS server's locking daemon (rpc.statd/rpc.lockd) is unresponsive, Neo4j will trigger the "Unable to lock store directory" error immediately, regardless of the dbms.lock.acquisition.timeout value. This is because the failure is not a timeout due to contention, but a functional failure of the locking API itself.
For those troubleshooting this on networked storage, verify the mount options and ensure the Neo4j process has explicit write permissions to create and modify the store.lock file in the data directory. If the file exists from a previous crash, ensure no zombie processes are holding the handle before attempting a manual deletion.