dreamscale-io/gridtime

IdeaFlow engine - duplicate key exceptions on feature cache when running concurrently

accolasia opened this issue · 1 comments

When there's multiple concurrent attempts to create the same feature key, duplicate key exceptions will occur. Need to debug the specific use cases, where this is happening, but since there is no guarding against this case in place right now, will likely need to implement a retry, so that if two threads try to key the same feature at the same time, the second thread can pick up the key generated from the first, and keep on going.

Added synchronization locks when resolving the same feature type, and then forced commit of transaction within the scope of the lock so that other transactions in other threads would be able to see it.

Tried using REQUIRES_NEW on the Spring transaction propagation to solve this, but for some reason doesn't work, and ended up creating a new EntityManager using the factory to be able to force commit the transactions... I'm having issues with connection leaks now for the multi-threaded tests which could be related to this though... needs more investigation whether this works as a solution, or causes unfortunate side effects.

The immediate concurrency problem with the exceptions is fixed for now.