Wednesday, December 13

How gdb can help you to solve MySQL problems

What you can do with gdb

  • Check stack traces (and variables), per thread: thread apply all bt [full]
  • Print variables, up to complex one:
  • thread 1
  • print do_command::thd->query_string.string.str
  • Set new values for variables (global and per thread, even those formally read-only in MySQL while it’s running):
  • set max_connections=5000
  • set opt_log_slave_updates=1
  • Call functions (that may do complex changes):
  • call rpl_filter->add_do_db(strdup("hehehe"))
  • Set breakpoints and watchpoints
  • Work interactively or use gdb as a command line utility (-batch)
  • Use macros, Python scripting, more…
  • All these may not work, fail, hang, crash, produce obscure errors…
  • You have to read and understand the source code