DuplicateKeyException - TInkerPop3/OrientDB M1

16 views
Skip to first unread message

Christos Vasilakis

unread,
Jul 19, 2017, 12:25:49 PM7/19/17
to OrientDB
Hi there,

Sorry if this has been asked before but what is the proper way to handle a DuplicateKey exception when using the following TinkerPop API to add a new Vertex?

Vertex server = traversal.V().hasLabel("Servers")
.has("name", serverId)
.tryNext().orElseGet(
() -> traversal.addV(T.label, "Servers", "name", serverId).next());

I have multiple processes running trying to insert data in the database but sometimes this fails cause as I suspect (can be wrong) an insert is attempted but an insert has been made already by a different process.
I am bulk-loading concurrently a bunch of data, per process insertion is done in serial form (that is one record at a time aka no multiple threads)  and each process share different subset of data. It just happen to kick them both  at the same time with an empty database beforehand.

In particular I am getting the following exception
com.orientechnologies.orient.core.storage.ORecordDuplicatedException: Cannot index record Servers{name:server1}: found duplicated key 'server1' in index 'Servers.name' previously assigned to the record #34:0

I am just getting started with TinkerPop3 API and using the M1 release of OrientDB (orientdb-community-tp3-3.0.0m1) for experimentation.

Thank you in advance.

-
Christos



Reply all
Reply to author
Forward
0 new messages