Paritioned Graph. Error on saving record when creating vertex and adding edge in the same transacti

78 views
Skip to first unread message

Krzysztof Genge

unread,
Jul 7, 2015, 5:14:41 PM7/7/15
to orient-...@googlegroups.com
I am using OrientDB version 2.0.11 and am trying to implement partitioned graph like described in docs (http://orientdb.com/docs/last/orientdb.wiki/Partitioned-Graphs.html)
My use case requires to create a Vertex and Edge linking that Vertex to another one in the same transaction (this vertex should be visible only to the user who created it).

code snippet:
...
final Map<String, Object> properties = ;//some properties
final Vertex categoryVertex = ((OrientGraph) graph).addVertex(CategoryVertex.CATEGORY_CLASS_NAME, properties);
final Edge edge = categoryVertex.addEdge("IS_PARENT", parentCategoryVertex);//parentCategoryVertex - existing vertex retrieved from orientDB or vertex created in the same transaction
...

My DB  V and E classes inherit from ORestricted class just like in official documentation.
If I run this code as user with write permissions I get an error:

code snippet:
Unhandled exception
com.orientechnologies.orient.core.exception.ODatabaseException: Error on saving record #11:-3
    at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.executeSaveRecord(ODatabaseDocumentTx.java:1792) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.tx.OTransactionOptimistic.addRecord(OTransactionOptimistic.java:312) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.tx.OTransactionOptimistic.saveRecord(OTransactionOptimistic.java:253) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.save(ODatabaseDocumentTx.java:2309) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.save(ODatabaseDocumentTx.java:2143) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.save(ODatabaseDocumentTx.java:118) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinaryV0.recursiveLinkSave(ORecordSerializerBinaryV0.java:664) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinaryV0.writeOptimizedLink(ORecordSerializerBinaryV0.java:688) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinaryV0.writeSingleValue(ORecordSerializerBinaryV0.java:572) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinaryV0.serialize(ORecordSerializerBinaryV0.java:261) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinary.toStream(ORecordSerializerBinary.java:104) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.record.impl.ODocument.toStream(ODocument.java:2100) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.record.impl.ODocument.toStream(ODocument.java:695) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.executeSaveRecord(ODatabaseDocumentTx.java:1690) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.tx.OTransactionOptimistic.addRecord(OTransactionOptimistic.java:312) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.tx.OTransactionOptimistic.saveRecord(OTransactionOptimistic.java:253) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.save(ODatabaseDocumentTx.java:2309) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.save(ODatabaseDocumentTx.java:118) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:1727) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:1718) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:76) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.db.record.ridbag.embedded.OEmbeddedRidBag.serialize(OEmbeddedRidBag.java:371) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.db.record.ridbag.ORidBag.toStream(ORidBag.java:274) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinaryV0.writeSingleValue(ORecordSerializerBinaryV0.java:581) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinaryV0.serialize(ORecordSerializerBinaryV0.java:261) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinary.toStream(ORecordSerializerBinary.java:104) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.record.impl.ODocument.toStream(ODocument.java:2100) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.record.impl.ODocument.toStream(ODocument.java:695) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.commitEntry(OAbstractPaginatedStorage.java:1939) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.commit(OAbstractPaginatedStorage.java:922) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.tx.OTransactionOptimistic.doCommit(OTransactionOptimistic.java:488) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.tx.OTransactionOptimistic.commit(OTransactionOptimistic.java:147) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.commit(ODatabaseDocumentTx.java:2430) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.commit(ODatabaseDocumentTx.java:2400) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.commit(ONetworkProtocolBinary.java:1088) ~[orientdb-server-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.executeRequest(ONetworkProtocolBinary.java:390) ~[orientdb-server-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.server.network.protocol.binary.OBinaryNetworkProtocolAbstract.execute(OBinaryNetworkProtocolAbstract.java:217) ~[orientdb-server-2.0.11.jar:2.0.11]
    at com.orientechnologies.common.thread.OSoftThread.run(OSoftThread.java:69) ~[orientdb-core-2.0.11.jar:2.0.11]
Caused by: java.lang.NullPointerException: null
    at com.orientechnologies.orient.core.metadata.security.ORestrictedAccessHook.isAllowed(ORestrictedAccessHook.java:128) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.metadata.security.ORestrictedAccessHook.onRecordBeforeUpdate(ORestrictedAccessHook.java:91) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.hook.ODocumentHookAbstract.onTrigger(ODocumentHookAbstract.java:248) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.callbackHooks(ODatabaseDocumentTx.java:983) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.tx.OTransactionOptimistic.addRecord(OTransactionOptimistic.java:292) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.tx.OTransactionOptimistic.saveRecord(OTransactionOptimistic.java:253) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.save(ODatabaseDocumentTx.java:2309) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.save(ODatabaseDocumentTx.java:118) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:1727) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:1718) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:76) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.db.record.ridbag.embedded.OEmbeddedRidBag.serialize(OEmbeddedRidBag.java:371) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.db.record.ridbag.ORidBag.toStream(ORidBag.java:274) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinaryV0.writeSingleValue(ORecordSerializerBinaryV0.java:581) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinaryV0.serialize(ORecordSerializerBinaryV0.java:261) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinary.toStream(ORecordSerializerBinary.java:104) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.record.impl.ODocument.toStream(ODocument.java:2100) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.record.impl.ODocument.toStream(ODocument.java:695) ~[orientdb-core-2.0.11.jar:2.0.11]
    at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.executeSaveRecord(ODatabaseDocumentTx.java:1690) ~[orientdb-core-2.0.11.jar:2.0.11]
    ... 37 common frames omitted
    if (missingEnvironmentVariables) {
        throw new GradleException("Missing environment variables: ${missingEnvironmentVariables}")
    }
}

After short analyse the null pointer is trigger when trying to validate permissions for update operation on vertex that does not exist in DB yet (the one that is created in the running tansaction)

If I run this code as admin user (which has role database.bypassRestricted to bypass the record level security) 
the execution is successful -> the vertex and linking edge are created.

The question is: how to make it work for standard users? 

Thanks in advance for any suggestions.
 
Reply all
Reply to author
Forward
0 new messages