Skip to content

2.25.1.0-b193

@es1024 es1024 tagged this 15 Jan 17:17
Summary:
This diff adds `RobustMutex`, which is a mutex that is robust to process crash even when held.

This is implemented with `PTHREAD_MUTEX_ROBUST`. When the owner of the mutex crashes,
the next mutex acquire will succeed and be notified that the previous owner had crashed. We
use this to trigger a cleanup callback which will perform any necessary work needed to bring the
state guarded by the mutex back to a consistent state.

`PTHREAD_MUTEX_ROBUST` is not implemented on OS X (which follows an older version of UNIX
that does not have it). Crashes while holding the mutex should ideally never happen, and OS X is
not used for production deployment, so we just use a normal mutex in shared memory for OS X.

This is needed for future changes to move the table locks lock manager into shared memory. For more
context: D40272.
Jira: DB-14789

Test Plan: Added tests: `./yb_build.sh --cxx-test 'util_robust_mutex-test'`

Reviewers: sergei, bkolagani, amitanand

Reviewed By: sergei

Subscribers: svc_phabricator, ybase, rthallam, zdrudi, amitanand

Differential Revision: https://phorge.dev.yugabyte.com/D41082
Assets 2
Loading