Mark Atwood (fallenpegasus) wrote,
Mark Atwood
fallenpegasus

Logging in Drizzle, Part 1

A feature of the MySQL server that is used a lot, and yet is a source of much user confusion, code complexity, and multiprocessor lock contention, is logging. Query logging, slow query logging, and the new 5.1 feature, "log to table".

I've removed most all of that stuff from Drizzle (and removed two or three sets of now-no-longer-necessary mutex locks in the process), and replaced it with hooks into a logging plugin subsystem, and have implemented two plugins for it. One logs to a file, and the other logs to syslog.

The output looks almost completely unlike the current MySQL logging. There are no hash-prefixed pseudocomments, for one thing. And there is no distinction between the query log and the slow query log. Queries get logged, and the amount of time each query takes gets logged with it. This subsumes the "micro-slow patch" that is spreading around in the MySQL legacy world.

The current format is pretty "programmer-centric", but concrete advice and patches are welcome.


snprintf(msgbuf, MAX_MSG_LEN,
"thread_id=%ld query_id=%ld"
" t_connect=%lld t_start=%lld t_lock=%lld"
" command=%.*s"
" rows_sent=%ld rows_examined=%u\n"
" db=\"%.*s\" query=\"%.*s\"\n",
(unsigned long) session->thread_id,
(unsigned long) session->query_id,
(unsigned long long)(t_mark - session->connect_utime),
(unsigned long long)(t_mark - session->start_utime),
(unsigned long long)(t_mark - session->utime_after_lock),
(uint32_t)command_name[session->command].length,
command_name[session->command].str,
(unsigned long) session->sent_row_count,
(uint32_t) session->examined_row_count,
session->db_length, session->db,
session->query_length, session->query);



How to interpret this output, and how to turn on, control, and use logging, will be described in additional posts.
Tags: drizzle, geek, mysql
Subscribe
  • Post a new comment

    Error

    Comments allowed for friends only

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 1 comment