MySQL 9.1.0
Source Code Documentation
User_level_lock_wait_error_handler Class Reference

When MDL detects a lock wait timeout, it pushes an error into the statement diagnostics area. More...

Inheritance diagram for User_level_lock_wait_error_handler:
[legend]

Public Member Functions

 User_level_lock_wait_error_handler ()
 
bool got_timeout () const
 
bool handle_condition (THD *, uint sql_errno, const char *, Sql_condition::enum_severity_level *, const char *) override
 Handle a sql condition. More...
 

Private Attributes

bool m_lock_wait_timeout
 

Additional Inherited Members

- Protected Member Functions inherited from Internal_error_handler
 Internal_error_handler ()
 
Internal_error_handlerprev_internal_handler () const
 
virtual ~Internal_error_handler ()=default
 

Detailed Description

When MDL detects a lock wait timeout, it pushes an error into the statement diagnostics area.

For GET_LOCK(), lock wait timeout is not an error, but a special return value (0). NULL is returned in case of error. Capture and suppress lock wait timeout. We also convert ER_LOCK_DEADLOCK error to ER_USER_LOCK_DEADLOCK error. The former means that implicit rollback of transaction has occurred which doesn't (and should not) happen when we get deadlock while waiting for user-level lock.

Constructor & Destructor Documentation

◆ User_level_lock_wait_error_handler()

User_level_lock_wait_error_handler::User_level_lock_wait_error_handler ( )
inline

Member Function Documentation

◆ got_timeout()

bool User_level_lock_wait_error_handler::got_timeout ( ) const
inline

◆ handle_condition()

bool User_level_lock_wait_error_handler::handle_condition ( THD thd,
uint  sql_errno,
const char *  sqlstate,
Sql_condition::enum_severity_level level,
const char *  msg 
)
inlineoverridevirtual

Handle a sql condition.

This method can be implemented by a subclass to achieve any of the following:

  • mask a warning/error internally, prevent exposing it to the user,
  • mask a warning/error and throw another one instead. When this method returns true, the sql condition is considered 'handled', and will not be propagated to upper layers. It is the responsibility of the code installing an internal handler to then check for trapped conditions, and implement logic to recover from the anticipated conditions trapped during runtime.

This mechanism is similar to C++ try/throw/catch:

  • 'try' correspond to THD::push_internal_handler(),
  • 'throw' correspond to my_error(), which invokes my_message_sql(),
  • 'catch' correspond to checking how/if an internal handler was invoked, before removing it from the exception stack with THD::pop_internal_handler().
Parameters
thdthe calling thread
sql_errnothe error number for the condition raised.
sqlstatethe SQLSTATE for the condition raised.
levelthe severity level for the condition raised.
msgthe error message for the condition raised.
Returns
true if the condition is handled

Implements Internal_error_handler.

Member Data Documentation

◆ m_lock_wait_timeout

bool User_level_lock_wait_error_handler::m_lock_wait_timeout
private

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