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

Update edge | unable to change the edge endpoint #8406

Closed
gtadudeps opened this issue Jul 17, 2018 · 7 comments
Closed

Update edge | unable to change the edge endpoint #8406

gtadudeps opened this issue Jul 17, 2018 · 7 comments
Assignees
Labels
Milestone

Comments

@gtadudeps
Copy link

gtadudeps commented Jul 17, 2018

OrientDB Version: v3.0.3

Java Version: 8

OS: macOS High Sierra

Expected behavior

On issuing update edge command the endpoint should update. This worked in v2.2.35 but its not working in v3.0.3.

Actual behavior

It's throwing a error saying out is not a vertex and is failing on validateOutInForEdge.

`com.orientechnologies.orient.core.exception.OCommandExecutionException: Error updating edge: 'out' is not a vertex - [V#9:0{name:a} v1]
DB name="test"
at com.orientechnologies.orient.core.sql.executor.UpdateEdgePointersStep.validateOutInForEdge(UpdateEdgePointersStep.java:126)
at com.orientechnologies.orient.core.sql.executor.UpdateEdgePointersStep.handleUpdateEdge(UpdateEdgePointersStep.java:86)
at com.orientechnologies.orient.core.sql.executor.UpdateEdgePointersStep.access$000(UpdateEdgePointersStep.java:16)
at com.orientechnologies.orient.core.sql.executor.UpdateEdgePointersStep$1.next(UpdateEdgePointersStep.java:35)
at com.orientechnologies.orient.core.sql.executor.SaveElementStep$1.next(SaveElementStep.java:37)
at com.orientechnologies.orient.core.sql.executor.CountStep.syncPull(CountStep.java:53)
at com.orientechnologies.orient.core.sql.executor.OSelectExecutionPlan.fetchNext(OSelectExecutionPlan.java:37)
at com.orientechnologies.orient.core.sql.executor.OUpdateExecutionPlan.executeInternal(OUpdateExecutionPlan.java:46)
at com.orientechnologies.orient.core.sql.parser.OUpdateStatement.execute(OUpdateStatement.java:144)
at com.orientechnologies.orient.core.sql.parser.OStatement.execute(OStatement.java:59)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentEmbedded.command(ODatabaseDocumentEmbedded.java:540)
at com.orientechnologies.orient.server.network.protocol.http.command.post.OServerCommandPostCommand.executeStatement(OServerCommandPostCommand.java:175)
at com.orientechnologies.orient.server.network.protocol.http.command.post.OServerCommandPostCommand.execute(OServerCommandPostCommand.java:84)
at com.orientechnologies.orient.server.network.protocol.http.command.post.OServerCommandPostCommandGraph.execute(OServerCommandPostCommandGraph.java:36)
at com.orientechnologies.orient.server.network.protocol.http.ONetworkProtocolHttpAbstract.service(ONetworkProtocolHttpAbstract.java:172)
at com.orientechnologies.orient.server.network.protocol.http.ONetworkProtocolHttpAbstract.execute(ONetworkProtocolHttpAbstract.java:633)
at com.orientechnologies.common.thread.OSoftThread.run(OSoftThread.java:82)
Internal server error:

com.orientechnologies.orient.core.exception.OCommandExecutionException: Error updating edge: 'out' is not a vertex - [V#9:0{name:a} v1]
DB name="test"
at com.orientechnologies.orient.core.sql.executor.UpdateEdgePointersStep.validateOutInForEdge(UpdateEdgePointersStep.java:126)
at com.orientechnologies.orient.core.sql.executor.UpdateEdgePointersStep.handleUpdateEdge(UpdateEdgePointersStep.java:86)
at com.orientechnologies.orient.core.sql.executor.UpdateEdgePointersStep.access$000(UpdateEdgePointersStep.java:16)
at com.orientechnologies.orient.core.sql.executor.UpdateEdgePointersStep$1.next(UpdateEdgePointersStep.java:35)
at com.orientechnologies.orient.core.sql.executor.SaveElementStep$1.next(SaveElementStep.java:37)
at com.orientechnologies.orient.core.sql.executor.CountStep.syncPull(CountStep.java:53)
at com.orientechnologies.orient.core.sql.executor.OSelectExecutionPlan.fetchNext(OSelectExecutionPlan.java:37)
at com.orientechnologies.orient.core.sql.executor.OUpdateExecutionPlan.executeInternal(OUpdateExecutionPlan.java:46)
at com.orientechnologies.orient.core.sql.parser.OUpdateStatement.execute(OUpdateStatement.java:144)
at com.orientechnologies.orient.core.sql.parser.OStatement.execute(OStatement.java:59)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentEmbedded.command(ODatabaseDocumentEmbedded.java:540)
at com.orientechnologies.orient.server.network.protocol.http.command.post.OServerCommandPostCommand.executeStatement(OServerCommandPostCommand.java:175)
at com.orientechnologies.orient.server.network.protocol.http.command.post.OServerCommandPostCommand.execute(OServerCommandPostCommand.java:84)
at com.orientechnologies.orient.server.network.protocol.http.command.post.OServerCommandPostCommandGraph.execute(OServerCommandPostCommandGraph.java:36)
at com.orientechnologies.orient.server.network.protocol.http.ONetworkProtocolHttpAbstract.service(ONetworkProtocolHttpAbstract.java:172)
at com.orientechnologies.orient.server.network.protocol.http.ONetworkProtocolHttpAbstract.execute(ONetworkProtocolHttpAbstract.java:633)`

