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

Throw an NullPointerException error when querying with valueMap() #1812

Open
georgefuxiaosong opened this issue Sep 27, 2019 · 16 comments
Open

Comments

@georgefuxiaosong
Copy link

we have create a schema and add some vertexes in Janusgraph. For example,

捕获

However, when we want to adjust the schema structure and remove some PropertyKey like:
mgmt.getPropertyKey('age').remove().
An NullPointerException error was thrown while querying with valueMap() after this operation in the Gremlin console,
捕获2
So, how to fix this problem? thank you

@FlorianHockmann
Copy link
Member

Could you please try to reproduce this problem on a fresh installation of JanusGraph, ideally first without deleting any property key and then again after the deletion? You can for example simply load the graph of the gods to make it reproducible for us.
The stack trace doesn't look like it was caused by deleting a property key to me.

@ammarove
Copy link

ammarove commented Oct 2, 2019

@farodin91
Copy link
Contributor

@ammarove I tried to create a test for it, but wasn't able.

@Test
public void testDeletionOfSchemaProperties(){
    mgmt.makePropertyKey("propertyKey").dataType(String.class).cardinality(Cardinality.SINGLE).make();
    graph.traversal().addV("vertexLabel").property("propertyKey", "test").next();
    mgmt.getPropertyKey("propertyKey").remove();

    \\clopen();

    graph.traversal().addV("vertexLabel").property("propertyKey", "test").next();
    List<Map<Object, Object>> maps = graph.traversal().V().valueMap().toList();
    assertEquals(2, maps.size());
}

It would be good if you say the correct version of JanusGraph you are using and also try to find reproduction steps.

@ammarove
Copy link

ammarove commented Nov 24, 2019

@farodin91 i'm trying to reproduce this bug,
the scenario is little weird
when you remove the propertyKey

mgmt = graph.openManagement()  
mgmt.getPropertyKey("propertyKey").remove();
mgmt.commit()

and then re-find the propertykey

mgmt = graph.openManagement()  
key = mgmt.getPropertyKey("propertyKey").

the key is not null;

to reproduce the error i have to restart gremlin server;
when i restart the server and call mgmt.getPropertyKey("propertyKey"). the result will be null and the bug appear

gremlin> :remote connect tinkerpop.server conf/remote.yaml session
==>Configured localhost/127.0.0.1:8182-[d45ee226-eed1-407a-abae-f8fc19216c31]
gremlin> :> mgmt = graph.openManagement()
==>org.janusgraph.graphdb.database.management.ManagementSystem@3ad1f91e
gremlin> :> personVertexLabel = mgmt.makeVertexLabel('person').make()
==>person
gremlin> :> propertyKeyFirstName = mgmt.makePropertyKey('first_name').dataType(String.class).make()
==>first_name
gremlin> :> mgmt.commit()
==>null
gremlin> :> g.addV("person").property("first_name","ali").property("last_name","ammar").next()
==>v[4208]
gremlin> :> g.V()
==>v[4208]
gremlin> :> g.V().properties()
==>vp[first_name->ali]
==>vp[last_name->ammar]
gremlin> :> graph.getOpenTransactions().iterator().next().commit()
==>null
gremlin> :> mgmt.getPropertyKey("first_name").remove()
Operation cannot be executed because the enclosing transaction is closed
Type ':help' or ':h' for help.
Display stack trace? [yN]
gremlin> :> mgmt = graph.openManagement()
==>org.janusgraph.graphdb.database.management.ManagementSystem@55737326
gremlin> :> mgmt.getPropertyKey("first_name").remove()
==>null
gremlin> :> mgmt.getPropertyKey("first_name")
Server could not serialize the result requested. Server error - Error during serialization: Vertex with id 2053 was removed.. Note that the class must be serializable by the client and server for proper operation.
Type ':help' or ':h' for help.
Display stack trace? [yN]y
org.apache.tinkerpop.gremlin.jsr223.console.RemoteException: Server could not serialize the result requested. Server error - Error during serialization: Vertex with id 2053 was removed.. Note that the class must be serializable by the client and server for proper operation.
	at org.apache.tinkerpop.gremlin.console.jsr223.DriverRemoteAcceptor.submit(DriverRemoteAcceptor.java:176)
	at org.apache.tinkerpop.gremlin.console.commands.SubmitCommand.execute(SubmitCommand.groovy:41)
	at org.codehaus.groovy.tools.shell.Shell.execute(Shell.groovy:104)
	at org.codehaus.groovy.tools.shell.Groovysh.super$2$execute(Groovysh.groovy)
	at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:145)
	at org.codehaus.groovy.tools.shell.Groovysh.executeCommand(Groovysh.groovy:273)
	at org.codehaus.groovy.tools.shell.Groovysh.execute(Groovysh.groovy:164)
	at org.apache.tinkerpop.gremlin.console.GremlinGroovysh.super$3$execute(GremlinGroovysh.groovy)
	at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:145)
	at org.apache.tinkerpop.gremlin.console.GremlinGroovysh.execute(GremlinGroovysh.groovy:72)
	at org.codehaus.groovy.tools.shell.Shell.leftShift(Shell.groovy:122)
	at org.codehaus.groovy.tools.shell.ShellRunner.work(ShellRunner.groovy:95)
	at org.codehaus.groovy.tools.shell.InteractiveShellRunner.super$2$work(InteractiveShellRunner.groovy)
	at sun.reflect.GeneratedMethodAccessor45.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:145)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:165)
	at org.codehaus.groovy.tools.shell.InteractiveShellRunner.work(InteractiveShellRunner.groovy:130)
	at org.codehaus.groovy.tools.shell.ShellRunner.run(ShellRunner.groovy:59)
	at org.codehaus.groovy.tools.shell.InteractiveShellRunner.super$2$run(InteractiveShellRunner.groovy)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:145)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:165)
	at org.codehaus.groovy.tools.shell.InteractiveShellRunner.run(InteractiveShellRunner.groovy:89)
	at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:236)
	at org.apache.tinkerpop.gremlin.console.Console.<init>(Console.groovy:146)
	at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:236)
	at org.apache.tinkerpop.gremlin.console.Console.main(Console.groovy:453)
