mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
mdl_dbug_print_locks(): make it useful in gdb too
This commit is contained in:
parent
b81803f065
commit
7e9bc7bf4e
2 changed files with 32 additions and 37 deletions
64
sql/mdl.cc
64
sql/mdl.cc
|
@ -224,6 +224,35 @@ private:
|
|||
static const uint MAX_SEARCH_DEPTH= 32;
|
||||
};
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
|
||||
/*
|
||||
Print a list of all locks to DBUG trace to help with debugging
|
||||
*/
|
||||
|
||||
static int mdl_dbug_print_lock(MDL_ticket *mdl_ticket, void *arg, bool granted)
|
||||
{
|
||||
String *tmp= (String*) arg;
|
||||
char buffer[128];
|
||||
MDL_key *mdl_key= mdl_ticket->get_key();
|
||||
size_t length;
|
||||
length= my_snprintf(buffer, sizeof(buffer)-1,
|
||||
"\nname: %s db: %.*s key_name: %.*s (%s)",
|
||||
mdl_ticket->get_type_name()->str,
|
||||
(int) mdl_key->db_name_length(), mdl_key->db_name(),
|
||||
(int) mdl_key->name_length(), mdl_key->name(),
|
||||
granted ? "granted" : "waiting");
|
||||
tmp->append(buffer, length);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *mdl_dbug_print_locks()
|
||||
{
|
||||
static String tmp;
|
||||
mdl_iterate(mdl_dbug_print_lock, (void*) &tmp);
|
||||
return tmp.c_ptr();
|
||||
}
|
||||
#endif /* DBUG_OFF */
|
||||
|
||||
/**
|
||||
Enter a node of a wait-for graph. After
|
||||
|
@ -2358,7 +2387,9 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout)
|
|||
switch (wait_status)
|
||||
{
|
||||
case MDL_wait::VICTIM:
|
||||
mdl_dbug_print_locks();
|
||||
DBUG_LOCK_FILE;
|
||||
DBUG_PRINT("mdl_locks", ("%s", mdl_dbug_print_locks()));
|
||||
DBUG_UNLOCK_FILE;
|
||||
my_error(ER_LOCK_DEADLOCK, MYF(0));
|
||||
break;
|
||||
case MDL_wait::TIMEOUT:
|
||||
|
@ -3241,34 +3272,3 @@ void MDL_ticket::wsrep_report(bool debug)
|
|||
psi_stage->m_name);
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
|
||||
/*
|
||||
Print a list of all locks to DBUG trace to help with debugging
|
||||
*/
|
||||
|
||||
static int mdl_dbug_print_lock(MDL_ticket *mdl_ticket, void *arg, bool granted)
|
||||
{
|
||||
String *tmp= (String*) arg;
|
||||
char buffer[128];
|
||||
MDL_key *mdl_key= mdl_ticket->get_key();
|
||||
size_t length;
|
||||
length= my_snprintf(buffer, sizeof(buffer)-1,
|
||||
"\nname: %s db: %.*s key_name: %.*s (%s)",
|
||||
mdl_ticket->get_type_name()->str,
|
||||
(int) mdl_key->db_name_length(), mdl_key->db_name(),
|
||||
(int) mdl_key->name_length(), mdl_key->name(),
|
||||
granted ? "granted" : "waiting");
|
||||
tmp->append(buffer, length);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mdl_dbug_print_locks()
|
||||
{
|
||||
String tmp;
|
||||
mdl_iterate(mdl_dbug_print_lock, (void*) &tmp);
|
||||
DBUG_PRINT("mdl_locks", ("%s", tmp.c_ptr()));
|
||||
}
|
||||
#endif /* DBUG_OFF */
|
||||
|
|
|
@ -1106,9 +1106,4 @@ typedef int (*mdl_iterator_callback)(MDL_ticket *ticket, void *arg,
|
|||
bool granted);
|
||||
extern MYSQL_PLUGIN_IMPORT
|
||||
int mdl_iterate(mdl_iterator_callback callback, void *arg);
|
||||
#ifndef DBUG_OFF
|
||||
void mdl_dbug_print_locks();
|
||||
#else
|
||||
static inline void mdl_dbug_print_locks() {}
|
||||
#endif /* DBUG_OFF */
|
||||
#endif /* MDL_H */
|
||||
|
|
Loading…
Reference in a new issue