ef9d7d4 Ticket 50745: ns-slapd hangs during CleanAllRUV tests

1 file Authored by tbordaz 4 years ago, Committed by mreynolds 4 years ago,
    Ticket 50745: ns-slapd hangs during CleanAllRUV tests
    
    Bug Description:
    	The hang condition:
    		- is not systematic
    		- occurs in rare case, for example here during the deletion of a replica.
    		- a thread is waiting for a dblock that an other thread "forgot" to
    		  release.
    		- have always existed, at least since 1.4.0 but likely since 1.2.x
    
    	When deleting a replica, the replica is retrieved from
    	mapping tree structure (mtnode).
    	The replica is also retrieved through the mapping tree
    	when writing updates to the changelog.
    
    	When deleting the replica, mapping tree structure is cleared
    	after the changelog is deleted (that can take some cycles).
    	There is a window where an update can retrieve the replica,
    	from the not yet cleared MT, while the changelog being removed.
    
    	At the end, the update will update the changelog that is
    	currently removed and keeps an unfree lock in the DB.
    
    Fix description:
    	Ideally mapping tree should be protected by a lock but it
    	is not done systematically (e.g.  slapi_get_mapping_tree_node).
    	Using a lock looks an overkill and can probably introduce
    	deadlock and performance hit.
    	The idea of the fix is to reduce the window, moving the
    	mapping tree clear before the changelog removal.
    
    https://pagure.io/389-ds-base/issue/50745
    
    Reviewed by: Mark Reynolds, Ludwig Krispenz