gremlin> :> mgmt.commit()
==>null
gremlin> :> mgmt = graph.openManagement()
==>org.janusgraph.graphdb.database.management.ManagementSystem@51f1b2b
gremlin> :> mgmt.getPropertyKey("first_name")
==>first_name
gremlin> :> mgmt.getPropertyKey("first_name").remove()
==>null
gremlin> :> mgmt.commit()
==>null
gremlin> :> graph.getOpenTransactions().iterator().next().commit()
org.apache.tinkerpop.gremlin.jsr223.console.RemoteException
Type ':help' or ':h' for help.
Display stack trace? [yN]
gremlin> :> g.V()
==>v[4208]
gremlin> :> g.V().properties()
==>vp[first_name->ali]
==>vp[last_name->ammar]
$ ./graph/janusgraph-0.3.1-hadoop2/bin/gremlin.sh 

RESTART GREMLIN SERVER THEN GREMLIN CLIENT

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/ammar/Programming/big-data/graph/janusgraph-0.3.1-hadoop2/lib/slf4j-log4j12-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/ammar/Programming/big-data/graph/janusgraph-0.3.1-hadoop2/lib/logback-classic-1.1.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
plugin activated: janusgraph.imports
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
23:26:44 WARN  org.apache.hadoop.util.NativeCodeLoader  - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
plugin activated: tinkerpop.hadoop
plugin activated: tinkerpop.spark
plugin activated: tinkerpop.tinkergraph
gremlin> :remote connect tinkerpop.server conf/remote.yaml session
==>Configured localhost/127.0.0.1:8182-[21447fb4-bc5c-4930-9e1f-7dad97cdb3b3]
gremlin> :> g.V().properties()
org.apache.tinkerpop.gremlin.jsr223.console.RemoteException
Type ':help' or ':h' for help.
Display stack trace? [yN]y
org.apache.tinkerpop.gremlin.jsr223.console.RemoteException
	at org.apache.tinkerpop.gremlin.console.jsr223.DriverRemoteAcceptor.submit(DriverRemoteAcceptor.java:178)
	at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:236)
	at org.apache.tinkerpop.gremlin.console.commands.SubmitCommand.execute(SubmitCommand.groovy:41)
	at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:236)
	at org.codehaus.groovy.tools.shell.Shell.execute(Shell.groovy:104)
	at org.codehaus.groovy.tools.shell.Groovysh.super$2$execute(Groovysh.groovy)
	at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:145)
	at org.codehaus.groovy.tools.shell.Groovysh.executeCommand(Groovysh.groovy:273)
	at org.codehaus.groovy.tools.shell.Groovysh.execute(Groovysh.groovy:164)
	at org.apache.tinkerpop.gremlin.console.GremlinGroovysh.super$3$execute(GremlinGroovysh.groovy)
	at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:145)
	at org.apache.tinkerpop.gremlin.console.GremlinGroovysh.execute(GremlinGroovysh.groovy:72)
	at org.codehaus.groovy.tools.shell.Shell.leftShift(Shell.groovy:122)
	at org.codehaus.groovy.tools.shell.ShellRunner.work(ShellRunner.groovy:95)
	at org.codehaus.groovy.tools.shell.InteractiveShellRunner.super$2$work(InteractiveShellRunner.groovy)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:145)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:165)
	at org.codehaus.groovy.tools.shell.InteractiveShellRunner.work(InteractiveShellRunner.groovy:130)
	at org.codehaus.groovy.tools.shell.ShellRunner.run(ShellRunner.groovy:59)
	at org.codehaus.groovy.tools.shell.InteractiveShellRunner.super$2$run(InteractiveShellRunner.groovy)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:145)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:165)
	at org.codehaus.groovy.tools.shell.InteractiveShellRunner.run(InteractiveShellRunner.groovy:89)
	at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:236)
	at org.apache.tinkerpop.gremlin.console.Console.<init>(Console.groovy:146)
	at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:236)
	at org.apache.tinkerpop.gremlin.console.Console.main(Console.groovy:453)

