Domanda

My application is populating a Neo4j graph database at /tmp/import.db. In addition to my unit tests I like to use the Neo4j browser (AKA Neo4j Community) to do some digging in that same database. When the browser is running, my application crashes when it gets run because the database it is locked:

Exception in thread "main" java.lang.RuntimeException: Error starting org.neo4j.kernel.EmbeddedGraphDatabase, /tmp/import.db
    at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:330)
    at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:63)
    at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:92)
    at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:198)
    at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:69)
    at no.marcello.cmdb.Import.<init>(Import.java:34)
    at no.marcello.cmdb.Main.main(Main.java:10)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.StoreLockerLifecycleAdapter@5d20e46' was successfully initialized, but failed to start. Please see attached cause exception.
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:509)
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:115)
    at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:307)
    ... 6 more
Caused by: org.neo4j.kernel.StoreLockException: Unable to obtain lock on store lock file: /tmp/import.db/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:82)
    at org.neo4j.kernel.StoreLockerLifecycleAdapter.start(StoreLockerLifecycleAdapter.java:44)
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:503)
    ... 8 more
Caused by: java.io.IOException: Unable to lock sun.nio.ch.FileChannelImpl@70b0b186
    at org.neo4j.kernel.impl.nioneo.store.FileLock.wrapFileChannelLock(FileLock.java:38)
    at org.neo4j.kernel.impl.nioneo.store.FileLock.getOsSpecificFileLock(FileLock.java:93)
    at org.neo4j.kernel.DefaultFileSystemAbstraction.tryLock(DefaultFileSystemAbstraction.java:89)
    at org.neo4j.kernel.StoreLocker.checkLock(StoreLocker.java:74)
    ... 10 more

Now I have to neo4j stop and neo4j start between every run of my application to see the changes. My hands got tired of that.

Can I disable locking of the database when using the Neo4j browser? I'd like to do that for testing purposes, as it helps alot to see how my database model evolves while I'm populating it.

È stato utile?

Soluzione

Database systems -- small ones, anyway -- can often run in either of two modes: embedded or server. In embedded mode, the idea is that one program and only one program can read and write to the database at a time. This is quite useful for many applications, and allows the database to dispense with the code necessary to allow access among multiple programs, which eats up time, code, and processing power.

In server mode, the database management system itself runs as a separate program, and it is built to have multiple programs access it.

Based on the class in the error message above, you have an embedded database, so the answer to your question is "no, you can't do that in this mode". You can switch to using a server mode of neo4j, I expect, but connecting to it will involve some code changes, and you then have the minor problems of making sure your database system is running when your program runs, etc.

So you can do it with this database data, but you have to change the mode in which you are running the database management system.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top