Steps to reproduce

create vertex v set name = 'a'; --> #9:0
create vertex v set name = 'b'; --> #10:0
create vertex v set name = 'c'; --> #11:0

create edge e from #10:0 to #11:0; --> #17:0

update edge e set out = (select from v where name = 'a' ) where @rid = #17:0

@luigidellaquila luigidellaquila self-assigned this Jul 17, 2018
luigidellaquila added a commit that referenced this issue Jul 17, 2018
@luigidellaquila
Copy link
Member

Hi @gtadudeps

I just pushed a fix, it will be released with v 3.0.5

Thanks

Luigi

@luigidellaquila luigidellaquila added this to the 3.0.5 milestone Jul 17, 2018
@gtadudeps
Copy link
Author

Hi @luigidellaquila thanks for such a quick response!
Do we have a release date for v3.0.5?

Thanks

@gtadudeps
Copy link
Author

gtadudeps commented Jul 17, 2018

One follow-up question I had is, with this fix in place would we be able to perform upsert on edges:

for example: With Vertex class Person having unique index on Name and edge class Friend having unique index on id property .
UPDATE EDGE Friend SET in = (SELECT FROM Person WHERE Name = 'name1' ) , out = (SELECT FROM Person where Name = 'name2') , id = 'f1' UPSERT WHERE id = 'f1'

Thanks

@luigidellaquila
Copy link
Member

Hi @gtadudeps

We do not have a date for 3.0.5 yet, but I'd say it will be in one or two weeks.

About the upsert, I have to check it, the parser accepts it but I'm not sure that the case is completely covered in the execution planner.

Anyway, the snapshot is already available here https://oss.sonatype.org/content/repositories/snapshots/com/orientechnologies/orientdb-community/3.0.5-SNAPSHOT/ so you can try it yourself

Thanks

Luigi

@gtadudeps
Copy link
Author

gtadudeps commented Jul 18, 2018

Hi @luigidellaquila
Thanks for the providing the build, the fix is working.

I looked into the upsert query with this build, though its creating the edge and sets the @rid properly within the edge its not updating the IN and OUT fields of vertex and thus breaks the graph, Is this case currently handled?

Case:
NodeObj vertex has unique index on qName.
ImpactEdge vertex has unique index on edgeId

Command i tried
CREATE VERTEX NodeObj CONTENT {"tD":1,"qName":"1.101.4.2881","cT":1531588634559} ;
CREATE VERTEX NodeObj CONTENT {"tD":1,"qName":"1.101.4.3620","cT":1531588634559} ;
UPDATE Edge ImpactEdge SET out = ( SELECT FROM NodeObj where qName='1.101.4.2881') , in = ( SELECT FROM NodeObj where qName='1.101.4.3620') , edgeId= '1.101.4.2881_1.101.4.3620_9223372036854775807' UPSERT WHERE edgeId = '1.101.4.2881_1.101.4.3620_9223372036854775807'

@luigidellaquila
Copy link
Member

Hi @gtadudeps

You are right, it doesn't work and it requires a fix. Could you please open another issue for that?

What we have now is an UPSERT on edges that works on out/in only. I don't know if you need it, but in case you can use it as follows:

define the schema for the edge as follows:

CREATE PROPERTY ImpactEdge.out LINK;
CREATE PROPERTY ImpactEdge.in LINK;
CREATE INDEX ImpactEdge_out_in on ImpactEdge (out, in) UNIQUE;

and then

CREATE EDGE ImpactEdge UPSERT FROM ( SELECT FROM NodeObj where qName='1.101.4.2881') TO ( SELECT FROM NodeObj where qName='1.101.4.3620') 
SET edgeId= '1.101.4.2881_1.101.4.3620_9223372036854775807'

Thanks

Luigi

@gtadudeps
Copy link
Author

gtadudeps commented Jul 22, 2018

Hi @luigidellaquila

Thanks for your suggestion, but in our case since there could be multiple edges between two vertices we really couldn't have a unique constraint on out and in properties. I have opened the issue for this case #8424.

Unrelated to this but perhaps you could suggest/look into to another issue that we are facing and which has become very critical for us scaling up #8421.

Thanks for all your efforts! 👍

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

2 participants