JanusGraph / janusgraph

JanusGraph: an open-source, distributed graph database
https://janusgraph.org
Other
5.27k stars 1.16k forks source link

Dynamic traversal source does not get updated without server restart #1269

Open mchandrasekar opened 5 years ago

mchandrasekar commented 5 years ago

Fresh install of gremlin server with latest code from master (0.3.1), fresh install of Cassandra, fresh install of elasticsearch does not update dyanmic traversal sources for graphs created using ConfiguredGraphFactory without doing a server restart.

Steps to reproduce:

1) Build current master branch (0.3.1) 2) Start gremlin server using yaml 3) Create configured graph factory like shown here.

When this is executed traversalSourceAlias is not updated in the remote gremlin-server, even though this is executed. Because of which the following exception orrucrs

The traversal source [graph1_traversal] for alias [g] is not configured on the server.

What fixed the problem:

Changing the ConfigurationManagementGraph.getConfigurations() to the code below fixed the issue. For some reason, graph.traversal().V().has(PROPERTY_TEMPLATE, false) is not returning any results even in the gremlin shell without doing a server restart. But updating this to graph.traversal().V().hasLabel(VERTEX_LABEL) is working. This also seemed like a better way to look up configuration vertices.

public List<Map<String, Object>> getConfigurations() {
        final List<Map<String, Object>> graphConfigurations = graph.traversal().V().hasLabel(VERTEX_LABEL).valueMap().toList();
        return graphConfigurations.stream().map(this::deserializeVertexProperties).collect(Collectors.toList());
    }
sinnergarden commented 4 years ago

I meet the same problem with janus version 0.4. and it does solve the problem.

However, I don't understand why it happens, as the dynamically created new graph already been set to v.property(PROPERTY_TEMPLATE, false);. How can the new graph not been retrieved by original filter?

Other info:

    public void createConfiguration(final Configuration config) {
        Preconditions.checkArgument(config.containsKey(PROPERTY_GRAPH_NAME),
                                    String.format("Please include the property \"%s\" in your configuration.",
                                                  PROPERTY_GRAPH_NAME
                                    ));
        final Map<Object, Object> map = ConfigurationConverter.getMap(config);
        final Vertex v = graph.addVertex(T.label, VERTEX_LABEL);
        map.forEach((key, value) -> v.property((String) key, value));
        v.property(PROPERTY_TEMPLATE, false);
        graph.tx().commit();
    }
ourdaidai commented 4 years ago

Same issue here. Create graph1 with g1 = ConfiguredGraphFactory.create("graph1");

I can get graph name with

curl --location --request POST '111.111.111.111:8182' \
--header 'content-type: application/json' \
--data-raw '{"gremlin":"ConfiguredGraphFactory.getGraphNames()"}'

But others will get "message": "No such property: g1/g1_traversal/graph1/XXXXX for class: Script56",

After reconnect with console

gremlin> g1
No such property: g1 for class: Script57
Type ':help' or ':h' for help.

Only graph1 works in console, but not in curl.

gremlin> graph1
==>standardjanusgraph[berkeleyje:db/berkeley]

Use python

connection = DriverRemoteConnection('ws://XXXXXXXXXXXX:8182/gremlin', 'graph1_travseral') #also tried 'g','graph1','graph1_traversal','g1'.
g = graph.traversal().withRemote(connection)
xx = g.V().name.toList() # this line failed

GremlinServerError: 499: The traversal source [graph1_travseral] for alias [g] is not configured on the server.

janusgraph-0.5.1