我正在尝试评估 Neo4j 中的不同数据模型。出于这个原因,我创建了两个具有不同模型的数据库并将它们保存在同一目录中:
path/to/database/graphModel1
path/to/database/graphModel2
下一步是我使用 java 创建了一个应用程序,我可以在其中选择数据模型和要评估的查询(只有几个预定义的查询)。根据选择的模型,我想使用嵌入式数据库的实例。目前,我使用以下 if 子句来区分它们:
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);
但是在我使用model1进行第一次查询并希望使用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
我意识到第一个数据库上已经有 astore_lock
和 a lock
,但这对启动第二个嵌入式数据库有何影响?有谁知道如何解决这个问题?
提前致谢!