Gremlin server error logs:

java.lang.NullPointerException
	at org.janusgraph.graphdb.database.EdgeSerializer.parseRelation(EdgeSerializer.java:128)
	at org.janusgraph.graphdb.database.EdgeSerializer.readRelation(EdgeSerializer.java:73)
	at org.janusgraph.graphdb.transaction.RelationConstructor.readRelation(RelationConstructor.java:70)
	at org.janusgraph.graphdb.transaction.RelationConstructor$1.next(RelationConstructor.java:57)
	at org.janusgraph.graphdb.transaction.RelationConstructor$1.next(RelationConstructor.java:45)
	at org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapStep.processNextStart(FlatMapStep.java:45)
	at org.janusgraph.graphdb.tinkerpop.optimize.JanusGraphPropertiesStep.processNextStart(JanusGraphPropertiesStep.java:111)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:143)
	at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:192)
	at org.apache.tinkerpop.gremlin.server.op.AbstractOpProcessor.handleIterator(AbstractOpProcessor.java:89)
	at org.apache.tinkerpop.gremlin.server.op.AbstractEvalOpProcessor.lambda$evalOpInternal$5(AbstractEvalOpProcessor.java:252)
	at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval$0(GremlinExecutor.java:274)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

reproduced with janusgraph-0.3.1-hadoop2
configutation :

graphs: {
  graph: conf/gremlin-server/janusgraph-cql-es-server.properties
}

@zhoudl-git
Copy link

Is that problem solved?

@bishnuagrawal-zeotap
Copy link

Is this solved? I am experiencing same issue while using properties() or valueMap():

graph.traversal().V(1791307856).properties()

@lbornov2
Copy link

lbornov2 commented Oct 5, 2020

I am generatring my own IDs (graph.set-vertex-id=true), as we require fast lookups, and we cannoto create indexes on properties, and thus searching by properties will require a full table scan.

I'm also using cql backend.

I noticed that this happens with IDs which are way out of the normal range:

gremlin> :> g.V()
==>v[13357428224]
==>v[302190240512]
==>v[13357420288]
==>v[13357475840]

The error only occurs for the ID which is the outlier:

gremlin> :> g.V(302190240512).valueMap()
java.lang.NullPointerException
Type ':help' or ':h' for help.
Display stack trace? [yN]y
java.lang.NullPointerException
	at org.janusgraph.graphdb.database.EdgeSerializer.parseRelation(EdgeSerializer.java:127)
	at org.janusgraph.graphdb.database.EdgeSerializer.readRelation(EdgeSerializer.java:73)
	at org.janusgraph.graphdb.transaction.RelationConstructor.readRelation(RelationConstructor.java:70)
	at org.janusgraph.graphdb.transaction.RelationConstructor$1.next(RelationConstructor.java:57)
	at org.janusgraph.graphdb.transaction.RelationConstructor$1.next(RelationConstructor.java:45)
	at org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertyMapStep.map(PropertyMapStep.java:100)
	at org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertyMapStep.map(PropertyMapStep.java:52)
	at org.apache.tinkerpop.gremlin.process.traversal.step.map.MapStep.processNextStart(MapStep.java:37)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:143)
	at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:197)
	at org.apache.tinkerpop.gremlin.server.op.AbstractOpProcessor.handleIterator(AbstractOpProcessor.java:93)
	at org.apache.tinkerpop.gremlin.server.op.AbstractEvalOpProcessor.lambda$evalOpInternal$5(AbstractEvalOpProcessor.java:264)
	at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval$0(GremlinExecutor.java:278)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

