MySQL 8.4.2
Source Code Documentation
Deadlock_notifier Class Reference

A static class for reporting notifications about deadlocks. More...

Public Member Functions

 Deadlock_notifier ()=delete
 

Static Public Member Functions

static void notify (const ut::vector< const trx_t * > &trxs_on_cycle, const trx_t *victim_trx)
 Handles writing the information about found deadlock to the log files and caches it for future lock_latest_err_file() calls (for example used by SHOW ENGINE INNODB STATUS) More...
 

Static Private Member Functions

static bool is_allowed_to_be_on_cycle (const lock_t *lock)
 Determines if a situation in which the lock takes part in a deadlock cycle is expected (as in: handled correctly) or not (say because it is on a DD table, for which there is no reason to expect a deadlock and we don't handle deadlocks correctly). More...
 
static void print (const trx_t *trx, ulint max_query_len)
 Print transaction data to the deadlock file and possibly to stderr. More...
 
static void start_print ()
 rewind(3) the file used for storing the latest detected deadlock and print a heading message to stderr if printing of all deadlocks to stderr is enabled. More...
 
static void print (const lock_t *lock)
 Print lock data to the deadlock file and possibly to stderr. More...
 
static void print (const char *msg)
 Print a message to the deadlock file and possibly to stderr. More...
 
static void print_title (size_t pos_on_cycle, const char *title)
 Prints a numbered section title to the deadlock file and possibly to stderr. More...
 

Detailed Description

A static class for reporting notifications about deadlocks.

Constructor & Destructor Documentation

◆ Deadlock_notifier()

Deadlock_notifier::Deadlock_notifier ( )
delete

Member Function Documentation

◆ is_allowed_to_be_on_cycle()

bool Deadlock_notifier::is_allowed_to_be_on_cycle ( const lock_t lock)
staticprivate

Determines if a situation in which the lock takes part in a deadlock cycle is expected (as in: handled correctly) or not (say because it is on a DD table, for which there is no reason to expect a deadlock and we don't handle deadlocks correctly).

The purpose of the function is to use it in an assertion failing as soon as the deadlock is identified, to give developer a chance to investigate the root cause of the situation (without such assertion, the code might continue to run and either fail at later stage when the data useful for debugging is no longer on stack, or not fail at all, which is risky).

Parameters
[in]locklock found in a deadlock cycle
Returns
true if we expect that this lock can take part in a deadlock cycle

◆ notify()

void Deadlock_notifier::notify ( const ut::vector< const trx_t * > &  trxs_on_cycle,
const trx_t victim_trx 
)
static

Handles writing the information about found deadlock to the log files and caches it for future lock_latest_err_file() calls (for example used by SHOW ENGINE INNODB STATUS)

Parameters
[in]trxs_on_cycletrxs causing deadlock, i-th waits for i+1-th
[in]victim_trxthe trx from trx_on_cycle which will be rolled back

◆ print() [1/3]

void Deadlock_notifier::print ( const char *  msg)
staticprivate

Print a message to the deadlock file and possibly to stderr.

Parameters
msgmessage to print

◆ print() [2/3]

void Deadlock_notifier::print ( const lock_t lock)
staticprivate

Print lock data to the deadlock file and possibly to stderr.

Parameters
lockrecord or table type lock

◆ print() [3/3]

void Deadlock_notifier::print ( const trx_t trx,
ulint  max_query_len 
)
staticprivate

Print transaction data to the deadlock file and possibly to stderr.

Parameters
trxtransaction
max_query_lenmax query length to print

◆ print_title()

void Deadlock_notifier::print_title ( size_t  pos_on_cycle,
const char *  title 
)
staticprivate

Prints a numbered section title to the deadlock file and possibly to stderr.

Numbers do not have to be unique, as they are used to identify transactions on the cycle, and there are multiple sections per transaction.

Parameters
[in]pos_on_cycleThe zero-based position of trx on deadlock cycle
[in]titleThe title of the section

◆ start_print()

void Deadlock_notifier::start_print ( )
staticprivate

rewind(3) the file used for storing the latest detected deadlock and print a heading message to stderr if printing of all deadlocks to stderr is enabled.


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