MySQL 9.1.0
Source Code Documentation
MDL_deadlock_handler Class Reference

An error handler which converts, if possible, ER_LOCK_DEADLOCK error that can occur when we are trying to acquire a metadata lock to a request for back-off and re-start of open_tables() process. More...

Inheritance diagram for MDL_deadlock_handler:
[legend]

Public Member Functions

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

Private Attributes

Open_table_contextm_ot_ctx
 Open table context to be used for back-off request. More...
 
bool m_is_active
 Indicates that we are already in the process of handling ER_LOCK_DEADLOCK error. More...
 

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

An error handler which converts, if possible, ER_LOCK_DEADLOCK error that can occur when we are trying to acquire a metadata lock to a request for back-off and re-start of open_tables() process.

Constructor & Destructor Documentation

◆ MDL_deadlock_handler()

MDL_deadlock_handler::MDL_deadlock_handler ( Open_table_context ot_ctx_arg)
inline

Member Function Documentation

◆ handle_condition()

bool MDL_deadlock_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_is_active

bool MDL_deadlock_handler::m_is_active
private

Indicates that we are already in the process of handling ER_LOCK_DEADLOCK error.

Allows to re-emit the error from the error handler without falling into infinite recursion.

◆ m_ot_ctx

Open_table_context* MDL_deadlock_handler::m_ot_ctx
private

Open table context to be used for back-off request.


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