Facing FileLockException while using neo4j-admin import

I am using neo4j-admin import to read the csv and create nodes. While firing up the command for the import I am facing a file lock exception.
My import csv file -

movieId:ID,title,year:int,:LABEL
tt0133093,"The Matrix",1999,Movie
tt0234215,"The Matrix Reloaded",2003,Movie;Sequel
tt0242653,"The Matrix Revolutions",2003,Movie;Sequel

I have already tried to kill the process and still the problem pertains.

Command while running the import - /bin/neo4j-admin import --nodes=test_new_import.csv

ERROR :

org.neo4j.kernel.impl.store.UnderlyingStorageException: org.neo4j.io.pagecache.impl.FileLockException: This file is locked by another process, please ensure you don't have another Neo4j process or tool using it: '/var/lib/neo4j/data/databases/graph.db/neostore'.'
*** at org.neo4j.kernel.impl.store.NeoStores.verifyRecordFormat(NeoStores.java:217)***
*** at org.neo4j.kernel.impl.store.NeoStores.(NeoStores.java:144)***
*** at org.neo4j.kernel.impl.store.StoreFactory.openNeoStores(StoreFactory.java:129)***
*** at org.neo4j.kernel.impl.store.StoreFactory.openAllNeoStores(StoreFactory.java:93)***
*** at org.neo4j.unsafe.impl.batchimport.store.BatchingNeoStores.instantiateStores(BatchingNeoStores.java:237)***
*** at org.neo4j.unsafe.impl.batchimport.store.BatchingNeoStores.createNew(BatchingNeoStores.java:181)***
*** at org.neo4j.unsafe.impl.batchimport.ParallelBatchImporter.doImport(ParallelBatchImporter.java:87)***
*** at org.neo4j.tooling.ImportTool.doImport(ImportTool.java:581)***
*** at org.neo4j.commandline.dbms.CsvImporter.doImport(CsvImporter.java:128)***
*** at org.neo4j.commandline.dbms.ImportCommand.execute(ImportCommand.java:236)***
*** at org.neo4j.commandline.admin.AdminTool.execute(AdminTool.java:127)***
*** at org.neo4j.commandline.admin.AdminTool.main(AdminTool.java:51)***
*** Suppressed: java.lang.IllegalStateException: VM pause monitor is not started***
*** at org.neo4j.util.Preconditions.checkState(Preconditions.java:142)***
*** at org.neo4j.kernel.monitoring.VmPauseMonitor.stop(VmPauseMonitor.java:71)***
*** at org.neo4j.unsafe.impl.batchimport.staging.OnDemandDetailsExecutionMonitor.done(OnDemandDetailsExecutionMonitor.java:128)***
*** at org.neo4j.unsafe.impl.batchimport.staging.MultiExecutionMonitor.done(MultiExecutionMonitor.java:82)***
*** at org.neo4j.unsafe.impl.batchimport.staging.MultiExecutionMonitor.done(MultiExecutionMonitor.java:82)***
*** at org.neo4j.unsafe.impl.batchimport.ImportLogic.close(ImportLogic.java:520)***
*** at org.neo4j.unsafe.impl.batchimport.ParallelBatchImporter.doImport(ParallelBatchImporter.java:99)***
*** ... 5 more***
Caused by: org.neo4j.io.pagecache.impl.FileLockException: This file is locked by another process, please ensure you don't have another Neo4j process or tool using it: '/var/lib/neo4j/data/databases/graph.db/neostore'.'
*** at org.neo4j.io.pagecache.impl.SingleFilePageSwapper.acquireLock(SingleFilePageSwapper.java:227)***
*** at org.neo4j.io.pagecache.impl.SingleFilePageSwapper.(SingleFilePageSwapper.java:178)***
*** at org.neo4j.io.pagecache.impl.SingleFilePageSwapperFactory.createPageSwapper(SingleFilePageSwapperFactory.java:66)***
*** at org.neo4j.io.pagecache.impl.muninn.MuninnPagedFile.(MuninnPagedFile.java:149)***
*** at org.neo4j.io.pagecache.impl.muninn.MuninnPageCache.map(MuninnPageCache.java:412)***
*** at org.neo4j.kernel.impl.store.MetaDataStore.getRecord(MetaDataStore.java:285)***
*** at org.neo4j.kernel.impl.store.NeoStores.verifyRecordFormat(NeoStores.java:198)***
*** ... 11 more***

WARNING Import failed. The store files in /var/lib/neo4j/data/databases/graph.db are left as they are, although they are likely in an unusable state. Starting a database on these store files will likely fail or observe inconsistent records so start at your own risk or delete the store manually
unexpected error: org.neo4j.io.pagecache.impl.FileLockException: This file is locked by another process, please ensure you don't have another Neo4j process or tool using it: '/var/lib/neo4j/data/databases/graph.db/neostore'.'

In the documentation, it says that neo4j-admin import should only be used to import data into a previously unused database:

https://neo4j.com/docs/operations-manual/current/tools/import/

It sounds like you might be trying to run import into an already running database. The database files might be locked because Neo4j itself is running locking those files. If this is the case for you, I'd recommend checking the docs, and using neo4j-admin import to get the data into a completely different graph, and then later starting neo4j with that graph.

2 Likes

Hi David,
I tried that and I was successfully able to create the nodes BUT then when I am starting my server I am not able to hit the neo4j browser.

Not being able to hit the Neo4j browser is a separate issue; you might consider starting another thread for that, and including the output of your debug.log file.

Hello @david.allen,

I am facing the same issue. Therefore I am trying to create a new graph (from command line only on Linux).

How is it possible to create a new graph from command line only? Is it actually possible with the community edition of Neo4j?

Thanks a lot!

Hi, I have the same issue, could you mind sharing the final solution?
Thanks

It's worth noting that if you go the route of creating the database before running the import command, neo4j cannot actually be running while you perform the import. Otherwise, you will see this lock issue on the neostore file corresponding to the database you create. I've found that it's easier to do a neo4j-admin import before actually creating the database in neo4j, to avoid these file lock issues.