Archive

Archive for March, 2009

MySQL wants Pluggable Query Cache too!

March 25th, 2009

I was pleased to wake up this morning to find a message from Monty Taylor on my IRC client about how MySQL is working towards a pluggable query cache API:

Why do I care? well I’ve been talking about a pluggable query cache interface for Drizzle from it’s early days so I was delighted to see that someone else in the world cares too. Here are my blog posts that describes this better:

An advise from me is that we can’t really promote the query cache feature with it’s current design since it is far more effective to use memcached directly from the application layer. We really need to come up with a design that allows the cache to be more granular (do better than table-level invalidation for every update) although this is easier said than done heh.

I totally look forward to seeing how the MySQL Query Cache API turns out anyway :)

Toru Maesaka drizzle, oss

Debugging Drizzle with GDB remotely from OS X

March 24th, 2009

If you’re a Mac user and often work remotely on Drizzle with Linux via SSH, this post is for you.

At some stage in your development process, you might come across a situation where you want to use GDB to see what’s going on inside the server process. Doing this is really simple as described in the Drizzle wiki:

$ cd /path/to/drizzle_source/tests
$ ./dtr --start-and-exit --gdb

However, you will find that the Server process will always fail to start. Don’t stress yet, the issue is simple. The --gdb startup routine fails because it tries to interact with a X server which you haven’t loaded.

Does this sound familiar? what you want to do in this case is use X11.app instead of Terminal.app (or iTerm) and ssh into the remote box with the -X option. You should then be able to simply follow the instructions on the Drizzle wiki.

That’s it, easy :)

Toru Maesaka drizzle , ,

Progress on the SQL Parser work

March 16th, 2009

Continued from my previous post on making the SQL parser pluggable in Drizzle.

So despite mentioning that I wanted to get the prototype done by the MySQL Users Conference 09 in april, it only took three motivated days to get what I stated done. One day on code reading (grasping the execution flow), one day on hacking it, and another day on testing and debugging. If you’re interested in the outcome, you can see the branch on Launchpad.

Pushing out the SQL parser from the core was easy since all I had to do was override the mysql_parse() entry point. The only issue I came across was how MySQL is designed to execute the query inside the parser. Needless to say, this was troublesome since a given component must be completely decoupled from the system for it to be separated.

To get around this obstacle, I ended up ripping out the query execution routine from the parser and to compensate this, I introduced a new wrapper function in the Drizzle core called sql_parse_and_execute().

static void sql_parse_and_execute(Session *session, const char *query,
                                  const size_t query_len,
                                  const char **found_semicolon)
{
  bool error= sql_parse(session, query, query_len, found_semicolon);
 
  if (!error && !session->is_error())
  {
    mysql_execute_command(session);
  }
 
  clean_parsed_tree(session);
}

Admittedly this solution is rough and I wasn’t 100% confident but it passed all the test cases so I pushed it to my experimental branch and threw it at the list anyway. This was a really good move since it brought up various discussions and the fundamental question of,

“is MySQL doing the right thing?”

from fellow Drizzle and MySQL developers.

As I previously mentioned, the current SQL Parser does too much by design. Ideally a parser should just create and return a Parse Tree from the query it was given. The core would then do whatever it needs to do with the tree (like create a execution plan) and free it when it’s done. Whether the execution planner should be part of the Parser Module or not is a different story of course.

The current parser is also tightly coupled with the Session object (known as THD class in MySQL) which needs to be dealt with. There are many other issues pointed out by the community and for those that are interested, you can view the thread here:

Doesn’t this show how transparent the Drizzle project is? :)

Admittedly, I’m too inexperienced at this stage to go any further on my own so I’m now planning on working closely with the veterans in the community and slowly learn as I go.

Happy Hacking!

Toru Maesaka drizzle, oss , ,

Thank you Apache, Greetings Nginx

March 3rd, 2009

Yesterday the hard drive of the physical web server that I was using for this blog decided to die. This was pretty funny since it happened within 24 hours after I predicted that my Mac was going to die before the web server.

Fortunately I had backed up my blog the day before so I didn’t lose any content. What was unfortunate though, was losing the templates that I made modifications to. Heh, guess its time for a new taste :)

This hardware failure gave me a good excuse to move away from the server that I technically didn’t own but was “gifted” by mixi (I’m now on a VPS by Slicehost). It also gave me a good excuse to upgrade WordPress which I’ve been neglecting to do for some time now.

But hey, not only I upgraded the CMS, I decided to do something different and use nginx, a Russian lightweight web server instead of Apache. I have nothing against Apache but I’ve been wanting to play with nginx for a while so it was a good time to try it out. For those that are curious, I didn’t go with lighttpd because I’ve already played with it in the past.

How’d it turn out?

If you’re seeing this blog post, it’s most likely working. That is, unless I’ve impulsively changed the http server after this entry (which is unlikely, at least in 2009).

My opinion so far is that nginx’s configuration file structure is fantastically nice. It feels like you’re actually coding something and it’s really simple. I had to do extra work to get FastCGI working with nginx (it won’t spawn a fcgi process for you) by using lighttpd’s spawn-fcgi (now a subproject of lighttpd) but nothing complicated.

This worked really well for 5 hours or so until the fcgi daemon decided to die on me… I’m not sure whether it was the daemon or PHP that caused the issue but I was too lazy to look into it so I configured daemontools to babysit fcgi for me.

So far, so good :)

Toru Maesaka oss , , ,