MDL_lock encapsulation: notify_conflicting_locks()

Avoid accessing MDL_lock::m_rwlock from MDL_context::acquire_lock(),
use MDL_lock::notify_conflicting_locks_if_needed() instead.

Also MDL_lock::needs_notification() doesn't require MDL_lock::m_rwlock
protection, so it is moved out of critical section.

This is part of broader cleanup, which aims to make large part of
MDL_lock members private. It is needed to simplify further work on
MDEV-19749 - MDL scalability regression after backup locks.
This commit is contained in:
Sergey Vojtovich 2025-05-01 13:40:36 +04:00 committed by Sergei Golubchik
parent 84d85849a0
commit 3c1b80a1bf

View File

@ -780,6 +780,17 @@ end:
mysql_prlock_unlock(&m_rwlock);
}
void notify_conflicting_locks_if_needed(MDL_ticket *ticket, bool abort_blocking)
{
if (needs_notification(ticket))
{
mysql_prlock_wrlock(&m_rwlock);
notify_conflicting_locks(ticket->get_ctx(), abort_blocking);
mysql_prlock_unlock(&m_rwlock);
}
}
const MDL_lock_strategy *m_strategy;
private:
static const MDL_backup_lock m_backup_lock_strategy;
@ -2500,10 +2511,7 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout)
break;
}
mysql_prlock_wrlock(&lock->m_rwlock);
if (lock->needs_notification(ticket))
lock->notify_conflicting_locks(this, abort_blocking);
mysql_prlock_unlock(&lock->m_rwlock);
lock->notify_conflicting_locks_if_needed(ticket, abort_blocking);
}
if (wait_status == MDL_wait::EMPTY)
wait_status= m_wait.timed_wait(m_owner, &abs_timeout, TRUE,