Archive for the 'Geek' Category

MySQL 5.0.48 proof that the MySQL release cycle is completely broken.

Sunday, December 9th, 2007

When I received and email almost two years ago about a announcement that MySQL was going to release and enterprise product I was very excited. I was looking forward to a redhat style model of vetting releases in the community then offering a proven stable version to paying customers. I saw it as a great way to for MySQL to generate revenue as well as eliminate the need for people to stay a few releases back from the head and guess when to upgrade.

The release shocked me. What was originally emailed to me and the final plan were two very different things. It was a plan to hand paying customers bleeding edge code that had been tested only by MySQL’s QA team. It seems MySQL has forgotten the years of testing by millions of community members that has given MySQL the stability we have grown to trust. I predicted the instability of MySQL enterprise back in October ‘06 by saying that releasing patches in enterprise that hadn’t been tested by the community would result in instable releases being delivered to paying customers. These should always be tested by the community first.

MySQL 5.0.48 enterprise is rock solid proof that the release cycle MySQL chose to implement is completely broken. It was released then pulled due to some very basic sorting functionality being broken. I hope they’re working to change the release cycle to more of a redhat model both to put trust back in the community for testing and to give enterprise customers the stable version they’re paying for.

Just Incase but not in time

Wednesday, November 7th, 2007

I’m not the only one to drop my iphone. However, I am one of the few to drop my iphone and have it impact pavement on the edge of the glass and shatter half way across the screen. Apple is nice enough to ‘repair’ accidental damage for $250. By repair I mean replace the phone on site. While it seems steep for a repair fee remember that most other companies make you buy a new one.

With my newly repaired iphone I also picked up a black incase for it. The case feels like it’s protecting the iphone well but it makes it more difficult to put in your pocket and the dock is now useless. The case makes the phone too wide to slide into the case. All other functionality is available with the case on. The case also covers the edge of the glass where my old phone impacted pavement.

WOTD: awksome

Wednesday, October 24th, 2007

Referring to a shell command that uses awk in a creative way. As in, “That shell command was awksome!”.

If you have no idea what I’m talking about. Wikipedia can fill you in on the power of awk.

MySQL bugbot and status changes

Monday, September 10th, 2007

MySQL Bug Tracker

I realize that MySQL is in a transitional phase making it’s development more transparent to the community so this entry isn’t really a rant but something that will hopefully ease the transition. The public MySQL bug tracker doesn’t seem to have any way to view the history of status changes to a bug. Things like changing a bug from open to inactive. I assume there will always be things that should be hidden from bugs like links to sites internal to MySQL AB but things like simple status changes should be visible to the public.

For example on this Bug #20358 Heikki posted a comment that he was moving the bug from open to unable to repeat. Did he actually make the change? I have no idea because I can’t access the status log. Was it ever changed from unable to repeat back to open or verified? Again I have no idea…

Another “feature” of the bug system that I find questionable is the bug bot. The script trolls the bug database looking for bugs that need an automatic state change. In my opinion it should never find anything. I’ve noticed that it changes state on bugs that haven’t been commented on for a month to an inactive status. I have one example of a Bug #26489 that I think is fairly critical being marked in an inactive state not because the bug wasn’t still occurring, but because we had no new useful information to post at the time. Just because no new information has been found doesn’t necessarily mean that a bug should be taken off of people’s radar. If humans want to mark them as inactive it’s fine but a script making that decision worries me.

I do appreciate the things MySQL has done recently to make the development process more accessible for those of us without MySQL AB on our name tag. #mysql-dev on freenode is well populated with very intelligent minds. It’s nice to have them readily accessible to bounce ideas off of.

Keep the momentum on this transition going and please don’t mark my blog post as inactive :)

GroundWork Open Source

Sunday, August 26th, 2007

Are you afraid of nagios because of the config files? Don’t worry you’re not alone. GroundWork to the resuce! GroundWork is a set of packages that takes the pain out of configuration for nagios. It’s a web based GUI that supports importing existing nagios configs, audo discovery of servers and much more. I hate for this to sound like an advertisement for GroundWork but it does solve most of my major complaints about nagios. The most important of which is that it’s a pain to setup and configure. GroundWork with basic checks can be setup on a friday afternoon.

I do have a few complaints. First the configuration EZ and configuration sub menus aren’t logical. Configuration doesn’t have commit. In order for any changes to take effect you have to go back to the Configuration EZ menu. This should really be changed to have configuration basic and advanced, both with commit capability. Easy is essentially worthless.

Another issue is the use of RRD for performance historical data. This paragraph deserves it’s own post and I’ll write it some day. For now I’ll just cover the main issue I have not with RRD itself but the way RRD is used most of the time. RRD is purely for round robin data. Historical performance data is not round robin. Hell it has “history” right in the name. This data should be kept as long as possible. It’s useful for planning capacity for future events based on previous events. Aggregating away history data into month or year graphs means it’s impossible to go back and see what traffic looked like on dec 25th 2005 or any other random date(s) because RRD has either purged it or aggregated it away into a yearly view. I know it’s possible to disable the aggregation on rrd but the preallocation of data files makes this impractical for long term data storage and constantly changing servers and services. Once again RRD is a fine tool for what’s it meant to be used for it’s just not meant for historical data.

Anyway if you like nagios but are afraid of the configs give GroundWork a try. Beware! If you install it on a server with and existing apache package GroundWork will overwrite /etc/init.d/httpd

Google WiFi a failed experiment in Mountain View.

Monday, August 13th, 2007

When I first moved to down town Mountain View the person at the leasing office spent about 15 minutes trying to convince me that DSL/Cable availability wasn’t an issue because Google was going to provide free internet to all of Mountain View. I tried to explain that WiFi wasn’t good enough because I routinely ssh into servers across the country thus ping time is critical. My initial assumptions about Google WiFi have been proven right over the past two years. Unless you’re aligned with Google just right it doesn’t work. I’ve tried from in buildings, in parkings lots all around town my conclusion is that it’s a compete and total failure.

I’m willing to give them a few more months to get it working in downtown mountain view. What I can’t forgive is the fact that they can’t get it working from their own campus. I’m at Google HQ building 43 right now for the MySQL Meetup and I can see an SSID for Google WiFi from my laptop but I can’t connect to it long enough to even authenticate through wifi.google.com. To me a good way to promote your free wifi service is to have it readily available on your campus.

I’ll continue the hunt for a google wifi “hotspot” in down town mountain view but don’t hold your breath.

tests and mysql-test sub directories

Sunday, August 12th, 2007

Recently I’ve been making more modifications to the MySQL source. Part of making modifications is testing them. For years I’ve been curious why there are both tests and mysql-test sub directories in the source tarballs. Arjen Lentz tells me that tests is old and that mysql-test is the current testing framework. This makes sense since the manual testing pages are all about mysql-test.

Are there plans to clean up the remnants of the old testing framework? What else is there in the tarball that’s outdated and needs to be removed?

set sql_log_slow=0 to control the slow query log.

Tuesday, July 3rd, 2007

Currently there isn’t a good method to control sending individual queries to the slow query log. Typically this isn’t an issue. It becomes an issue when using very short query times and importing sql files. The slow query log doesn’t have a limit on the length of queries it will write to a log. If you’re importing a sql file with inserts that get sent to the log mysql will dump the entire insert query. This can cause the slow query log to grow to gigs in size in a very short time.

I’ve patched mysql 5.0.41 to add a session variable called sql_log_slow (think sql_log_bin) that when set to 0 will prevent queries from that session from being sent to the slow query log. The patch also updates mysqlbinlog to set that variable in it’s output. One issue with this patch is that the executable comment version in mysqldump is set to 5.0.41 but it will error when imported on any 5.0.41 server that doesn’t have this patch. If it’s merged the version in the comment will need to be bumped.

sql_log_slow is also handy for controlling noise in the slow query log. It can be used to prune down queries that are known to be slow so only true problem queries are logged.

Here is the patch. I’ll post this on internals soon.

How alter table locks tables and handles transactions

Monday, May 7th, 2007

I’ve talked to several people that have questions about how alter table works under the hood. They want to know how it handles locking tables why they can sometimes use a table during alter table and other times they can’t. Also why it’s so slow :)

First let’s look at the basic process alter table typically goes through.

  1. If a transaction is open on this thread, commit it.
  2. Acquire a read lock for the table.
  3. Make a temporary table with new structure
  4. Copy the old table to the temporary table row by row changing the structure of the rows on the fly.
  5. Rename the original table out of the way
  6. Rename the temporary table to the original table name.
  7. Drop the original table.
  8. Release the read lock.

The slowest part of the process is copying rows from the original table to the temporary table. For large tables this can take minutes to hours. There are a few optimizations built into this process. If the alter table query only renames the table then mysql doesn’t bother copying all the rows to a temporary table and just renames it. For most other things such as renaming columns, adding/dropping indexes, making columns nullable, changing the column default all require copying the entire table.

During the first 4 steps MySQL allows other clients to read from the table being altered. When alter table is done copying rows to the temporary table and is ready to rename it it changes the table lock. MySQL instructs all other clients currently reading from the table to close the table when they are done. While alter table is waiting for existing clients to finish reading from the table it prevents other clients from starting to read from the table. During this time selects will be blocked on “Waiting for tables”. When the last client is done reading from the table alter table continues renaming the table.

This has some interesting implications for transactions and repeatable reads. Internally innodb keeps track of when rows are created. When a transaction is started it can only see rows that were created before the transaction was started (using repeatable read). Any rows created after are not returned. Since alter table copied rows from the old table to the new table rows get a new version number as they are inserted into the temporary table. An alter table can cause a dirty read in transactions that span an alter table. Transactions started before alter table will get no rows back from the table after alter table is finished. If your application is sensitive to dirty reads or getting no rows back from a table (really dirty read :) ) then don’t run alter table on a server when clients are running.

Here is an example.

mysql a> alter ignore table t add unique index (t);

mysql b> begin;
Query OK, 0 rows affected (0.00 sec)

#This select is from the original table while alter table is copying rows
mysql> select * from t limit 10;
+——+
| t |
+——+
| 10 |
| 10 |
| 10 |
| 10 |
| 10 |
| 10 |
| 10 |
| 10 |
| 10 |
| 10 |
+——+
10 rows in set (0.00 sec)
#alter table finishes
#Rows created in the temporary table before we issued begin
mysql> select * from t limit 10;
+———-+
| t |
+———-+
| 10 |
| 6920631 |
| 27998430 |
| 41865298 |
| 49403894 |
+———-+
5 rows in set (0.00 sec)

#Get a new view of the table
mysql> commit;
Query OK, 0 rows affected (0.00 sec)

#This select returns all the rows.
mysql> select * from t limit 10;
+———–+
| t |
+———–+
| 10 |
| 6920631 |
| 27998430 |
| 41865298 |
| 49403894 |
| 50522347 |
| 84441015 |
| 109401269 |
| 110202688 |
| 123590778 |
+———–+
10 rows in set (0.00 sec)

If we start the transaction before alter table the select after alter table has finished will return no rows even though there are rows in the table. I’m not sure why innodb allows rename of a table when transactions still have a few of that table open. It seems like a bug to me.

[Updated 2007-05-14 Bug #28432

select sql_cache_ttl

Monday, April 23rd, 2007

I’ve been thinking about the query cache since last years user conference. One of the features of the query cache is that it’s completely transparent to client. It achieves this by clearing cache entries for tables as soon as the tables are updated. This makes the cache inefficient for tables that are constantly updating.

While thinking about this also thought about slaves and non critical reads. In a replication setup reads that are sent to slaves expect to get data back that might not be the most current. In this situation it doesn’t make sense to expire the cache for every single update because queries running against the slave already know that they are going to get back slightly old data. I thought, “Why not add a time to live to cache entries instead of clearing them for every update?” So, I did.

I added an option to select called sql_cache_ttl. This option instructs the query cache hold the entry in the cache for query_cache_ttl seconds. query_cache_ttl can be set globally or per thread. Initial testing shows that it does help eliminate the cache thrashing that occurs during updates on tables that have many large cache entries.

I have a few more optimizations that I want to add to the patch before sending it into MySQL. The patch below is a preview that works with 5.0.37.

The patch.