June 26, 2007

MySQL 4.0 Merge Tables Incompatibility

Recently Yahoo! small bussiness encountered an interesting error when they tried to upgrade from MySQL 4.0.26 to 4.1.23. This is really interesting how MySQL rolled out an in-compatibility change in the minor version from 4.1.22 to 4.1.23 without much of specifying it any where nor how to get around the problem.

Here is the scenario. When you have a regular table with a simple PRIMARY KEY column and a merge table on top of that base table in MySQL 4.0; then upgrading to 4.1.23 (enterprise release or from the current bitkeeper source) causes the table un-usable due to the check on internal data structure used when building the key/index columns. It works fine even with 4.1.22 community release.

Lets consider with the real example now:

  1. First connect to MySQL 4.0.26 server; and create a simple table(base_t1) with a integer primary key column(id) and an associated merge table (merge_t1):
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 1 to server version: 4.0.24-Yahoo-SMP-log
     
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
     
    mysql> CREATE TABLE IF NOT EXISTS base_t1 (
        -> id int NOT NULL PRIMARY KEY
        -> ) TYPE = MyISAM;
    Query OK, 0 rows affected (0.00 sec)
     
    mysql> CREATE TABLE IF NOT EXISTS merge_t1 (
        -> id int NOT NULL PRIMARY KEY
        -> ) TYPE = MRG_MyISAM INSERT_METHOD=LAST UNION=(base_t1);
    Query OK, 0 rows affected (0.00 sec)
     
    mysql> desc base_t1;
    +-------+---------+------+-----+---------+-------+
    | Field | Type    | Null | Key | Default | Extra |
    +-------+---------+------+-----+---------+-------+
    | id    | int(11) |      | PRI | 0       |       |
    +-------+---------+------+-----+---------+-------+
    1 row in set (0.00 sec)
     
    mysql> desc merge_t1;
    +-------+---------+------+-----+---------+-------+
    | Field | Type    | Null | Key | Default | Extra |
    +-------+---------+------+-----+---------+-------+
    | id    | int(11) |      | PRI | 0       |       |
    +-------+---------+------+-----+---------+-------+
    1 row in set (0.00 sec)
     
    mysql> exit
  2. Now, upgrade the MySQL Server to 4.1.23 by keeping the same old data files and once the server is upgraded; try to select or describe the merge table(mege_t1); and it pops up with an error as shown below:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 2 to server version: 4.1.23-5b-Yahoo-SMP-log
     
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
     
    mysql> desc base_t1;
    +-------+---------+------+-----+---------+-------+
    | Field | Type    | Null | Key | Default | Extra |
    +-------+---------+------+-----+---------+-------+
    | id    | int(11) |      | PRI | 0       |       |
    +-------+---------+------+-----+---------+-------+
    1 row in set (0.00 sec)
     
    mysql> desc merge_t1;
    ERROR 1168 (HY000): Unable to open underlying table which is differently defined or of non-MyISAM type or doesn''t exist
    mysql> select * from merge_t1;
    ERROR 1168 (HY000): Unable to open underlying table which is differently defined or of non-MyISAM type or doesn''t exist

The reason for this is; MySQL has rolled out a change to identify what data structures are used to build the key/index columns; and by default it is HA_KEY_ALG_UNDEF in MySQL 4.0 and from 4.1.23 onwards it will be either of the following:

  • HA_KEY_ALG_BTREE
  • HA_KEY_ALG_RTREE
  • HA_KEY_ALG_HASH
  • HA_KEY_ALG_FULLTEXT

So, if you recreate the base table back in 4.1; everything works fine because it uses the right type as shown below:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    
    mysql> drop table base_t1;
    Query OK, 0 rows affected (0.01 sec)
     
    mysql> CREATE TABLE IF NOT EXISTS base_t1 (
        -> id int NOT NULL PRIMARY KEY
        -> ) TYPE = MyISAM;
    Query OK, 0 rows affected, 1 warning (0.00 sec)
     
    mysql> desc base_t1;
    +-------+---------+------+-----+---------+-------+
    | Field | Type    | Null | Key | Default | Extra |
    +-------+---------+------+-----+---------+-------+
    | id    | int(11) |      | PRI | 0       |       |
    +-------+---------+------+-----+---------+-------+
    1 row in set (0.00 sec)
     
    mysql> desc merge_t1;
    +-------+---------+------+-----+---------+-------+
    | Field | Type    | Null | Key | Default | Extra |
    +-------+---------+------+-----+---------+-------+
    | id    | int(11) |      | PRI | 0       |       |
    +-------+---------+------+-----+---------+-------+
    1 row in set (0.00 sec)