Output for ElementMap:

gremlin> :> g.V(302190240512).elementMap()
Could not find type for id: 2061
Type ':help' or ':h' for help.
Display stack trace? [yN]y
java.lang.NullPointerException: Could not find type for id: 2061
	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:250)
	at org.janusgraph.graphdb.types.vertices.JanusGraphSchemaVertex.name(JanusGraphSchemaVertex.java:57)
	at org.janusgraph.graphdb.vertices.AbstractVertex.label(AbstractVertex.java:121)
	at org.apache.tinkerpop.gremlin.process.traversal.step.map.ElementMapStep.map(ElementMapStep.java:67)
	at org.apache.tinkerpop.gremlin.process.traversal.step.map.ElementMapStep.map(ElementMapStep.java:48)
	at org.apache.tinkerpop.gremlin.process.traversal.step.map.MapStep.processNextStart(MapStep.java:37)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:143)
	at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:197)
	at org.apache.tinkerpop.gremlin.server.op.AbstractOpProcessor.handleIterator(AbstractOpProcessor.java:93)
	at org.apache.tinkerpop.gremlin.server.op.AbstractEvalOpProcessor.lambda$evalOpInternal$5(AbstractEvalOpProcessor.java:264)
	at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval$0(GremlinExecutor.java:278)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

Janusgraph Version: 0.5.2

@bishnuagrawal-zeotap
Copy link

We are dependent on JG for ids.

@Phocion
Copy link

Phocion commented Mar 5, 2021

Hoping to revive this thread, as I'm having the same issue. I was receiving the exact same error with the exact same ID regardless of the vertex ID I was querying against. I noticed in @lbornov2 example, the same thing: vertex id 302190240512 is not 2061. So why would querying for id 302190240512 have an issue with id 2061?

I believe the answer lies in that vertex with id 2061 is a corrupt/ghost node. My guess is that for some reason, it's doing a full-index scan to find the vertex with the given ID, coming across the ghost node, and not gracefully handling it.

I'm trying to understand how to run GhostVertexRemover on my JanusGraph instance to see if this fixes the issue - since I cannot remove my suspected ghost node with .drop(). Documentation for GhostVertexRemover is very sparse/non-existant.

This is a pretty show-stopping bug, I think.

@li-boxuan
Copy link
Member

@Phocion

Using GhostVertexRemover can help you scan the entire table and remove ghost vertices. I have to admit it is not well-documented and cannot be used out-of-the-box. I have a plan to revise and enhance that component but no ETA as of now.

If you already know the ghost vertex and you want to delete it, try doing this:

Iterator<JanusGraphRelation> iterator = v.query().noPartitionRestriction().relations().iterator();
while (iterator.hasNext()) {
        iterator.next();
        iterator.remove();
}
v.remove();

@Phocion
Copy link

Phocion commented Mar 5, 2021

@li-boxuan -- Thank you for the quick reply! I'm using the Gremlin console to run this, but can covert this to Groovy.

It seems however that ghost nodes may not be the culprit here - after some more testing, it's the 'true' value in the valueMap() function which is causing the error.

I haven't had this issue before with JanusGraph 0.3 -- but now using JanusGraph 0.5 with the same data as before. What am I missing here>

gremlin> g.V(22818960).valueMap(true);
Could not find type for id: 130061
gremlin> g.V(22818960).valueMap();
--- Correct Results ---
gremlin> g.V(130061)
Could not find type for id: 130061

Yet this works:

gremlin> g.V(22818960).project('id').by(T.id);
==>[id:22818960]

and this works as well, which is odd because I would have thought it shouldn't:

gremlin> g.V(130061).project('id').by(T.id);
==>[id:130061]

So what exactly is Vertex with ID 130061 ?? Perhaps I should also note I'm using goblin (Python) to load everything into JanusGraph.

Thank you!

@mad
Copy link
Contributor

mad commented Apr 14, 2022

This type of errors produced because schema removed but data is exists with deleted schema

Here snippet that remove entities without schema https://gist.github.com/mad/fdbc29215bc223f7ec33c0eb75d406cb

