MySQL 8.3.0
Source Code Documentation
rw_pr_lock_t Struct Reference

Portable implementation of special type of read-write locks. More...

#include <thr_rwlock_bits.h>

Public Attributes

native_mutex_t lock
 Lock which protects the structure. More...
 
native_cond_t no_active_readers
 Condition variable which is used to wake-up writers waiting for readers to go away. More...
 
unsigned int active_readers
 Number of active readers. More...
 
unsigned int writers_waiting_readers
 Number of writers waiting for readers to go away. More...
 
bool active_writer
 Indicates whether there is an active writer. More...
 
my_thread_t writer_thread
 Thread holding wr-lock (for debug purposes only). More...
 

Detailed Description

Portable implementation of special type of read-write locks.

These locks have two properties which are unusual for rwlocks: 1) They "prefer readers" in the sense that they do not allow situations in which rwlock is rd-locked and there is a pending rd-lock which is blocked (e.g. due to pending request for wr-lock). This is a stronger guarantee than one which is provided for PTHREAD_RWLOCK_PREFER_READER_NP rwlocks in Linux. MDL subsystem deadlock detector relies on this property for its correctness. 2) They are optimized for uncontended wr-lock/unlock case. This is scenario in which they are most often used within MDL subsystem. Optimizing for it gives significant performance improvements in some of tests involving many connections.

Another important requirement imposed on this type of rwlock by the MDL subsystem is that it should be OK to destroy rwlock object which is in unlocked state even though some threads might have not yet fully left unlock operation for it (of course there is an external guarantee that no thread will try to lock rwlock which is destroyed). Putting it another way the unlock operation should not access rwlock data after changing its state to unlocked.

TODO/FIXME: We should consider alleviating this requirement as it blocks us from doing certain performance optimizations.

Member Data Documentation

◆ active_readers

unsigned int rw_pr_lock_t::active_readers

Number of active readers.

◆ active_writer

bool rw_pr_lock_t::active_writer

Indicates whether there is an active writer.

◆ lock

native_mutex_t rw_pr_lock_t::lock

Lock which protects the structure.

Also held for the duration of wr-lock.

◆ no_active_readers

native_cond_t rw_pr_lock_t::no_active_readers

Condition variable which is used to wake-up writers waiting for readers to go away.

◆ writer_thread

my_thread_t rw_pr_lock_t::writer_thread

Thread holding wr-lock (for debug purposes only).

◆ writers_waiting_readers

unsigned int rw_pr_lock_t::writers_waiting_readers

Number of writers waiting for readers to go away.


The documentation for this struct was generated from the following file: