diff options
author | Sergei Golubchik <serg@mariadb.org> | 2021-05-03 23:31:33 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2021-06-09 18:36:43 +0200 |
commit | 7e9bc7bf4e79463779a3f8c370c7244ff77ae15d (patch) | |
tree | 387279d165f823ee7670720ff9ca10fc365a8fc5 /sql/mdl.cc | |
parent | b81803f0657b1693ac42643ae39ff25ccc42db36 (diff) | |
download | mariadb-git-7e9bc7bf4e79463779a3f8c370c7244ff77ae15d.tar.gz |
mdl_dbug_print_locks(): make it useful in gdb too
Diffstat (limited to 'sql/mdl.cc')
-rw-r--r-- | sql/mdl.cc | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/sql/mdl.cc b/sql/mdl.cc index 5e54178db70..4cb1154b8eb 100644 --- a/sql/mdl.cc +++ b/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 */ |