java.lang.IllegalStateException: Database locked. using batch-import

1,393 views
Skip to first unread message

Mark Needham

unread,
Mar 4, 2013, 7:31:17 PM3/4/13
to ne...@googlegroups.com
I've been playing around with Michael's batch-import to create a bunch of nodes/relationships in a neo4j instance I'm running on a vagrant VM and somehow I've managed to lock the database and I'm not entirely sure how to fix it!

These are the last lines of /var/lib/neo4j/data/log/neo4j.0.0.log

Mar 5, 2013 12:20:24 AM org.neo4j.server.logging.Logger log
INFO: Loaded neo4j tuning properties from conf/neo4j.properties
Mar 5, 2013 12:20:24 AM org.neo4j.server.logging.Logger log
SEVERE: Failed to start database.
Mar 5, 2013 12:20:24 AM org.neo4j.server.logging.Logger log
SEVERE:
java.lang.IllegalStateException: Database locked.
        at org.neo4j.kernel.InternalAbstractGraphDatabase.create(InternalAbstractGraphDatabase.java:289)
        at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:227)
        at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:79)
        at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:70)
        at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:205)
        at org.neo4j.server.database.CommunityDatabase.start(CommunityDatabase.java:55)
        at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:124)
        at org.neo4j.server.Bootstrapper.start(Bootstrapper.java:85)
        at org.neo4j.server.Bootstrapper.main(Bootstrapper.java:49)
Mar 5, 2013 12:20:24 AM org.neo4j.server.logging.Logger log
SEVERE: Failed to start Neo Server on port [7474]

I stopped the database before running my import using 'service neo4j-service stop' and then ran a shell script which executed the following:

java -server -Xmx2G -jar /tmp/batch-importer.jar /var/lib/neo4j/data/graph.db /usr/share/football/batch_import/nodes.csv /usr/share/football/batch_import/rels.csv

Where the CSV files contain nodes/relationships and the /tmp/batch-importer.jar is a build of the JAR from batch-import which I copied onto the machine.

The version of neo is 1.8.2 running on Ubuntu 12.04 but I've been successful with using the batch-import on a 1.9.M04 instance on OS X 10.8.2.

I am running the Open JDK on the VM (going to switch to the Sun JDK now), would that likely be the cause of a database lock?

Thanks in advance,
Mark

Michael Hunger

unread,
Mar 4, 2013, 7:51:38 PM3/4/13
to ne...@googlegroups.com
If you shut it down correctly (both batchinserter and index) then there should be no lock. You can just delete the *.lock files if you're sure that there is no neo4j process running on this db anymore.

Was there any error when running the importer?

Cheers

Michael


--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Mark Needham

unread,
Mar 4, 2013, 8:36:02 PM3/4/13
to ne...@googlegroups.com
Nope there was no error when running the importer:

sudo ./import.sh 
Using Existing Configuration File

Importing 8290 Nodes took 0 seconds 

Importing 34044 Relationships took 0 seconds 

Importing 503 Done inserting into players Index took 0 seconds 

Importing 37 Done inserting into teams Index took 0 seconds 

Importing 12 Done inserting into months Index took 0 seconds 

Importing 270 Done inserting into matches Index took 0 seconds 

Importing 69 Done inserting into countries Index took 0 seconds 

Importing 6 Done inserting into continents Index took 0 seconds 

Total import time: 1 seconds 

I also can't seem to find any lock files which is a bit weird:

vagrant@precise64:/var/lib/neo4j$ tree | grep lock
|   |   |   |       |   |   |-- DeadlockDetectedException.html
|   |   |   |       |   |-- DeadlockDetectedException.html
|   |   |   |-- transactions-deadlocks.html
|   |   |   |-- transactions-locking.html

No neo process running:

vagrant@precise64:/var/lib/neo4j$ ps aux | grep neo
vagrant  28513  0.0  0.2  11684   928 pts/0    S+   01:32   0:00 grep --color=auto neo

Doesn't seem like there's any other processes holding onto the database directory:

vagrant@precise64:/var/lib/neo4j$ sudo lsof | grep neo  
bash      25988    vagrant  cwd       DIR              252,0     4096    3802751 /var/lib/neo4j
sudo      28517       root  cwd       DIR              252,0     4096    3802751 /var/lib/neo4j
grep      28518    vagrant  cwd       DIR              252,0     4096    3802751 /var/lib/neo4j
lsof      28519       root  cwd       DIR              252,0     4096    3802751 /var/lib/neo4j
lsof      28520       root  cwd       DIR              252,0     4096    3802751 /var/lib/neo4j

Very weird...

Michael Hunger

unread,
Mar 4, 2013, 8:43:56 PM3/4/13
to ne...@googlegroups.com
Are you looking in the right directory? Check in the data/graph.db one. (Also in the index)

