Skip to content

2.27.0.0-b576

@druzac druzac tagged this 17 Sep 13:31
Summary:
7f56068 introduced a deadlock in the pg client service shutdown path. The `CheckExpiredSessions` callback, run by the `check_expired_sessions_` scheduler, can deadlock with the shutdown thread calling `PgClientServiceImpl::Impl::Shutdown` when the shutdown thread calls `check_expired_sessions_::Shutdown` while holding `PgClientServiceImpl::Impl::mutex_` inside `PgClientServiceImpl::Impl::Shutdown`. The issue is `CheckExpiredSessions` tries to acquires `PgClientServiceImpl::Impl::mutex_` and the scheduler's `Shutdown` method blocks waiting for all inflight tasks to complete, so the two threads can deadlock on `PgClientServiceImpl::Impl::mutex_`.

This diff removes lock guard annotation from `check_expired_sessions_` so `check_expired_sessions_::Shutdown` can be called without holding the pg client service lock.
Jira: DB-18293, DB-4289

Test Plan:
```
/yb_build.sh --cxx-test='TEST_F(PgAdvisoryLockTest, SessionLockDeadlockWithRowLocks) {' -n 60 --tp 1 --stop-at-failure
```

Reviewers: bkolagani, sergei

Reviewed By: bkolagani

Subscribers: ybase, rthallam, yql

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