But the question is “why did MySQL rolled this incompatible change” ?, can not they mark HA_KEY_ALG_UNDEF as HA_KEY_ALG_BTREE as the default one in 4.1 and above ?

This really breaks most of the existing tables merge tables as they can’t even open the file due to this invalid check; and only options left is to re-create the tables. I released a new version internally in Yahoo! to bipass the check by using a configurable variable; and after that, everything seemed to be working fine

June 17, 2007

Random OS Crash with Bootcamp 1.3

Recently after upgrading to Bootcamp 1.3; I noticed that when working under Windows Vista under direct dual boot Bootcamp; at times; the Macbook pro automatically exists the OS and restarts back without even any problem indication. This is annoy at times without any issues. This indicates that this is not an OS issue, instead something todo with Macbook pro or Bootcamp. I also upgraded the Mac Drivers from 1.2 to 1.3 by re-creating the drivers CD from the Bootcamp Asssistant; but still no luck.

In a side note; I also noticed when the Windows prompts Windows Error Recovery screen during the boot when the OS shuts abnormally; I see the Macbook keyboard doesn’t work; so I have to wait till it completes 28 sec nor it allowed to to select alternative boot options as the none of the keys works.

Also; when the battery drains out of the Macbook on Vista; I never get any critical battery alarm before it shuts off; Macbook seemed to shutoff the OS suddenly without even any alarm even though it seemed to be configured.

June 16, 2007

No luck with Parallels 4128 - Same Problems

Still am fighting to get Parallels 3.0 (build 4124 and 4128) to work on my Macbook Pro with my Windows Vista Ultimate edition which is running fine under Bootcamp along with VMware fusion beta 4. Today, I upgraded from Parallels build 4124, which used to cause blue screen of death to Parallels 4128; and the same problem(s) continues again with new upgraded release; not sure how to get Parallels to work with Bootcamp Vista.

I get the new blue screen of death now. So, I booted back Vista under parallels using Safeboot with network; and uninstalled Parallel Tools. But sub-sequent boots caused the Vista not able to boot under Parallels as well as VMware; as it is keep complaining about the missing c:\windows\system32\hal.dll file at the boot screen itself.

So, I did a direct boot to Vista; and that seemed to work, which saved my life not to reinstall or repair the Vista OS…and this time I didn’t dare to boot back with Parallels ; as every time I boot; I get into new set of problems. VMware Fusion seemed to be working fine, even though I noticed that it tries to register the OS again…but at-least it looks like stable on my environment; and I think I will get settled with Fusion for now; as it has much better performance than Parallels along with it also supports Readyboost. I will wait for the upgraded version of Parallels to try later and also wait for Fusion to support Unity for Vista editions.

June 12, 2007

MySQL Windows Debug Server - Run Time Checks

Today I just did a fresh rebuild of MySQL 5.1.19 on my Windows XP laptop using Visual Studio 2005. The build process is straight forward with few initial steps:

  1. I already have Visual Studio 2005 Professional edition installed.
  2. Installed cmake
  3. I also installed Windows Bison port, even though am not sure if I will change the parser code.
  4. Extracted the source files to a directory
  5. Ran win/configure WITH_INNOBASE_STORAGE_ENGINE from the top directory
  6. Once the configure completed; executed win\build-vs8.bat; which generated the project workspaces (sln and vcproj) without any problems.

Once I have the MySQL.sln project workspace file; loaded with Vistual Studio 2005 and started the debug build by making mysqld as the startup project. The build completed without any errors.

I started the mysqld debug server under debugger; and when I tried to connect and/or execute any query to this server; the server generates the error Run-Time Check Failure #3 - The variable ‘MYSQLlVal’ is being used without being initialized. I did not wanted to change the source code; so found a solution to turn off this run time checks by going to project settings -> mysqld properties -> Configuration properties -> C/C++ -> Code Generation and changed the Basic Runtime Checks value to “Stack Frames (/RTCs)” from “Both (/RTC1, equv. to /RTCsu)”. Once this this value is changed and did a complete rebuild of the mysqld project workspace; and the resulted debug server did not popup anymore runtime errors.

