{"action":"created","issue":{"url":"https://api.github.com/repos/orientechnologies/orientdb/issues/4338","labels_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/4338/labels{/name}","comments_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/4338/comments","events_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/4338/events","html_url":"https://github.com/orientechnologies/orientdb/issues/4338","id":86873661,"number":4338,"title":"creating edges that involve different shards introduces \"OTransactionException\"","user":{"login":"clarkpeng","id":12093640,"avatar_url":"https://avatars.githubusercontent.com/u/12093640?v=3","gravatar_id":"","url":"https://api.github.com/users/clarkpeng","html_url":"https://github.com/clarkpeng","followers_url":"https://api.github.com/users/clarkpeng/followers","following_url":"https://api.github.com/users/clarkpeng/following{/other_user}","gists_url":"https://api.github.com/users/clarkpeng/gists{/gist_id}","starred_url":"https://api.github.com/users/clarkpeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clarkpeng/subscriptions","organizations_url":"https://api.github.com/users/clarkpeng/orgs","repos_url":"https://api.github.com/users/clarkpeng/repos","events_url":"https://api.github.com/users/clarkpeng/events{/privacy}","received_events_url":"https://api.github.com/users/clarkpeng/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-10T07:33:37Z","updated_at":"2015-06-12T11:32:56Z","closed_at":null,"body":"Hi all,\r\n\r\nI'm having issue while using OrientVertex.addEdge() API.\r\nMy orientdb version is community 2.0.10 and it runs in distributed mode with tcp-ip join as below.\r\n\r\n```\r\nmulticast enabled=\"false\"\r\ntcp-ip enabled=\"true\"\r\n```\r\n\r\nThe distributed-config.json has below configurations.\r\n\r\n```\r\n\"clusters\":{\r\n...\r\n\"vertex1_server1\":{ \"servers\":[\"server1\"]}\r\n\"edge1_server1\"  :{ \"servers\":[\"server1\"]}\r\n\"vertex2_server2\":{ \"servers\":[\"server2\"]}\r\n...\r\n}\r\n```\r\n\r\nThat means:\r\n1. cluster \"vertex1_server1\" and \"edge1_server1\" will only reside in server1\r\n2. cluster \"vertex2_server2\"  will only reside in server2\r\n\r\nNow when I wish to add edge1 from cluster \"vertex1_server1\" to cluster \"vertex2_server2\", it always throws below exception.\r\n\r\n```\r\nAdd v1\r\nAdd v2\r\nAdd e1\r\n[error] (run-main-0) com.orientechnologies.orient.core.exception.OTransactionException: Error on committing distributed transaction\r\ncom.orientechnologies.orient.core.exception.OTransactionException: Error on committing distributed transaction\r\n        at com.orientechnologies.orient.server.distributed.ODistributedStorage.commit(ODistributedStorage.java:953)\r\n        at com.orientechnologies.orient.core.tx.OTransactionOptimistic.doCommit(OTransactionOptimistic.java:488)\r\n        at com.orientechnologies.orient.core.tx.OTransactionOptimistic.commit(OTransactionOptimistic.java:147)\r\n        at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.commit(ODatabaseDocumentTx.java:2427)\r\n        at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.commit(ODatabaseDocumentTx.java:2397)\r\n        at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.commit(ONetworkProtocolBinary.java:1088)\r\n        at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.executeRequest(ONetworkProtocolBinary.java:390)\r\n        at com.orientechnologies.orient.server.network.protocol.binary.OBinaryNetworkProtocolAbstract.execute(OBinaryNetworkProtocolAbstract.java:217)\r\n        at com.orientechnologies.common.thread.OSoftThread.run(OSoftThread.java:69)\r\nCaused by: com.orientechnologies.orient.core.exception.ODatabaseException: Error on retrieving record #11:0 (cluster: vertex1_prism-orient-db-01)\r\n        at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.executeReadRecord(ODatabaseDocumentTx.java:1634)\r\n        at com.orientechnologies.orient.core.tx.OTransactionOptimistic.loadRecord(OTransactionOptimistic.java:226)\r\n        at com.orientechnologies.orient.core.tx.OTransactionOptimistic.loadRecord(OTransactionOptimistic.java:237)\r\n        at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.load(ODatabaseDocumentTx.java:1446)\r\n        at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.load(ODatabaseDocumentTx.java:118)\r\n        at com.orientechnologies.orient.core.record.impl.ODocument.field(ODocument.java:890)\r\n        at com.orientechnologies.orient.server.distributed.task.OTxTask.execute(OTxTask.java:101)\r\n        at com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin.executeOnLocalNode(OHazelcastPlugin.java:761)\r\n        at com.orientechnologies.orient.server.hazelcast.ODistributedWorker.onMessage(ODistributedWorker.java:300)\r\n        at com.orientechnologies.orient.server.hazelcast.ODistributedWorker.run(ODistributedWorker.java:121)\r\nCaused by: com.orientechnologies.orient.server.distributed.ODistributedException: Error on executing distributed request (id=43 from=prism-orient-db-02 task=record_read userName=admin) against database 'testdb.[vertex1_prism-orient-db-01]' to nodes [prism-orient-db-01]\r\n        at com.orientechnologies.orient.server.hazelcast.OHazelcastDistributedDatabase.send2Nodes(OHazelcastDistributedDatabase.java:195)\r\n        at com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin.sendRequest(OHazelcastPlugin.java:354)\r\n        at com.orientechnologies.orient.server.distributed.ODistributedStorage.readRecord(ODistributedStorage.java:554)\r\n        at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.executeReadRecord(ODatabaseDocumentTx.java:1601)\r\n        at com.orientechnologies.orient.core.tx.OTransactionOptimistic.loadRecord(OTransactionOptimistic.java:226)\r\n        at com.orientechnologies.orient.core.tx.OTransactionOptimistic.loadRecord(OTransactionOptimistic.java:237)\r\n        at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.load(ODatabaseDocumentTx.java:1446)\r\n        at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.load(ODatabaseDocumentTx.java:118)\r\n        at com.orientechnologies.orient.core.record.impl.ODocument.field(ODocument.java:890)\r\n        at com.orientechnologies.orient.server.distributed.task.OTxTask.execute(OTxTask.java:101)\r\n        at com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin.executeOnLocalNode(OHazelcastPlugin.java:761)\r\n        at com.orientechnologies.orient.server.hazelcast.ODistributedWorker.onMessage(ODistributedWorker.java:300)\r\n        at com.orientechnologies.orient.server.hazelcast.ODistributedWorker.run(ODistributedWorker.java:121)\r\nCaused by: com.orientechnologies.orient.server.distributed.ODistributedException: Quorum 1 not reached for request (id=43 from=prism-orient-db-02 task=record_read userName=admin). Elapsed=3025ms No server in conflict. Received: {prism-orient-db-01=waiting-for-response}\r\n        at com.orientechnologies.orient.server.distributed.ODistributedResponseManager.manageConflicts(ODistributedResponseManager.java:585)\r\n        at com.orientechnologies.orient.server.distributed.ODistributedResponseManager.getFinalResponse(ODistributedResponseManager.java:349)\r\n        at com.orientechnologies.orient.server.hazelcast.OHazelcastDistributedDatabase.waitForResponse(OHazelcastDistributedDatabase.java:365)\r\n        at com.orientechnologies.orient.server.hazelcast.OHazelcastDistributedDatabase.send2Nodes(OHazelcastDistributedDatabase.java:192)\r\n        at com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin.sendRequest(OHazelcastPlugin.java:354)\r\n        at com.orientechnologies.orient.server.distributed.ODistributedStorage.readRecord(ODistributedStorage.java:554)\r\n        at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.executeReadRecord(ODatabaseDocumentTx.java:1601)\r\n        at com.orientechnologies.orient.core.tx.OTransactionOptimistic.loadRecord(OTransactionOptimistic.java:226)\r\n        at com.orientechnologies.orient.core.tx.OTransactionOptimistic.loadRecord(OTransactionOptimistic.java:237)\r\n        at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.load(ODatabaseDocumentTx.java:1446)\r\n        at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.load(ODatabaseDocumentTx.java:118)\r\n        at com.orientechnologies.orient.core.record.impl.ODocument.field(ODocument.java:890)\r\n        at com.orientechnologies.orient.server.distributed.task.OTxTask.execute(OTxTask.java:101)\r\n        at com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin.executeOnLocalNode(OHazelcastPlugin.java:761)\r\n        at com.orientechnologies.orient.server.hazelcast.ODistributedWorker.onMessage(ODistributedWorker.java:300)\r\n        at com.orientechnologies.orient.server.hazelcast.ODistributedWorker.run(ODistributedWorker.java:121)\r\n```\r\n\r\nIf I change distributed-config.json to have all clusters on all servers, then the program executes as expected.\r\n\r\n```\r\n\"clusters\":{\r\n...\r\n\"vertex1_server1\":{ \"servers\":[\"server1\", \"server2\", \"<NEW_NODE>\"]}\r\n\"edge1_server1\"  :{ \"servers\":[\"server1\", \"server2\", \"<NEW_NODE>\"]}\r\n\"vertex2_server2\":{ \"servers\":[\"server1\", \"server2\", \"<NEW_NODE>\"]}\r\n...\r\n}\r\n```\r\n\r\nI already raised a question in https://groups.google.com/forum/#!msg/orient-database/E6sxiLYJ9og/q4VGB9_F0SYJ, and Luigi suggests to create a new issue.\r\n\r\nIt seems to me that while edge1 is going to be created, server1 firstly lock vertex1 and ask server2 to create edge1. When server2 wishes to update vertex2 for edge1, it asks for the lock of vertex1 and deadlock happens so the procedure ends up in timeout.\r\n\r\nActually i kept all the server logs and configurations, but I have no idea how to upload them. In case it's needed, I'll paste the logs in this thread.\r\n\r\nThe simple test case is as below.\r\n\r\n```\r\nimport com.tinkerpop.blueprints.impls.orient.OrientGraphFactory\r\n\r\nimport scala.collection.JavaConverters._\r\nimport scala.collection.JavaConversions._\r\n\r\nobject OrientdbTestdbImporter {\r\n\r\n  val uris = Array(\"remote:server1/testdb\")\r\n  val dbs = Array(new OrientGraphFactory(uris(0), \"admin\", \"admin\").setupPool(100, 200))\r\n\r\n  def main(args: Array[String]) {\r\n\r\n    val graphDB = dbs(0).getTx()\r\n\r\n    val v1 = graphDB.addVertex(\"class:Vertex1,cluster:vertex1_server1\", Map(\"pid\" -> \"v1\").asJava.asInstanceOf[java.util.Map[String,Object]])\r\n    graphDB.commit()\r\n    println(\"Add v1\")\r\n\r\n    val v2 = graphDB.addVertex(\"class:Vertex2,cluster:vertex2_server2\", Map(\"pid\" -> \"v2\").asJava.asInstanceOf[java.util.Map[String,Object]])\r\n    graphDB.commit()\r\n    println(\"Add v2\")\r\n\r\n    val e1 = v1.addEdge(\"Edge1\", v2, \"Edge1\", \"edge1_server1\", Map().asJava.asInstanceOf[java.util.Map[String,Object]])    println(\"Add e1\")\r\n    graphDB.commit()\r\n\r\n    println(\"OK\")\r\n\r\n    dbs.foreach( _.close())\r\n  }\r\n}\r\n```\r\n\r\nThanks,\r\nClark"},"comment":{"url":"https://api.github.com/repos/orientechnologies/orientdb/issues/comments/111463115","html_url":"https://github.com/orientechnologies/orientdb/issues/4338#issuecomment-111463115","issue_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/4338","id":111463115,"user":{"login":"lvca","id":312606,"avatar_url":"https://avatars.githubusercontent.com/u/312606?v=3","gravatar_id":"","url":"https://api.github.com/users/lvca","html_url":"https://github.com/lvca","followers_url":"https://api.github.com/users/lvca/followers","following_url":"https://api.github.com/users/lvca/following{/other_user}","gists_url":"https://api.github.com/users/lvca/gists{/gist_id}","starred_url":"https://api.github.com/users/lvca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lvca/subscriptions","organizations_url":"https://api.github.com/users/lvca/orgs","repos_url":"https://api.github.com/users/lvca/repos","events_url":"https://api.github.com/users/lvca/events{/privacy}","received_events_url":"https://api.github.com/users/lvca/received_events","type":"User","site_admin":false},"created_at":"2015-06-12T11:32:56Z","updated_at":"2015-06-12T11:32:56Z","body":"Clark, we have a similar test case in TestSharding.java. Please could you see if your case si so much different?"}}