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

HIGH SEVERITY..I was able to retrieve an edge using graph.getVertex(edgeId)! (2.1.3) #5089

Closed
zifnab87 opened this issue Oct 10, 2015 · 16 comments
Assignees
Labels
Milestone

Comments

@zifnab87
Copy link

Possibly related/causing my other issues (#5068, #5033, #5048)

        OrientGraph graph = factory.getTx();
        Vertex v = graph.getVertex("#26:0");
        Edge e = graph.getEdge("#26:0");
        System.out.println(v+" "+e);
v(ContainsPrimitive)[#26:0] e[#26:0][#21:102-ContainsPrimitive->#30:1]

I stumbled upon that because it was giving a NullPointer exception trying to access properties that were not there.. The code was supposed to be retrieving a vertex but I debugged it and it was an edge retrieved as a vertex!

@lvca , @Laa This happens with any edges that I tried from two classes! I would appreciate it if you could investigate it as soon as possible - you already have my copy of db in the email. I almost switched to a different product and still thinking of it..

I checked with every single backup (about 20 of them) from the first one 4 months ago till the last one and all of them are behaving exactly the same way! I really don't know why my database became so messed up...so early on!

@zifnab87 zifnab87 changed the title HIGH SEVERITY..I was able to get an edge as a vertex! (2.1.3) HIGH SEVERITY..I was able to retrieve an edge using graph.getVertex(edgeId)! (2.1.3) Oct 10, 2015
@lvca
Copy link
Member

lvca commented Oct 10, 2015

I checked in the code and there is this check:

if (!doc.getSchemaClass().isSubClassOf(OrientEdgeType.CLASS_NAME))
  throw new IllegalArgumentException("Class '" + doc.getClassName() + "' is not an edge class");

Trying to create a new test case for it.

@lvca lvca added the bug label Oct 10, 2015
@lvca lvca self-assigned this Oct 10, 2015
@lvca lvca added this to the 2.1.x (next hotfix) milestone Oct 10, 2015
@zifnab87
Copy link
Author

@lvca Thanks for the quick response.. What I would expect in my case is
Class ContainsPrimitive is not a vertex class. Also what I don't understand is how this edge got into my code as vertex.. I wonder if there is a bug that instead of the Direction.OUT vertex it returns the edge as a vertex too at least for my db, probably because the cluster ids are messed up

@zifnab87
Copy link
Author

@lvca I recreated piece by piece my database from scratch and I added a few vertices and an edge using the console and the same thing happens!

v(ContainsPrimitive)[#21:0] e[#21:0][#13:0-ContainsPrimitive->#13:1]

@lvca
Copy link
Member

lvca commented Oct 10, 2015

@zifnab87 How can I reproduce it? Do you have a script to generate it?

@zifnab87
Copy link
Author

Yeah I am able anytime.. give me some time I will send it :)

@zifnab87
Copy link
Author

@lvca

CREATE DATABASE remote:localhost/test2 root admin plocal
CONNECT remote:localhost/test2 admin admin
CREATE CLASS Date extends V
CREATE CLASS Number extends V
CREATE CLASS Has extends E
CREATE VERTEX Date // #11:0
CREATE VERTEX Number //#12:0
CREATE EDGE Has FROM #11:0 TO #12:0 /[Has#13:0{out:#11:0,in:#12:0} v1]
OrientGraphFactory factory = new OrientGraphFactory("remote:localhost/test2");
OrientGraph graph = factory.getTx();
Vertex v = graph.getVertex("#13:0");
Edge e = graph.getEdge("#13:0");
System.out.println(v+" "+e);

Oct 10, 2015 4:56:10 PM com.orientechnologies.common.log.OLogManager log
INFO: OrientDB auto-config DISKCACHE=7,419MB (heap=2,706MB os=12,173MB disk=36,272MB)
v(Has)[#13:0] e[#13:0][#11:0-Has->#12:0]

@lvca
Copy link
Member

lvca commented Oct 12, 2015

This test pass:

  @Test
  public void edgesCannotBeVertices() {
    OrientGraphNoTx gNoTx = new OrientGraphNoTx(URL, "admin", "admin");
    try {
      OrientVertex v = gNoTx.addVertex(null);
      OrientVertex loadedV = gNoTx.getVertex(v.getIdentity());
      try {
        OrientEdge e = gNoTx.getEdge(v.getIdentity());
        Assert.fail();
      } catch (IllegalArgumentException e) {
        // OK
      }
    } finally {
      gNoTx.shutdown();
    }

    OrientGraph g = new OrientGraph(URL, "admin", "admin");
    try {
      OrientVertex v = g.addVertex(null);
      OrientVertex loadedV = g.getVertex(v.getIdentity());
      try {
        OrientEdge e = g.getEdge(v.getIdentity());
        Assert.fail();
      } catch (IllegalArgumentException e) {
        // OK
      }
    } finally {
      g.shutdown();
    }
  }

@lvca
Copy link
Member

lvca commented Oct 12, 2015

So at this point could be the remote connection, let me check it...

@lvca
Copy link
Member

lvca commented Oct 12, 2015

Tested against remote, 2.1.x and develop branch and in all the cases a IllegalArgumentException is thrown. @zifnab87 please could you provide an executable test case that shows the problem?

@zifnab87
Copy link
Author

ok I will send it. @lvca could it be that you are not using specific vertex classes but the default ones?? your database should have already two vertex classes and an edge class..

@lvca
Copy link
Member

lvca commented Oct 12, 2015

Tried with specific vertex class and same result: everything works as expected:

  @Test
  public void edgesCannotBeVertices() {
    OrientGraphNoTx gNoTx = new OrientGraphNoTx(URL, "admin", "admin");
    try {
      gNoTx.createVertexType("TestV");
      gNoTx.createEdgeType("TestE");

      OrientVertex v = gNoTx.addVertex("class:TestV");
      OrientVertex loadedV = gNoTx.getVertex(v.getIdentity());
      try {
        OrientEdge e = gNoTx.getEdge(v.getIdentity().toString());
        Assert.fail();
      } catch (IllegalArgumentException e) {
        // OK
      }
    } finally {
      gNoTx.shutdown();
    }

    OrientGraph g = new OrientGraph(URL, "admin", "admin");
    try {
      OrientVertex v = g.addVertex("class:TestV");
      OrientVertex loadedV = g.getVertex(v.getIdentity().toString());
      try {
        OrientEdge e = g.getEdge(v.getIdentity());
        Assert.fail();
      } catch (IllegalArgumentException e) {
        // OK
      }
    } finally {
      g.shutdown();
    }
  }

@zifnab87
Copy link
Author

@lvca In your test case, I think you are checking the inverse thing to what is failing, as I said in this comment earlier (#5089 (comment))

I am requesting an edge through getVertex.. This is what fails.. The case you are testing worked for me yesterday.. I will check when i get home but if you can, please create an edge and then request it through getVertex() ..

@lvca
Copy link
Member

lvca commented Oct 12, 2015

Got it, I think this is possible because we use Vertex as generic schema-less type, so I guess there is no check if the vertex is an edge. I can check on it, but my question is: why are you retrieving an edge as vertex? I mean, wha's the purpose and why it's so critical? Could you just retrieve it as edge with getEdge()?

@zifnab87
Copy link
Author

Well I didn't do it on purpose @lvca It happened in my code after a complicated insert.. In my models I keep a reference of a vertex about to be updated or just inserted.. For some reason after a specific (tested) use case that I add a big hierarchy of objects, I debugged it and I found an edge in the place of a vertex. This throws a NullPointerException because I try to use this "vertex" to find vertex properties that of course are not on the edge.. This is the bug that led me to find the bug we are currently discussing. That's why I am very frustrated. This is a case I have many passing integration tests and I haven't changed the code for quite a while yet it manages to fail when some of the nodes are newly inserted.. It is as if the clusters are messed up.. Yet the closed issue #5033 that I sent some code for you to replicate, makes my life really difficult since I cannot run all my tests at once

@zifnab87
Copy link
Author

zifnab87 commented Mar 7, 2016

@lvca this is definitely a bug I don't understand why cannot replicate was added.. I have moved away from OrientDB to TitanDB since December unfortunately.

@lvca
Copy link
Member

lvca commented May 12, 2016

@zifnab87 You were right, added check.

@lvca lvca closed this as completed May 12, 2016
@lvca lvca modified the milestones: 2.2.0 GA, 2.1.x (next hotfix) May 12, 2016
@lvca lvca removed the in progress label May 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants