98826d9 Ticket 51068 - deadlock when updating the schema

Authored and Committed by tbordaz 3 years ago
    Ticket 51068 - deadlock when updating the schema
    
    Bug Description:
            It exists a 3 threads deadlock scenario. It involves state change plugins when it
            calls schema_changed_callback. So the trigger is a change of schema (direct or via
            replication). The scenario is
          MOD(cn=schema)    hold StateChange lock   wait for vattr lock
          SRCH              hold vattr lock         wait for DB page
          MOD               hold DB page            wait for StateChange lock
    
    Fix Description:
            Statechange lock protects the list of registered callbacks.
            lock is a mutex where actually registration of callback is only done
            at startup. Later the list is only lookup.
            Making statechange lock a rwlock suppresses the deadlock scenario
            as MODs will only acquire in read StateChange lock.
            It should also improve performance as at the moment all MODs are serialized
            on that lock
    	In order to prevent writer starvation a new slapi_new_rwlock_prio
            create rwlock with priority to writers.
    
    https://pagure.io/389-ds-base/issue/51068
    
    Reviewed by: Mark Reynolds, William Brown
    
    Platforms tested: 30
    
    Flag Day: no
    
    Doc impact: no
    
        
file modified
+1 -1