Innodb is full of crap

Innodb code is full of crap. All across the source base it pretends that it can do multiple log groups. But it always initializes only one. And sometimes at random places it acknowledges this fact. There is a case of this schizophrenia within single function. In file log0log.c, function log_write_up_to(), we see the code with this comment:

group = UT_LIST_GET_FIRST(log_sys->log_groups);
        group->n_pending_writes++;      /*!< We assume here that we have only
                                        one log group! */

Then a few lines below we see iteration over the list of groups.

group = UT_LIST_GET_FIRST(log_sys->log_groups);
        /* Do the write to the log files */
        while (group) {
                group = UT_LIST_GET_NEXT(log_groups, group);

Why iterate over the list that always has only one member? Why have this list at all, why it’s not direct pointer to the log group? Who needs multiple log groups that never are? Even more interesting is that there is a large part of log-related code that stays there but is disabled with #ifdefs. This is the code for something called log archives. The related configuration options are documented like this:

  • innodb_log_arch_dir
    This variable is unused, and is deprecated as of MySQL 5.0.24. It is removed in MySQL 5.1
  • innodb_log_archive
    Whether to log InnoDB archive files. This variable is present for historical reasons, but is unused. Recovery from a backup is done by MySQL using its own log files, so there is no need to archive InnoDB log files. The default for this variable is 0.

Almost half (albeit disabled) of 3500+ lines of log0log.c file from MySQL 5.1 still deal with these log archives. And this code is still there in MySQL 5.5. Is there anybody who needs it?

The same is for support for some ancient checksum algorithms. I guess the Innodb files with these checksums if still can be found then it’s only on certain spacious 40MB hard-drives that collect dust in some abandoned garage in Finland.

And let’s not forget that wonderful uber-portable 64-bit arithmetic with the help of macros. Yes, it makes the code so readable. I just like to learn what are the current target platforms where there is no compiler available with “long long” or “int64_t” arithmetic? I believe that in year 2011 we could already think of 32-bit arithmetic as something special and 64-bit as the default.

All in all, with all the effort to scale up MySQL to high-end servers why not start cleaning up the mess already?

Leave a Reply

Your email address will not be published. Required fields are marked *