/var/lib/neo4j/data/graph.db

The file is called "lock"

Mark Needham

unread,
Mar 4, 2013, 9:10:08 PM3/4/13
to ne...@googlegroups.com
Yeh the tree command is supposed to show you all the files traversing down the directories so in theory it would have found me anything in that directory.

In any case I tried an 'ls' on the directory that you suggested:

vagrant@precise64:/var/lib/neo4j/data/graph.db$ ls -alh
total 2.4M
drwxr-xr-x 3 root  root    4.0K Mar  5 01:30 .
drwxr-xr-x 3 neo4j nogroup 4.0K Mar  5 01:31 ..
drwxr-xr-x 3 root  root    4.0K Mar  5 01:30 index
-rw-r--r-- 1 root  root     819 Mar  5 01:30 index.db
-rw-r--r-- 1 root  root     297 Mar  5 01:30 messages.log
-rw-r--r-- 1 root  root      69 Mar  5 01:30 neostore
-rw-r--r-- 1 root  root       9 Mar  5 01:30 neostore.id
-rw-r--r-- 1 root  root     73K Mar  5 01:30 neostore.nodestore.db
-rw-r--r-- 1 root  root       9 Mar  5 01:30 neostore.nodestore.db.id
-rw-r--r-- 1 root  root    1.1M Mar  5 01:30 neostore.propertystore.db
-rw-r--r-- 1 root  root     153 Mar  5 01:30 neostore.propertystore.db.arrays
-rw-r--r-- 1 root  root       9 Mar  5 01:30 neostore.propertystore.db.arrays.id
-rw-r--r-- 1 root  root       9 Mar  5 01:30 neostore.propertystore.db.id
-rw-r--r-- 1 root  root     133 Mar  5 01:30 neostore.propertystore.db.index
-rw-r--r-- 1 root  root       9 Mar  5 01:30 neostore.propertystore.db.index.id
-rw-r--r-- 1 root  root     520 Mar  5 01:30 neostore.propertystore.db.index.keys
-rw-r--r-- 1 root  root       9 Mar  5 01:30 neostore.propertystore.db.index.keys.id
-rw-r--r-- 1 root  root     75K Mar  5 01:30 neostore.propertystore.db.strings
-rw-r--r-- 1 root  root       9 Mar  5 01:30 neostore.propertystore.db.strings.id
-rw-r--r-- 1 root  root    1.1M Mar  5 01:30 neostore.relationshipstore.db
-rw-r--r-- 1 root  root       9 Mar  5 01:30 neostore.relationshipstore.db.id
-rw-r--r-- 1 root  root     113 Mar  5 01:30 neostore.relationshiptypestore.db
-rw-r--r-- 1 root  root       9 Mar  5 01:30 neostore.relationshiptypestore.db.id
-rw-r--r-- 1 root  root     710 Mar  5 01:30 neostore.relationshiptypestore.db.names
-rw-r--r-- 1 root  root       9 Mar  5 01:30 neostore.relationshiptypestore.db.names.id

Also: 

vagrant@precise64:/var/lib/neo4j/data/graph.db/index$ ls -alh
total 12K
drwxr-xr-x 3 root root 4.0K Mar  5 01:30 .
drwxr-xr-x 3 root root 4.0K Mar  5 01:30 ..
drwxr-xr-x 3 root root 4.0K Mar  5 01:30 lucene

Michael Hunger

unread,
Mar 4, 2013, 9:14:47 PM3/4/13
to ne...@googlegroups.com
Cool, so no lock file. Then it should start.

Lasse Westh-Nielsen

unread,
Mar 5, 2013, 3:19:13 AM3/5/13
to ne...@googlegroups.com
Hey Mark,

The database lock was something we added to prevent two (or more) instances from accessing the same files at the same time.

So you get that error message when you start up, and your database tries to lock a particular file 'store_lock' in the graph.db directory. Are you sure the other instance using those files had been shut down properly?

 - Lasse




--

Mark Needham

unread,
Mar 5, 2013, 6:04:45 PM3/5/13
to ne...@googlegroups.com, la...@neotechnology.com
Hey Lasse,

Yeh I noticed that 'store_lock' reference when I was skimming through the code trying to work out why the exception was getting thrown but interestingly I didn't seem to have a 'store_lock' file sitting in the graph.db directory so I did a 'touch store_lock' to create it and now everything is starting fine. 

I couldn't see any other instance running in the process list or anything containing a reference to the lock file so I'm assuming that the absence of the file was the problem?

Mark

Mark Needham

unread,
Mar 5, 2013, 6:10:39 PM3/5/13
to ne...@googlegroups.com, la...@neotechnology.com
I think I may also have had the permissions on the directory screwed up and that's why it wasn't able to create the store_lock file in the first place. 
Reply all
Reply to author
Forward
0 new messages