Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restart neo4j in docker without killing container #77

Open
alexliffick opened this issue Mar 3, 2017 · 7 comments
Open

restart neo4j in docker without killing container #77

alexliffick opened this issue Mar 3, 2017 · 7 comments

Comments

@alexliffick
Copy link

alexliffick commented Mar 3, 2017

I've rolled my own Dockerfile to start with neo4j and include supervisord to run the docker-entrypoint script. It would be nice if I didn't have to do this and use my own image, but rather if Neo4j was setup this way from the get-go, or at least in some way that the container wouldn't die when trying to add additional conf entries aside from the few items that can be passed in as environment variables. If it helps, did the following:

Supervisord.conf:
[supervisord]
nodaemon=true

[program:neo4j]
command=/docker-entrypoint.sh neo4j
stopsignal=INT

Dockerfile:

FROM neo4j:enterprise

# Add the current working folder
COPY . /var/lib/neo4j

# Set the working directory to the new mapped folder.
WORKDIR /var/lib/neo4j

RUN apk update;apk add vim supervisor

#create the log dir for supervisor and copy the config file
RUN mkdir -p /var/log/supervisor

# Expose the node.js and consul ports to the Docker host.
EXPOSE 7474 7687 7473

CMD ["/usr/bin/supervisord", "--configuration=/var/lib/neo4j/supervisord.conf"]
@spacecowboy
Copy link
Contributor

If you're going to the trouble of making your own docker image to use supervisord I'd heavily recommend that you run neo4j directly instead of the entrypoint script. Then you wouldn't have to fight the setting code.

So something like

[program:neo4j]
command=/var/lib/neo4j/bin/neo4j console
stopsignal=INT

@streamnsight
Copy link

using supervisord in a docker container is not the way to go: if you process dies, the container dies. Just restart the container. Docker provides the --restart always flag for this purpose.

@Rohithzr
Copy link

Rohithzr commented Apr 22, 2019

@spacecowboy I am in a situation where I want to restore a graph.db folder from a different machine. The process needs me to unbind the cluster-state. But because I am running docker containers, stopping the process will simply stop the container.

@AlanLongYu
Copy link

AlanLongYu commented May 31, 2019

Yes I have the trouble too! I want to import some csv data to graph.db ,but always display error.
Because the docker run a instance of neo4j which I can access it about http://localhost:7474/
but how can I stop the process rather than simply stop the container.

/var/lib/neo4j # neo4j-admin import --nodes=import/movies.csv --database graph.db
Neo4j version: 3.5.5
Importing the contents of these files into /data/databases/graph.db:
Nodes:
/var/lib/neo4j/import/movies.csv

Available resources:
Total machine memory: 3.86 GB
Free machine memory: 895.90 MB
Max heap memory : 491.00 MB
Processors: 1
Configured max memory: 3.04 GB
High-IO: false

IMPORT FAILED in 18047d 12h 53m 50s 261ms.
Data statistics is not available.
Peak memory usage: 0.00 B
Import 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: '/data/databases/graph.db/neostore'.'
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: '/data/databases/graph.db/neostore'.'
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: '/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 com.neo4j.unsafe.impl.batchimport.RestartableParallelBatchImporter.fastForwardToLastCompletedState(RestartableParallelBatchImporter.java:190)
at com.neo4j.unsafe.impl.batchimport.RestartableParallelBatchImporter.doImport(RestartableParallelBatchImporter.java:113)
at org.neo4j.tooling.ImportTool.doImport(ImportTool.java:585)
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 com.neo4j.unsafe.impl.batchimport.RestartableParallelBatchImporter.doImport(RestartableParallelBatchImporter.java:118)
... 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: '/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:408)
at org.neo4j.kernel.impl.store.MetaDataStore.getRecord(MetaDataStore.java:285)
at org.neo4j.kernel.impl.store.NeoStores.verifyRecordFormat(NeoStores.java:198)
... 12 more

WARNING Import failed. The store files in /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: '/data/databases/graph.db/neostore'.'

@nicorikken
Copy link

Same issue here, using it in Kubernetes. For now I use a workaround:

  1. Start the container with a custom command to ensure it is remains running: tail -f /dev/null
  2. Exec into the container and run the admin commands.
  3. Stop the container and restart it with the default command.

To solve the use-case of imports I'm now working on using a Kubernetes initContainer to seed the database using a previously registered dump.

@acarl005
Copy link

@nicorikken I have the same problem, but a different solution in Kubernetes. I used a Job and created a modified image from the Neo4j image. I mounted a Persistent Volume to this container on /data. From this, I ran neo4j-admin on the data, saving the ingested data to the volume. I then created a Deployment for a fresh, unmodified Neo4j image and mounted this volume to it, so it contained the ingested data.

@tuwid
Copy link

tuwid commented Jan 17, 2020

@Rohithzr This would count as an administrative procedure and needs to be done by set of cli parameters where you can import your new graph from the other directory without restarting the main process. The proper solution wouldn't be to make this kind of workaround to keep the container always running, would be to add the proper functionality in neo4j for import from a directory / NFS

Having said that you could override the entrypoint to start neo4j &; and to tail -f somke log file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants