Skip to content

Instantly share code, notes, and snippets.

@giastfader
Created October 5, 2013 16:10
Show Gist options
  • Select an option

  • Save giastfader/6842734 to your computer and use it in GitHub Desktop.

Select an option

Save giastfader/6842734 to your computer and use it in GitHub Desktop.
OrientDB: retry edge creation in case of vertex stealing
int maxRetries=MVCC_MAX_RETRIES;
boolean done=false;
OConcurrentModificationException e =null;
for (int i=1;i<=maxRetries;i++){
try {
Logger.debug("Creation of the edge. Attempt n. " + i);
db.createEdge((ODocument)vertex1.reload().getRecord(),vertex2).save();
done=true;
Logger.debug("Edge created successfully after " + i + " attempts");
break;
}catch (OConcurrentModificationException ex){
e=ex;
Logger.debug ("+++ vertex1 was modified by another thread. Let's retry. This was the attempt n. " + i);
Thread.sleep(1);
}
}
if (!done) throw e;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment