https://bugs.openldap.org/show_bug.cgi?id=10095
--- Comment #5 from Peter Zhu peter@peterzhu.ca ---
We can add a flag to the lockfile for "mutex is valid"
I think this will guarantee that this bug does not occur, but I think that there is a chance of a livelock since p1 and p2 can be stuck in a cycle of acquire read lock, check that the "mutex is valid" is not set, try to acquire a write lock, fail because both are holding a read lock, release read lock and try again. It might be able to mitigate this by performing random backoff, but that's probably bad for performance.
Probably we should revert the ITS#9278 patch.
That's what we did in our production systems, it seems to have resolved the issue. AFAIK Linux does not allocate any memory in `pthread_mutex_init`, so not calling `pthread_mutex_destroy` shouldn't leak memory (although according to specification we're supposed to call `pthread_mutex_destroy` when we're done using it).