Currently, there is one Job Acquisition Thread per cluster node, which puts the acquired Jobs into a queue, which is then processed by the worker threads. This queue is of type List<List<String>> with the inner list being a list of exclusive job ids that belong to the same process instance.
New exclusive Jobs that are created, while another exclusive Job is executed, go currently not into the existing exclusive jobs set, but are free to be aquired by any Job Acquisition Thread of the cluster and processed by any worker thread.
Our idea is that a thread immediately locks new exclusive jobs for its cluster node and adds it to the list of exclusive jobs it is currently processing.
This way ActivitiOptimisticLockingExceptions at parallel joins can be completely avoided even in clustered environments.
Basic hooks already available, most notably the property in the jobs table. No schema changes will be necessary.