-
Notifications
You must be signed in to change notification settings - Fork 18
[Bug] Concurrent read to Orion's in-memory cache layer could lead to lost updates #168
Description
Problem
Orion has an in-memory entity cache layer (aka overlay) which is used to persist save/update/remove DB operations, and then flush/commit them in bulk.
The problem is that concurrent reads/writes to overly could lead to lost updates if the concurrent operations are working with the same entity ID.
This issue(#166) is happening in DataObjectsDeleted mapping while trying to unset asset relations, since this function is concurrently trying to unset all asset relations from the same referencing entity (e.g Video/Channel). While unsettling reference of one asset the update made by the other unsettling operation could get lost if the entity was not present in the cache and had to be retrieved from the db. The outcome of this error is that processor could crash since Postgre's foreign key referential constraint would be violated
Fix
We could resolve this issue by ensuring that access to the overlay's cache is synchronous if two operations try to access the same entity record. This could be achieved by implementing the locking mechanism in the overlay.