AnsweredAssumed Answered

Concurrent data modification handling discussion

Question asked by ancoron on Sep 17, 2011
Hi devs,

let's discuss here, what has been reported with https://jira.codehaus.org/browse/ACT-901 and how Activiti can help to avoid such situations altogether.

The problem (from my point of view) is simple: there are writers and readers in different threads and transactions.

Now if someone just uses Activiti with its capability to parallelize executions the user might expect that Activiti handles these situations.

So now for some out-of-the-box available solutions (please contribute if you think something is missing):

  • Optimistic locking approach using the existing MVCC (all the burder to the developer of the process for the error case)

  • synchronizing writes only (read-committed - read-uncommitted possible inside same JVM)

  • synchronize reads and writes (read-committed only, readers blocked until previous writers committed)
At least I've implemented the second option using an "unfair" ReentrantLock in some of my applications and they work fine inside a single JVM. However, in a clustered scenario you may go for option 2 too which means that readers might get old data at some point and writers would have to synchronize using the database or another mechanism suitable in clustered/distributed environments.

Outcomes