• Hugo Beauzée-Luyssen's avatar
    Cache: Fix a race condition · 25213b7c
    Hugo Beauzée-Luyssen authored
    This was causing the insertion assert to trigger, due a thread querying
    the database while:
    - Holding the cache lock
    - Acquiring the database lock
    - Inserting the fetched entity in cache if it didn't exist
    
    While another thread was inserting an entity while:
    - Holding the database lock
    - Releasing it after the insertion was done
    - Holding the cache lock
    - Checking that the entity didn't exist in cache
    
    Since the locking order wasn't consistent, the 1st thread was
    interupting the 2nd before it was done with the entire insertion
    method, causing an inconsistent state.
    25213b7c