Orient Technologies
The Company behind OrientDB
--
---
You received this message because you are subscribed to a topic in the Google Groups "OrientDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orient-database/MMh_SxSdYKQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
return;If (no) then "CREATE EDGE RELATIONSHIP FROM (srcVertex) TO (destVertex)"Does the instance of the Edge already exist?If (no) then create vertex for destination end of the edge I'm about to createIf (yes) then does the actual vertex instance of the destination class exist?If (yes) then does the Edge class exist?a. Does the destination Class exist?2. Iterate over the FK fields. For each FK:1. Insert/Update the main recordColin,It's only running on a single thread right now, so everything is running serially and synchronously. The idea is that I get a JSON data document from a relational database (SQL Server), and that record has a number of FK values as fields.The deadlock is occurring on the main record, interestingly.At first I was using a Transaction so that I could roll back the whole operation in the event of a failure. I changed it to use NoTx(), but it didn't help.I'm using an UPDATE Account CONTENTS { <json> } UPSERT WHERE Id = "xxxxx" as the mechanism for inserting/updating the main record. Since that statement only returns a count of the records modified (1), I then go back and immediately SELECT FROM Account WHERE Id = "xxxxx".I had the best luck when I put a graph.commit() between the UPDATE and the SELECT statements.Is there a better way to do this? I coded a "graph.addVertex()", but I would still need to pre-check for existence and then UPDATE, because I don't see a single-call mechanism from Java for doing that, other than the UPSERT.My first implementation was in a Javascript function which followed the same logic, but it was (still is occassionally) deadlocking too.Any/all thoughts are welcome.Thanks very much,Patrick
On Tue, Mar 31, 2015 at 10:52 AM, Colin wrote:Hi Patrick,Are you sharing the same graph db connection among your threads doing the querying?What's your design look like for writing/reading the database?Thanks,-ColinOrient Technologies
The Company behind OrientDB
On Monday, March 30, 2015 at 3:02:39 PM UTC-5, Patrick Hoeffel wrote:OrientDB 2.0.5 on Windows Server 2012, client connecting from Win 7 Pro
I have a Java class that is inserting a vertex and then adding outbound edges. I'm doing queries to figure out what intermediate data needs to also be created in order for my edges to be built properly, but something is causing a deadlock, and I can only get it to clear by restarting OrientDB. Here is the stack trace from Eclipse when this happens:
If anyone has seen this before, please let me know.
Thanks,
Patrick--
---
--Patrick Hoeffel
--
---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
var cmd;
var result;
var dataJson = JSON.parse(data);
var srcId = dataJson["Id"];
devlogInfo("srcId=" + srcId);
try {
// Before doing anything else, persist the input document
if (vertexExistsInClass("Account", srcId)) {
// The vertex already exists, so this becomes an UPDATE operation
cmd = "UPDATE Account CONTENT " + data + " WHERE Id = '" + srcId + "'";
devlogInfo(cmd);
db.begin();
result = db.command(cmd); // <== THIS OPERATION PRODUCES WHAT ACTS LIKE AN UNRECOVERABLE DEADLOCK, REQUIRING SERVER SHUTDOWN/RESTART
} else {
devlogInfo("CREATED VERTEX, Id = " + srcId);
db.begin();
result = db.save(data); // <== THIS OPERATION WORKS GREAT
}
// Proceed with creation of Edges going out from this vertex, including creation of destination vertices if needed.
// Before doing anything else, persist the input document
cmd = "UPDATE Client CONTENT " + data + " UPSERT WHERE Id = '" + srcId + "'";
result = db.command(cmd);
To unsubscribe from this group and all its topics, send an email to orient-database+unsubscribe@googlegroups.com.
--Patrick Hoeffel
--
---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
CREATE CLASS Base EXTENDS V ABSTRACT
CREATE Property Base.Id STRING
CREATE Property Base.DateCreated DATETIME
CREATE Property Base.DateModified DATETIME
CREATE INDEX Id ON Base (Id collate ci) UNIQUE_HASH_INDEX METADATA {ignoreNullValues : false}
CREATE CLASS BaseMaster EXTENDS Base ABSTRACT
CREATE Property BaseMaster.Name STRING
CREATE Property BaseMaster.Code STRING
CREATE CLASS Account EXTENDS BaseMaster
http://localhost:2480/function/Demo/loadData_Account/{ "@class":"Account" , "Id":"11111111-5022-e411-8534-00155d016d32" , "Timestamp":"13129987427877781504" , "Company":"22222222-4c22-e411-8534-00155d016d32" , "Code":"012345" , "Name":"Some Name" , "Type":"1" , "SubsidiaryType":"0" , "PostingType":"0" , "Status":"0" }
UPDATE Account CONTENT { "@class":"Account" , "Id":"11111111-5022-e411-8534-00155d016d32" , "Timestamp":"13129987427877781504" , "Company":"22222222-4c22-e411-8534-00155d016d32" , "Code":"012345" , "Name":"Some Name" , "Type":"1" , "SubsidiaryType":"0" , "PostingType":"0" , "Status":"0" }
UPSERT WHERE Id = "11111111-5022-e411-8534-00155d016d32"
I have 100 sample records that I use for testing. When the Id does not exist and the operation resolves to an INSERT, then everything is fine. When the Id does exist and the operation resolves to an UPDATE, that is when I see the problem.