@TaciturnMan
Copy link

TaciturnMan commented Aug 3, 2022

Here snippet that remove entities without schema https://gist.github.com/mad/fdbc29215bc223f7ec33c0eb75d406cb

I faced the same issue after removal the label from schema. Please could you advise how your snippet can be used to fix the data in graph (to remove entities without schema)? Thank you.

@Spiral90210
Copy link

Ok, I'm having the same proplem here. Please don't judge my stupidity, hindsight is 20:20 here.

In my case, I removed a property from the schema that was already linked to some nodes. I get a NullPointerException every time I try and scan over properties of these nodes - elementMap(), valueMap() and drop() fail, but accessing like g.V(1).properties('goodProp', 'badProp') will return only the good property, not causing the exception.

This property was not part of any index (thank goodness).

I'm not looking forward to recreating this data, however part of that cleanup involves dropping the old nodes, or writing new data where the old stuff should be, and I can't do either. I can add a new badProperty to the node, and get it with .properties('badProperty'), however valueMap() etc. is still broken.

Is there a job that can clean up "zombie properties"? Or perhaps seeing as Janusgraph will let you do something like this, at least handle it so recovery is possible without having to rebuild the whole graph somehow?

I've got a reproduction here, and as above only really rears its head once the cache has been cleared. Ignore the fact the label is 'tweet', it's not indicative of the real graph, but I needed to call it something. I've also simplified as much as I can here.

// first, set up the schema

mgmt=graph.openManagement()
tweet = mgmt.makeVertexLabel('tweet').make()
t_id = mgmt.makePropertyKey('t_id').dataType(String.class).cardinality(SINGLE).make()
t_msg = mgmt.makePropertyKey('t_msg').dataType(String.class).cardinality(SINGLE).make()
// make sure to link the properties to the node
mgmt.addProperties(tweet, t_id, t_msg)
mgmt.commit()

// add some data
g.addV('tweet').property('t_id', '1').property('t_msg', 'msg 1').iterate()

// now, break the schema
mgmt=graph.openManagement()
mgmt.getPropertyKey('t_id').remove();
mgmt.commit()

Important: restart the server here and load a new console to remove all caching

// these all fail
g.V().hasLabel('tweet').valueMap()
g.V().hasLabel('tweet').elementMap()
g.V().hasLabel('tweet').drop()

// this works, just one property shown though
g.V().hasLabel('tweet').properties('t_msg', 't_id')

And now the attempted recovery:

mgmt=graph.openManagement()
tweet = mgmt.getVertexLabel('tweet')
t_msg = mgmt.getPropertyKey('t_msg')
// recreate the property
t_id = mgmt.makePropertyKey('t_id').dataType(String.class).cardinality(SINGLE).make()
mgmt.addProperties(tweet, t_id, t_msg)
mgmt.commit()

// do a restart if you like

// succeeds
g.V().hasLabel('tweet').property('t_id', '1').iterate()
g.tx().commit()

// shows both properties
g.V().hasLabel('tweet').properties('t_msg', 't_id')

// all still fail with NPE
g.V().hasLabel('tweet').valueMap()
g.V().hasLabel('tweet').elementMap()
g.V().hasLabel('tweet').drop()

So, by removing a schema property that's in use on nodes, you can pretty much brick your graph, and have no way to add the property back to it? Is there any way to recover here? I can, through a convoluted process, rebuild individual nodes and sort the edges etc. out, but I do really need to be able to clear these old ones. Surely there has to be a way here?

The ultimate solution here - to be able to re-add the property back to nodes, rather than have to rebuild everything. I can get the values, I just need whatever is causing the NPE to get addressed.

@mad
Copy link
Contributor

mad commented May 7, 2024

@Spiral90210 you can fix it using this #1812 (comment)

graph = JanusGraphFactory.open("graph.properties");
new RemoveElementsWithoutJGSchema(graph).doRemove()

The logic of the job is quite simple, it runs through all relations and deletes those that are not in the schema

@Spiral90210
Copy link

@Spiral90210 you can fix it using this #1812 (comment)

graph = JanusGraphFactory.open("graph.properties");
new RemoveElementsWithoutJGSchema(graph).doRemove()

The logic of the job is quite simple, it runs through all relations and deletes those that are not in the schema

I've been on vacation so not been able to look at this until today. I'm going to attempt this later in the week, but on the surface it looks to be exactly what I need. I'll report back when I do!

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

No branches or pull requests