I'm trying to use Gremlin server to work with graph based database and docker-compose. The problem is that when I shutdown or restart the container, no static file is saved and the graph is empty with the following start.
What am I doing wrong? :(
What I have done is:
Set this image for the container
image: tinkerpop/gremlin-serverSet the container volumes
volumes:
- gremlin_data:/opt/gremlin-server/data
- Set the docker-compose volumes:
volumes:
pgdata:
django-static:
gremlin_data:
- Set the tinkergraph in order to save the graph state on close:
gremlin.tinkergraph.graphLocation=/opt/gremlin-server/data/graph.kryo
gremlin.tinkergraph.graphFormat=gryo
The issue appears to be that gremlin-server does not get shut down gracefully when running in docker. TinkerGraph is primarily an in-memory graph and it only saves to the location defined in
gremlin.tinkergraph.graphLocationwhen the graph instance is closed. When gremlin-server is sent a SIGINT, it will close the underlying TinkerGraph and the data will be saved.The issue is that when running the distributed gremlin-server docker image, gremlin-server is not the foreground process in the container. When the container is shut down, the server is never signaled to shut down gracefully, and this save does not take place.
I have tested a setup similar to what you described; if I simply shut down the container, my graph is not saved. However if I open a shell in the container and run the following to send a SIGINT to the server before shutdown, my data is preserved in my volume.
I believe this is something which should be resolved within TinkerPop. I have created a TinkerPop JIRA for such an improvement.
EDIT:
Stephen Mallette from the TinkerPop community connected me to an old related JIRA which has a much more elegant workaround. If you send
graph.close()as a gremlin script before shutting down the container, the graph will gracefully close and save to your volume. If you are connecting via gremlin-console, you can simply run the command.If you are connecting through the java driver or one of the other GLV's, you will have to submit the command as a script: