Concurrency during UPDATE ADD operation

31 views
Skip to first unread message

Eric24

unread,
Nov 11, 2017, 7:53:27 PM11/11/17
to OrientDB
If two clients perform an UPDATE ADD on the same record at the same time, do both ADD operations always succeed without an exception (since they can't conflict with each other by definition)? What about two PUT operations, with different/non-conflicting keys?

Eric24

unread,
Nov 12, 2017, 1:11:52 PM11/12/17
to OrientDB
To follow up on this, would LOCK RECORD be necessary? If I didn't want to incur the lock overhead, is there a way to set the concurrency strategy on the transaction (i.e. normally use "version", but select "automerge" for this operation)?

Luigi Dell'Aquila

unread,
Nov 13, 2017, 3:19:43 AM11/13/17
to orient-...@googlegroups.com
Hi Eric,

UPDATE ADD is just a normal record change, the record is completely overwritten and the version is increased, so you will have a normal ConcurrentModificationException if two operations happen at the same time.
My general advice in these cases is to use a commit/retry strategy. If you are doing it via SQL, just do 

BEGIN; 
UPDATE... ADD...;
COMMIT RETRY 10;

This way you will avoid lock overheads in most of the cases and you will have a retry only when it's strictly needed.

I hope it helps

Thanks

Luigi


--

---
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-database+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eric24

unread,
Nov 15, 2017, 1:37:31 PM11/15/17
to OrientDB
Hmmm. I had thought that ADD and PUT operations would be atomic? If they are not, what about INCREMENT? The docs certainly suggest that INCREMENT is atomic (it doesn't make the same claim about ADD or PUT, but I just assumed they would be).
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.

Luigi Dell'Aquila

unread,
Nov 16, 2017, 3:17:43 AM11/16/17
to orient-...@googlegroups.com
Hi Eric,

all these operations are atomic because of MVCC/optimistic locking, ie. if you do two INCREMENT on the same record in concurrency, one of the two will fail. This is why I suggested a commit/retry, just to let OrientDB manage the retry for you without any further effort at application level

Thanks

Luigi


To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscribe@googlegroups.com.

Eric Lenington

unread,
Nov 16, 2017, 10:50:33 AM11/16/17
to OrientDB
OK. That makes sense. I thought those operations were "inherently atomic", but they are really just doing an update like any other. The commit/retry is fine, I was just trying to make sure I understood.

--

---
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/6w2ZkOvNwnw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orient-database+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages