You are viewing fallenpegasus

entries friends calendar profile My Website Previous Previous Next Next
Mark Atwood - Logging in Drizzle, Part 1
Add to Memories
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),
(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: , ,
Current Location: Working from home, Seattle WA

From: darnaut Date: January 13th, 2009 11:29 am (UTC) (Link)

drizzle logging to file

The format for unsigned long is %lu, not %ld (same comment apply to others). BTW, it would be interesting to hear how you got rid of the various mutex locks.. are you guys using FILE? How do you guys managed to make writing to the file thread-safe?
1 comment or Leave a comment
Mark Atwood
Name: Mark Atwood
Website: My Website
Back May 2014
page summary