June 11, 2007

Safari on Windows Vista

Today Apple released the public beta 3 Safari browser for Windows. I downloaded and installed it on my Windows Vista and browser seemed to work fine without any problems. Most of the websites rendered without any issues. Even though I didn’t like the way the browser adjusts the data to fit to screen as it makes it uneasy to view when it moves the contents over the page for the proper layout (I noticed this even with Firefox at times, but only IE does it clean)

Only thing that I noticed is, Yahoo! beta mail gave a warning that the browser is not supported and upon continuing I was able to view the messaged. But when I tried to reply a mail; the compose editor becomes blank. So, looks like some work pending from mail team.

Another good thing is it gives an option to change the default search engine to either Google search or Yahoo! search. There is no stunning feature in Safari which can take the users away from IE as IE 7 also has all most all the features that Safari provides. Only people who hates Windows/IE has another source other than Firefox now. May be it will take some share away from Firefox on Windows.

As it only released now; only few default plugins are provided by Apple for time being. And there is no customization for browser in terms of placing the icons or changing the theme yet. Not sure apple will ever support that. Atleast Apple should change the page title bar font and its background.

I also noticed that the safari crashed 3 to 4 times when I hit the back button on my website as well from Apple website. Also; the back button seemed to take longer time than IE.

June 9, 2007

Failed to boot to Vista after Parallels upgrade

After updating Parallels (3.0 build 4124) and VMWare Fusion (beta 4 build 48339) to the latest version; the real fun started when I got a death of blue screen when I booted bootcamp Vista from Fusion.

Initially I upgraded Fusion and booting to bootcamp vista seemed to working fine. But after I installed Parallels; then I couldn’t boot back using Fusion. Looks like the Parallels tools drivers has caused the problem. As the error is coming from prlfs.sys file and this file looks like part of Parallels.

So, to get around this issue, I started the Vista in direct boot to uininstall Parallel tools; but that popped that I can only do this when running under virtual machine but nothing seemed to be right; becuase I can’t load the control panel nor get into any settings. I was able to check this by going to Explorer -> Uninstall or change a problem.

Booting with Parallels causes new blue screen of death. So ran a check disk on vista by doing a direct reboot; which recovered lot of files (especially all parallels related)…after done with check disk; rebooted with Parallels under safeboot with network and uninstalled the parallels tools and did a clean shutdown.

Now booting with Fusion worked fine. For the direct boot, windows asked me to enter the product key again before it actually started log me in…so upon doing so, could able to login to my system and everything seemed to be working now; and am not daring to start Parallels again with Bootcamp partition, but instead will stick to Fusion and Bootcamp. This recommends me that, I should be away from Parallels for time being.

Upgraded Bootcamp, Parallels and Fusion

Today I upgraded the following three major components on my macbook pro to have better Windows experience.

  1. Bootcamp 1.3
  2. VMWare fusion beta 4, build 48339
  3. Parallels 3.0, build 4124

All three components had major improvements in terms of stability, features and Bootcamp vista support. First and foremost I upgraded my Bootcamp 1.2 to 1.3; and the upgrade is very smooth and no issues and nothing.

Second, I upgraded fusion and even that upgrade went very smooth without any issues. After starting the Windows vista from bootcamp using fusion; and I noticed significant improvements to overall look and feel and performance along with unity feature (which is supposed to be the parallels coherence killer); unfortunately on my install; the unity feature is disabled. Not sure it is because of Bootcamp. But will fight with it later on.

Lastly I upgraded Parallels from 3188 to build 4124; and this version did not work with my earlier key; so need to go ahead with a trial version. First time booting to bootcamp Vista took me lot of time because it tried to install Parallels tools automatically by default along with subsequent boot time is also takes long time and the display is not as good when compared with fusion or direct boot; but overall good to see the bootcamp vista support from parallels. In a side note; when I booted through direct boot; a window pops up that Parallel tools can only be ran in virtual machine, this is a lame work from Parallels team; they should have fixed this becuase thats supposed to be a basic way that people will togle between virtual machine and direct boot.

At least things seemed to be OK for time being. Currently am settled with Fusion.