I am trying to evaluate different datamodels in Neo4j. For that reason I have created two databases which have those different models and saved them in the same directory:
path/to/database/graphModel1
path/to/database/graphModel2
The next step is that I have created an application with java where I can select the datamodel and the query I want to evaluate (there are only a few predefined queries). Depending which model was selected I want to use the instance of the embedded database. At the moment I use the following if-clause to distinguish between them:
if (model.equals("G1")) {
graph = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH_1);
} else if (model.equals("G2")) {
graph = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH_2);
}
registerShutdownHook(graph);
But using that snippet of code I got the following exception after I did the first query with model1 and want to compute the same query with model2:
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.StoreLockerLifecycleAdapter@1f1e9b8' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:513)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:115)
at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:330)
... 69 more
Caused by: org.neo4j.kernel.StoreLockException: Unable to obtain lock on store lock file: path/to/database/graphModel1/store_lock. Please ensure no other process is using this database, and that the directory is writable (required even for read-only access)
at org.neo4j.kernel.StoreLocker.checkLock(StoreLocker.java:78)
at org.neo4j.kernel.StoreLockerLifecycleAdapter.start(StoreLockerLifecycleAdapter.java:44)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:507)
... 71 more
Caused by: java.io.IOException: Couldn't lock lock file path/to/database/graphModel1/lock because another process already holds the lock.
at org.neo4j.io.fs.FileLock.getLockFileBasedFileLock(FileLock.java:126)
at org.neo4j.io.fs.FileLock.getOsSpecificFileLock(FileLock.java:70)
at org.neo4j.io.fs.DefaultFileSystemAbstraction.tryLock(DefaultFileSystemAbstraction.java:85)
at org.neo4j.kernel.StoreLocker.checkLock(StoreLocker.java:74)
... 73 more
I realized that there are already a store_lock
and a lock
on the first database but how does this affect starting a second embedded database? Does anyone know how to solve this problem?
Thanks in advance!