Docker Janusgraph Custom ID Values
I'm trying to setup a janusgraph database with custom verex ID values. I have the following docker-compose configuration:
Then, after setting up a Python environment with gremlin-python version 3.5.7, I execute the following:
And I get the following error message:
Solution:Jump to solution
You could do both
```
graph.set-vertex-id=true
graph.allow-custom-vid-types=true...
16 Replies
My
./janusgraph/janusgraph.properties
contains the following:
I've investigated the logs and found this message:
So now my question becomes, how do I set the global value?Thank you very much for getting back to me. I tried connecting to the graph in gremlin console using the following:
As you can see, it didn't work. So I think I must have bigger issues haha. I thought berkeley was used by default, but it doesn't seem to be working.
I also tried the inmemory config file just in case, and I was able to successfully set the value, as you said:
But my code still produced the same error.
Can you show the stacktrace for the Berkeley store error?
Regarding in-memory graph: could you show the full code/log that shows that your code still produces the same error?
Btw I would also want to point out that,
is invalid in JanusGraph. Not all numerical values are legal id values in JanusGraph. https://docs.janusgraph.org/advanced-topics/custom-vertex-id/#custom-long-id shows how you can get a legal numerical id. It may not work in gremlin-python, unfortunately.
My suggestion is use string type custom id
Here is the stack trace for
graph = JanusGraphFactory.open('conf/janusgraph-berkeleyje-server.properties')
And here is the stack trace when I run the same Python script:
The BerkeleyDB error is specific to BerkeleyDB itself. See if https://stackoverflow.com/questions/8612659/berkeley-db-error-the-je-lck-file-could-not-be-locked works. Try destroying your container and start over.
Stack Overflow
Berkeley DB error: The je.lck file could not be locked
We are encountering the ff error when running a java program using a berkeley DB.
"The environment cannot be locked for single writer access. ENV_LOCKED: The je.lck file could not be locked.
The second one looks more interesting. What if you add the vertex from the gremlin-console? Do you still see the same problem?
I tried tearing down/rebuilding the docker container (and deleting volumes), and I got the same error to do with lock files. Then I tried deleting the lock file just to see what would happen, and I got the following. It seems that there is a global variable that is setting the indexing backend to elasticsearch. But I thought I was using lucene? I don't believe I need a fancy indexing backend for my simple project, so I thought lucene would make things more simple. And I am not sure how I could change these global values without being able to create a
graph
instance in the gremlin console.I would like to mention again that my docker config only contains the following:
And my custom janusgraph.properties config file volume contains the following:
I also get the following messages to do with my "read only" volume at the beginning of my janusgraph logs:
Could this be a problem? If I don't make it read-only, the config file gets overridden as soon as the container starts. Notice the "ro" at the end of my volume.
You should do
graph.set-vertex-id
instead of set-vertex-id
. I see why you used set-vertex-id
instead of its full form - the doc was a bit misleading.
It seems that there is a global variable that is setting the indexing backend to elasticsearch. But I thought I was using lucene gremlin> graph = JanusGraphFactory.open('conf/janusgraph-berkeleyje-lucene-server.properties') 02:17:47 WARN org.janusgraph.diskstorage.configuration.builder.ReadConfigurationBuilder.getOptionsWithDiscrepancies - Local setting index.search.backend=lucene (Type: GLOBAL_OFFLINE) is overridden by globally managed value (elasticsearch). Use the ManagementSystem interface instead of the local configuration to control this setting.This clearly shows you have stale configuration. Maybe your volume wasn't really completely deleted. I think it would make more sense to start without Docker. You seem to struggle with Docker setup and JanusGraph setup at the same time. Let's get a plain JanusGraph setup correct first.
I have decided to just add a custom "id" property, as opposed to setting the actual ID controlled by janusgraph. I assumed providing custom IDs would be the most practical, but It seems that having a custom field works well enough for my purposes. Thank you for helping me with this, but I think there are too many intricate details for me to deal with and understand with this right now.
As you suggested, the
janusgraph.graph.set-vertex-id: true
property in docker-compose.yml worked, but after trying to provide my own ID values it said that they were invalid. I have provided the full stack trace. Strangely, using an id of 0
returns a different error than other IDs, such as 1
.
Reading the documentation, it sounds like we're supposed to get a custom ID by using the ID manager like so:
But I cannot figure out how to use this in gremlin-python. I believe it is janusgraph specific.Yes this is JanusGraph specific so you cannot do it in gremlin-python
Unfortunately we don't have a JanusGraph-specific driver for python
Solution
You could do both
Then you could use any arbitrary string ID, e.g.
But remember you should be using
org.apache.tinkerpop.gremlin.util.ser.GraphSONMessageSerializerV3
instead of org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV1
(you are probably already using it)Hacky solution here: id manager to vertex Id is doing this operation: id <<1 3. If you do this operation yourself you don't need to use toVertexid.
Side note: I am curious where are you reading janusgraph logs, I don't see them in my gke cluster