-
Notifications
You must be signed in to change notification settings - Fork 871
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
addEdge with orid to minimize dependency on referenced Vertex. #2132
Comments
It's pretty easy to implement the first part, but for transactions this is harder because all the operations happen at client-side and at commit() time we flush the transaction to the server/storage. So OrientDB is MVCC by design. We should support a concept of "operation" that the client should execute at server side level only. |
Yes, I thought abut the same. On Mon, Mar 17, 2014 at 12:44 PM, Luca Garulli notifications@github.comwrote:
Best regards, Orient Technologies |
I'm running in embed mode but that should only affect this slightly, if at all. If the retry happens within the scope of the commit() and minimizes the "lock" time for the references vertex, then I hope we will still see improvement. The best way would be to have the server add edges - for these light cases - with minimum overhead. Regards, |
We could create a new version of the method with an additional parameter "lockingStrategy" of type OStorage.LOCKING_STRATEGY :
In case it's KEEP_EXCLUSIVE_LOCK we should load the record by ID, by using this strategy (we recently added this feature) and let to the commit() the unlock of locked records. So we'd need an additional map<rid,lock_type> in the transaction object. This would work only with local/plocal/memory connections. For the remote case the locking would need more work (new lock/unlock commands, etc). WDYT about this solution? Are you working with plocal? |
Or maybe we should support the PESSIMISTIC transaction (now we only have optimistic) where all the records are locked:
|
Guys, a question. WDYT ? |
In general I agree with you but:
That's why I'd like the user can choose the best approach for his use case. |
Yes, but support of pessimistic transactions means such kind of behavior as I described above. |
Hi, Please excuse me for the lack of knowledge required to participate in this I do how ever understand the need for the 3 sided updates on bi-direction It seems to me that the drawback of this can be minimized by treating the Regards, On Tue, Mar 25, 2014 at 6:47 AM, Andrey Lomakin notifications@github.comwrote:
|
So what's the solution? To retry the entire tx? How if the tx is lead by the client? Think to this case: tx.begin()
try{
Vertex client = loadVertexClient( name );
if( client.getProperty("amount") < 1000 )
client.setProperty( "amount", client.amount() + 100 );
tx.commit();
} catch ( Exception e )
tx.rollback();
} |
I agree that in theory lock free is better (especially for scalability), but I draw my conclusion on empirical usage of the OrientDB as user. Unfortunately lack of pessimistc locking (at least for updates in COMMIT ) makes it extremely hard to build fast business solution especially with remote database. If you want to have No.1 popular and fast (from user perspective) graph database, it shouldn't be. |
@kowalot I agree with you, it's much better to provide a tool the user decide or not to use. This is the sake of OrientDB and NoSQL in general. What @Laa is referring, maybe, is the worrying about some new constraints that will avoid to scale up, but I cannot see them right now. I've a separate branch "tx-pessimistic" where the OIdentifiable has 2 new methods:
So now the user have control of locking, but it's more for OrientDB internal APis. All th elocks are stored in the tx, so at close all the locks are freed. This is a POC yet to introduce a pessimistic or at least hybrid approach to support something like addEdge() at the server side. |
…mmand: [RETRY <retry> [WAIT <pauseBetweenRetriesInMs]]
Good news. I've fixed this issue by introducing 2 new keywords in create edge SQL command:
Where:
@acmeguy This command can be executed in transactions, so I think covers 100% of your needs. Let me know the results of it ASAP, in the meanwhile I'll write a couple of test cases before to close it. |
Hi, How do I use this from the Java API? Regards, On Mon, Mar 31, 2014 at 12:21 AM, Luca Garulli notifications@github.comwrote:
|
It reloads the vertices in case of conflict. Use it with g.command ():
|
Hi, This is understood. Does it also work with temporary vertex IDs from within the transaction? Regards, On Mon, Mar 31, 2014 at 7:45 AM, Luca Garulli notifications@github.comwrote:
|
Nope because temporary rids scope are transaction only, and commands are executed on the server side, so out of transaction. But you could execute this command on the server side:
So the new created vertex rid will go as parameter of create edge. |
? OCommandSQL ? On Mon, Mar 31, 2014 at 12:01 PM, Luca Garulli notifications@github.comwrote:
|
How do I set the Edge Type in this command? On Mon, Mar 31, 2014 at 12:13 PM, Stefan Baxter stebax@gmail.com wrote:
|
Look at sql create edge command guide: |
Is there a blueprints alternative to this? We are using blueprints and I am running into the same concurrent modification due to version mismatch. I tried to use locks around graph.addEdge() but that didn't work since the version is incremented at the time of commit? Concurrent modification exception is also occuring at the time of commit. Caused by: com.orientechnologies.orient.core.exception.OConcurrentModificationException: Cannot UPDATE the record #12:213 because the version is not the latest. Probably you are updating an old record or it has been modified by another user (db=v6 your=v5) |
This command is to overcome this problem: it takes care of reloading of both vertices in case of conflict. |
OK thanks. Does it mean I have to use SQL instead of blueprints for adding edges? We are trying to keep our code as much agnostics to underlying datastore as possible so we are sticking with blueprints. |
Hi, This seems to introduces another problem for me. On vertex is most commonly a new one and using this approach means I have Is it not possible to have the server add "empty edges" this way by default Regards, On Mon, Mar 31, 2014 at 3:49 PM, ppeddi notifications@github.com wrote:
|
Could you execute everything at the server side with a SQL script? String cmd = "";
cmd += "begin";
cmd += "\nlet a = create vertex set script = true";
cmd += "\nlet b = select from v limit 1";
cmd += "\ncreate edge from $a to $b retry 100";
cmd += "\ncommit";
cmd += "\nreturn $a";
Object result = database.command(new OCommandScript("sql", cmd)).execute(); Look at issue #2176. |
do you know if I can use the combination of blueprints graph and SQL with in a single transaction. For example, I can use blueprints to create vertices and use SQL with retry feature for edges. //start transaction //commit the transaction. WHAT AND HOW DO I COMMIT? I HAVE graph object and database object. |
I suggest you to use last 1.7-SNAPSHOT (few minutes ago) and do this supposing v2 you already know has a rid = #11:232: String sql = "begin;let v1 = create vertex V;create edge from $v1 to (select from #11:232);commit retry 100";
database.command(new OCommandScript("sql", sql)); In this way you apply the retry to the commit and the entire tx will be repeated in case of conflict. Let me know how it performs under heavy load. Or you could also do: String sql = "begin;let v1 = create vertex V;let v2 = select from #11:232 lock record;create edge from $v1 to $v2;commit";
database.command(new OCommandScript("sql", sql)); |
I've updated the WiKi page: https://github.com/orientechnologies/orientdb/wiki/SQL-batch |
@enisher can you provide an ETA for this issue? |
Hi, Can this be done using the Java API? |
Ys, it's already there. |
already where? :) |
@acmeguy We implemented it in SQL command. Did you mean the addEdge() in Java API? You can do:
|
Luca, this line makes no sense :) I'm trying to add edges to existing vertices from a new vertex without updating the version number of the existing vertex. I thought I had this working but it's updating version numbers like crazy. My line is: |
This is another problem: set |
I have that set already: OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.setValue(1); Sorry, I thought the two were linked. is this irrelevant: |
Sorry, copy and paste: you should set it to |
yeah, I had it at -1 :) |
2.1-SNAPSHOT I have OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.setValue(-1); in my factory when getting OrientGraph and the vertex version still increasing and constantly getting concurrency modification exceptions and transaction rollback. I am using Java API and I don't think it does retry if it fails. In my use case, I consider vertex changed only when properties are changed but not edges. Could anyone point me to the right place on how the above configuration works? I will try to use -D in command line but it is not ideal. Thanks. |
Are you using OrientDB embedded or remote? In case of remote, where did you set that -D ? |
Embedded using plocal. Thank.
|
Are you working with distributed server (replication)? However, could you provide the code responsible of the exception? |
No. I only have one server with embedded plocal server. I tried to put My code is complicated and there are several classes involved. I will create a test case based on 2.1-SNAPSHOT. Thanks. |
Here is the three line of code which is called by passing in different data with the same userId. The third line increase the user version for each edge creation.
|
I've just added 2 test cases in ec23c69 commit and adding elements in tree ridbag doesn't increment version. Please could you send us a running test case to demonstrate the problem? |
Thanks for this fix -- it appears to have helped the issue we were having as well (using HTTP API). |
Allow edges to be created with ORID:
This would mean that I'm only referencing the target vertex and that NO other update is requested for the target vertex
Resolved during during commit:
See this discussion:
https://groups.google.com/forum/?fromgroups=#!topic/orient-database/qbXlDJbK8m8
The text was updated successfully, but these errors were encountered: