Wednesday, March 12, 2008

Disabling Mac OS X spotlight, or how to make your life complicated

Since my previous laptop is temporarily out of service, I am using a new one with Mac OS X Leopard. Which is cool, and it has great enhancements. However, after a few hours of usage, I noticed a sudden increase of CPU activity (+50%), for no apparent reason.
The resource monitor fingered a process named "mdworker", and Google took me to a page explaining that the real culprit is spotlight, which is indexing the disk contents.
Since I needed all the CPU power of my laptop to compile the latest server, I asked Google again, and I found a page with a method to disable Spotlight permanently. The recommended method involves root access, changing attributes of a long list of files, and a reboot. (!!!)
I could not afford the luxury of a reboot at the moment (and the instructions looked too obscure for my taste), and therefore I used an alternative (and more Mac-ish) way. I opened the spotlight options in System Preferences, found the privacy section, and added the whole Macintosh HD to the list of places not to index.


Ten seconds later, the CPU activity was back to normal.
I have enabled again the spotlight indexing during the night, and all is well.

Tuesday, March 11, 2008

Want a discount to attend the UC? Call a speaker!



Every speaker at the Users conference has a 20% discount code for friends and relatives who want to attend the UC2008.
Would you like to attend the UC, and save 20%? Send me a message! (my_first_name AT mysql DOT com).
If you don't know me, but you know another speaker, ask him or her for the discount code! And then, when you register for the conference, enter the discount code in the registration form.

Notice that I disabled comments to this post, so nobody will be tempted to ask for the code here. If you need the discount code, don't post comments. Send an email!

Reason #4 to attend the MySQL UC2008

MySQL Conference & Expo 2008
Disclaimer: Forget about my affiliation, this is my personal list of things that I am going to enjoy at the UC.

#4 A Tour of External Language Stored Procedures for MySQL



Eric Herman and Antony Curtis are hard workers. You don't see them bragging about this and that. They do long and thorough research, and then they prototype. At that point, they claim victory, and usually with reason.
Their work on stored procedures using external languages is one of the most refreshing pieces of new technology applied to MySQL since the announcement of MySQL 5.0.
If you are dissatisfied with the cumbersome heaviness of the standard stored routines, come to this session. You will be surprised of the interesting things you can do NOW with a MySQL server.

More reasons:

Reason #5 to attend the MySQL UC 2008

MySQL Conference & Expo 2008
Disclaimer: Forget about my affiliation, this is my personal list of things that I am going to enjoy at the UC.

#5 Database Security Using White-Hat Google Hacking



Sheeri always amazes me. When I think that I have seen all it has to be seen in the field of databases, she will always come with some innovative way of looking at old things.
This session is a series of aha! ideas. Some of them can have come to you. You may have heard of some others, but Sheeri does not stop at that. When she hears about a promising practice, she digs in, until she gets all is there to be learned.
She's a captivating speaker. Once you attend one of her sessions (or if you just talk to her in a corridor about anything), you are addicted. Highly recommended!

More reasons:

Monday, March 10, 2008

Reason #6 to attend the MySQL UC 2008

MySQL Conference & Expo 2008
Disclaimer: Forget about my affiliation, this is my personal list of things that I am going to enjoy at the UC.

#6 Optimizing MySQL and InnoDB on Solaris 10 for World's Largest Photo Blogging Community



Farhan Mashraqi knows his job. He must be good at it, because he has on his hands a very busy and heavily loaded server. Fotolog is one of those servers that can take away all your resources very quickly if you don't pay attention. If you want to stay online, you have to make sure that the server is always healthy and efficient.
The above is theory. Farhan tells you the practice behind this simple rule. He will show how to manage such a monster application and still ride the waves.
Don't miss it!

More reasons:

Did you back up your data today?

My laptop disk died on Friday.
Although this is a sad occurrence, I was very pleased to find out that my backup was in good shape, and I was back in working conditions 30 minutes after the accident.
I don't regret buying a 2 TB firewire hard disk.

That made a huge difference. Last time that I had a breakout, restoring 50GB from a USB external disk took about 5 hours. Transferring the same amount of data through a firewire interface takes now less than 25 minutes. I love technology!

Reason #7 to attend the MySQL UC 2008

MySQL Conference & Expo 2008
Disclaimer: Forget about my affiliation, this is my personal list of things that I am going to enjoy at the UC.

#7 MySQL Proxy : the complete tutorial


I shall start with a shameless plug, of course. I am going to enjoy this tutorial for several reasons.

For starters, it's the first tutorial I get to host at the Users Conference, and this is understandably satisfactory in itself.
Then, because it is going to give me the technical room that I was longing for. I have been writing and speaking about MySQL Proxy for 10 months, and on every occasion I felt that I had time or space limitations. There was not enough time to explain all that we can do with Proxy, or not enough time to write a longer article.
Now we can remedy. I and Jan Kneschke will have 6 full hours to explain Proxy beauty and intricacies, ranging from simple wizardry to replication goodies.
We will cover the basics of Lua language, with some internals, so that the attendees will leave the tutorial with the basic know-how to use the Proxy effectively.
There are still available seats. Hurry up and register!

Friday, March 07, 2008

Virtual attendance to Meetup-mashup in Boston - March 10

I love this company!
MySQL is still a virtual company. The Sun acquisition hasn't change this very peculiar fact. Yesterday and the day before we have held IRC meetings between the MySQL community and some Sun open source big shots.
virtual sea
On Monday evening in Boston, there will be a more traditional user group meeting in Boston, host by Sheeri K. Cabral. Actually, not very much traditional. I mean, the real people will physically attend the meetup, but the whole meetup will be recorded, and you can participate via IRC. And, even better, I will make a guest appearance via video-conference.
So, please meet me in Boston on March 10, at 7 PM EST, on a cold evening, while I will talk from Sardinia, 6,400 Km (4,000 miles) apart. Thanks Sheeri for organizing this event!

Thursday, March 06, 2008

Logs of IRC Meetup session with Ian Murdock

As Kaj announced, there was a IRC session with Ian Murdock on March 5.
Since I have been working in a virtual company for 18 months, I should not be surprised about this kind of events. Actually, IRC has become part of my life. I could not conceive working efficiently without it. When some new colleague asks me to have a simple phone call, without any IRC or other char facilities, I start shaking at the idea of such poor and antiquate way of communicating.
Even for one with experience, though, a public IRC meeting in a crowded #room is quite an experience. The "location" for the meeting is room #mysql on irc.freenode.net, a room that normally contains 400~500 people, where the level of noise is quite high.
Melbourne, Feb 2008
Having a public interview in such room is like crashing a party of bikers and start talking philosophy. The beauty of the system is that nobody seem to care. The bikers continue talking about their stuff, and our interview on philosophy went quite smoothly, albeit intermingled with requests of help (promptly answered by a bunch of MySQL geeks) and some trollish shouting that added color to the picture.
For the curious ones, here is the full session logs.

Monday, March 03, 2008

DISTINCT? Don't be lazy!

Sometimes, the easy solution is not the best one. I saw this problem happening several times. The query returns duplicates, and the first reaction of the developer is to fix it with DISTINCT.

Let's look at an example. Given the data below:

select * from people;
+-----------+-------+
| person_id | name |
+-----------+-------+
| 1 | Joe |
| 2 | Mary |
| 3 | Frank |
+-----------+-------+
3 rows in set (0.00 sec)

select * from projects;
+------------+-------------+-----------+
| project_id | descr | person_id |
+------------+-------------+-----------+
| 1 | Joe First | 1 |
| 2 | Joe second | 1 |
| 3 | Mary First | 2 |
| 4 | Mary second | 2 |
| 5 | Frank first | 3 |
+------------+-------------+-----------+
5 rows in set (0.00 sec)

select * from jobs;
+--------+-----------+-----------+------------+
| job_id | job_descr | person_id | project_id |
+--------+-----------+-----------+------------+
| 1 | joe aaa | 1 | 1 |
| 2 | joe bbb | 1 | 1 |
| 3 | joe ccc | 1 | 2 |
| 4 | Mary aaa | 2 | 3 |
| 5 | Mary bbb | 2 | 3 |
| 6 | Mary ccc | 2 | 3 |
| 7 | Mary ddd | 2 | 4 |
| 8 | Frank aaa | 3 | 5 |
| 9 | Frank bbb | 3 | 5 |
+--------+-----------+-----------+------------+
9 rows in set (0.01 sec)

The problem comes with this query:

SELECT p.name, COUNT(j.job_id) AS total , job_descr
FROM people p
INNER JOIN jobs j ON p.person_id = j.person_id
INNER JOIN projects pr ON pr.person_id = j.person_id
GROUP BY p.person_id ORDER BY total DESC,p.name;
+-------+-------+-----------+
| name | total | job_descr |
+-------+-------+-----------+
| Mary | 8 | Mary aaa |
| Joe | 6 | joe aaa |
| Frank | 2 | Frank aaa |
+-------+-------+-----------+

As you can easily see, the query reports twice the amount of jobs for Mary and Joe. The lazy solution is this

SELECT p.name, COUNT(DISTINCT j.job_id) AS total , job_descr
FROM people p
INNER JOIN jobs j ON p.person_id = j.person_id
INNER JOIN projects pr ON pr.person_id = j.person_id
GROUP BY p.person_id ORDER BY total DESC,p.name;
+-------+-------+-----------+
| name | total | job_descr |
+-------+-------+-----------+
| Mary | 4 | Mary aaa |
| Joe | 3 | joe aaa |
| Frank | 2 | Frank aaa |
+-------+-------+-----------+
However, this query does not tackle the real problem, which is that the query is joining two tables (projects and jobs) using a non-primary key column. And this "solution" also ignores the even more serious problem that the person_id is redundant, and should not be in the jobs table in the first place. Joining with a pair of primary/foreign key is the right cure:
SELECT p.name, COUNT(j.job_id) AS total, job_descr
FROM people p
INNER JOIN jobs j ON p.person_id = j.person_id
INNER JOIN projects pr ON pr.project_id = j.project_id
GROUP BY p.person_id ORDER BY total DESC,p.name ;
+-------+-------+-----------+
| name | total | job_descr |
+-------+-------+-----------+
| Mary | 4 | Mary aaa |
| Joe | 3 | joe aaa |
| Frank | 2 | Frank aaa |
+-------+-------+-----------+
The result is the same, but if you apply these queries on a couple of heavily populated tables, the first lazy query can be 5 times slower than the second one. The reason is simple: since the join was done on a non primary key column, the query performs a Cartesian product of projects and jobs, followed by a costly sort to remove the duplicates. The second query, instead, filters off the duplicates efficiently on the first step, thus delivering the wanted result faster.

Thursday, February 28, 2008

New Forge: Missing the bug!

Forge 2.0 was announced yesterday, and Jay and I were bracing ourselves for an avalanche of bugs, which did not come.
When Bug#34916 (Login not working on new forge site) was reported, I thought nothing of it. It was simply the wrong environment. The reporter could not log in, because he did not have an account.

I explained the problem, and felt good about it.
Sometimes I experienced reporting a bug and being told that it was intended behavior, not a bug, read the manual, thanks for writing, and that was it. So dry and clueless. Not inspiring for a further analysis.
So I took some minutes to explain what had happened, before closing the bug with the fatal words.
And the reporter, Diego Medina, wrote back, saying that indeed he did not have an account on wiki, and thus there was no bug. However, he reported a lack of message on a failed login, which made me suspicious.
So I tried logging in with a non existing account, and I was refused. Then I tried my account, with a wrong password. To my surprise, I was admitted. Then I logged out and I logged in again as Jay Pipes, with a wrong password, of course, because I don't know it.
Bingo! The system accepted my login. I was logged in as Jay. So the Forge was not checking the password at all. Something must have gone awry during the latest bug fixes.
I alerted Jay (not before changing his profile to a "lazy guy", though!) and he fixed the vulnerability in a few minutes. Apparently nobody noticed.
I found out the security hole thanks to Diego's suggestion. He actually found the bug, but he did not realize how serious it was. I feel positive vibes because I triggered Diego's comment with my explanation.
Note to bug verifiers (not all of them, but someone): sometimes, being kind can win you back some benefits!
Thanks Diego, for sending me to the right direction!
Community, please keep testing the new Forge!

Testing the new MySQL Forge


As Jay just just announced, we are launching Forge 2.0. This is a one man show, and that man is Jay. He designed and implemented the new Forge (and the old one, for that matter) almost entirely on his own. He fixed countless bugs, and after much suffering the community can now experience the new look and feel and the new cool features.
Thanks, Jay!

Now, if you want to help, enjoy the new Forge and report problems in our bugs system. Let me show you the general picture first,a nd then we'll see what to test.

A quick tour

There are many new features in the Forge:

  • The login. In the old Forge, you had two logins, one for the main forge and one for the wiki. In the new one there is only one login. If you had an account, use your email address and the wiki password to access the Forge.
  • The people section gives information on the user, and a summary of his/her contributions;
  • All sections can get votes. You can enter a vote from 1 to five for any project, tool, worklog.
  • The old snippets section is now called tools and code, to better describe what it contains. The code supports more languages than before (86 of them, actually!).
  • Comments. You can comment on any object (project, tool, worklog), using some HTML and special code tags.
  • The wiki is fully integrated, with the same look and feel, and a shared toolbar.



(Actually, I made a mistake in the example shown in this picture. I should have written "<b>bold</b> text" but you got the idea)

A testing check list


The new Forge has passed many checks, but we are sure that we must have missed something. And we know about some known bugs that we have not had time to fix, but we will tackle soon. Your help is much appreciated. If you have experience with MediaWiki and want to share your experience in fixing similar problems, by all means drop me or Jay a line, and we will be grateful.
Everyone else, you can just go through the list below, and report bugs to bugs system (Category: MySQL Forge).
  • Log in
  • edit an existing project (if you have created one before)
  • edit an existing tool (again, if you have created one before)
  • add a tag to a worklog/project/tool/person
  • search by tag
  • add a comment, using HTML or code tags
  • vote for a project/tool/worklog
  • add a new project and add tags
  • add a new tool and add tags
  • switch to the wiki, search for pages that you know in the old wiki, check that they are correct;
  • edit a wiki page
  • create a new wiki page
  • create a new user, login with this new entity, and do all the above
If that does not look enough to you, run around, and try to break things. Don't worry. We'll reload the database and fix the contents if you mess up too much.
However, remember that this is still a test environment. Everything you do will be overwritten on Monday, when we put the new Forge in production. Thus, play with it, but save important contents in the old wiki.

Troubleshooting


If your login does not work, remove all cookies related to forge1.mysql.com or forge.mysql.com and try again.
Remember that the new Forge uses the email address and the password of the old Forge wiki, not the main Forge.
One possible source of problems is when you had a different email address in the main forge and in the wiki. If that happened, we will be able to assign you ownership of the wiki pages you wrote, but not the projects and snippets. To fix that, go back to the old Forge and make sure that the email address used to login to the main forge matches the one used in the wiki, When we reload the database on Monday your previous work will be recognized. In the meantime, just create a fake account in the test forge, and enjoy the features!

Tuesday, February 26, 2008

Vim and MySQL, anyone?

On the Dev Zone there is a quick poll about your favorite IDE. The results from day one show a surprising preference for a lightweight editor, which happens to be my favorite as well.

Perhaps it's just a chance of the initial poll. We'll see in the next days.
However, it may be a good association of lightweight products. MySQL is a small, ubiquitous database server, compared to other more heavy products that need to be distributed in DVD, and the Vi family (with my favorite vim) is also small and ubiquitous.
What I loved a lot while working as a consultant is the ability of using syntax highlighting even in the most basic environments (i.e. a ssh connection on a terminal emulator) and the availability of vim in every operating system.


What's your take? Cast a vote for your favorite development environment.

Saturday, February 23, 2008

Bug or not bug? A Falcon mystery solved

Bug#33184 looked like a tough nut to crack. The initial report was quite clear. Some tests failed on Mac OS X.

I initially assumed that our testing boxes did not include the platform I was using, and informed Hakan. He tested the suite on his box, and reported success.
Too bad. Being able to reproduce a bug is the first step towards its fix. So we exchanged notes on how we compiled the sources. It turned out that I was using the optimized build, while Hakan was using a build with debug options.
I tried with debug options, and indeed, the test suite passed. However, since users are likely to adopt the optimized build, the bug was still confirmed.
More time passed. Hakan made some changes, and the test suite passed in his box, but failed in mine.
Finally, Hakan found the problem. The test suite failed because of the default gcc compiler provided by Apple. Mac OS X 10.4 and 10.5 offer gcc 4.0.1 with Xcode. Apparently, as Hakan found out, there is a bug in the exception handling of Apple's gcc.
After upgrading to gcc 4.2.2, the test suite passed without errors.
Good job, Hakan!

Thursday, February 21, 2008

Spring cleaning in MySQL supported platforms

The MySQL Lifecycle Policy determines which versions are actively supported, and for which platforms such support applies.
The basic principle is that old versions are supported for a quite long, but definitely limited period, once they have been replaced by a newer GA version. For example, since the introduction of this policy, MySQL 3.23 and 4.0 have been retired.
The policy contains also provisions for a different kind of End of Life dismissal. When support for certain platforms has been discontinued by their vendors, of the platform is not widely used, MySQL reserves the right to stop building binaries and testing code on such obsolete platforms.
The reason is simple. While hardware can be bought and stored, time is a commodity in short supply, and there is only a given amount of time that our engineers can devote to testing and supporting multiple platforms.
Therefore, it makes sense to discontinue those platforms that have few users, and dedicate some valuable time to new, emerging platforms that are more popular and widely used.
bones

For the above reasons, at the end of 2008, MySQL will discontinue some old platforms:
  • MAC OSX 10.3
  • HP-UX 11.00
  • SCO OpenServer (all versions)
  • QNX (all versions)
MySQL will continue to offer support to specific customers in these platforms, but the public builds will be abandoned as of December 31, 2008.

The above decision is based on some vendor end-of-life support, and on our surveys on platform usage.
The intention is to provide a better service to users and customers, by allowing our engineers to spend time on the more widely used systems.

Tuesday, February 19, 2008

Users Conference 2008 - latest schedule changes


If you plan to attend the MySQL Users Conference, hurry up! The early bird registration ends on February 26. It's your chance to save a few hundred dollars.
If you need some more reasons for attending, notice these late additions to the schedule:

The Falcon sessions were added just today, and my session is a replacement of "MySQL Proxy Wizardry" (but don't worry: some of its contents will be included in the MySQL Proxy Tutorial.
Did I mention that you should hurry up to save some bucks? Register now!

BTW, as a speaker, I can give a 20% discount to my friends. If you want to get one, please drop me a line by email at my_first_name AT mysql dot com.

Monday, February 18, 2008

On good coffee and acquisitions

When traveling to my parents town with my wife, we used to stop by a coffee shop on the highway, where a charming couple made good coffee with a smile. They were efficient and friendly. As soon as we were stepping out of the car, they were already preparing for our usual order (espresso and cappuccino), and they had always a joke or a funny comment for us.

Once we saw them dealing with two busloads of tourists, serving whatever they asked rapidly and cheerfully. This shop was a popular stop, always crowded.
It ended a few weeks ago. Someone decided that the location was profitable, and now the small shop has been replaced by a huge coffee+restaurant+amenities resort.
We stopped there, out of habit, shortly before my world trip. The crowd was thinner than usual. The charming couple was gone, replaced by a 4 people team, who sent us to queue at the cashier's before ordering. The coffee was awful, and the barista's attitude less than friendly. We were not impressed.
We went there again yesterday, just to give them another chance. The 4 people team has grown to 5, but the attitude and skillset have not improved. There were very few people, less than we had ever seen in that location. If you ask me, that resort is doomed. If there was any good business, it was because of the people running it, not because of a magical road junction that compelled travelers to stop there.
The lesson to learn here is simple: taking over a successful business without due thought to the people factor is risky, bordering on disastrous.
Sun seems to have this concept in mind. After the MySQL acquisition, they want to keep MySQL people in the right places. I am confident in the future, but a friendly reminder should not do any harm. :)

Thursday, February 14, 2008

Chasing elusive bugs

Since the announcement of Maria, I have been trying to use the same crashing test with Falcon, to establish conclusively if its crash recovery features are as reliable as I hope.

I tried the same test used for Maria, and after a crash, Falcon did not recover nicely. In fact, the server crashed on restart. I have not been able to repeat that behavior on Linux. Actually, I did, on a remote server that is not available to me at the moment, using an earlier revision, and I am waiting until I am back home to do some more testing with the latest tree.
However, I managed to repeat the problem with Mac OS X.
I run this script on a 6.0.5 server:

set storage_engine=falcon;
drop table if exists t1;
create table t1 (id int, b longblob) ;
insert into t1 values (1, repeat('a',1000000));
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;

When the script reaches the last line (has loaded 128 records and it's inserting the next batch), I stop the server with a vicious kill -9.
Upon restarting, the system looks under control, and I run the command that was previously interrupted:

insert into t1 select * from t1;

Here, the server crashes. I have repeated the above steps several times, and it crashes consistently on Mac OS X. On Linux, which I have on a virtual machine only (I am still on the road!) I can't repeat the crash with the current revision.
So, this is a bug, no questions about that, but not a serious one, unless I manage to prove otherwise.
Perhaps this bug is related to Bug#33517. We'll see.
If anyone has noted something similar, please let me know.

Freedom to work anywhere, really!

Singapore. Last stop of my world tour. Shortly after my arrival, the new Lunar Year began. The year of the rat was happily celebrated, and its symbols can be seen everywhere in town.


In Singapore, the Freedom To Work Anywhere @ MySQL has a new meaning. Most of the town is connected via a free wireless net. While sitting on a public bench (in cool evenings) or while enjoying food and drinks at hawker centers and cafes, you can just fire up your laptop, connect to the free wireless, and start browsing. You will need to get a (free) username and password through your mobile, but you can live with it easily.
I am on vacation, so I am not "working from anywhere", but the ubiquity of the wireless connection was hard to resist!
By the way, in case you were wondering if the Sun acquisition has changed anything substantial regarding new jobs, it hasn't. MySQL is hiring! Yes. Still. And with a plan of hiring more. So, if you were thinking of sending your CV, you can do it!

Friday, February 08, 2008

From open source to open country

During the last day of the Linux Conference Australia, I and Colin had the choice between joining the crowd for the open day, or meeting a semi-private invitation from Greg Lehey a well known icon in the open source world. He organized a hackers barbecue in his very isolated place, and we could not resist. In his original invitation, Greg said that he lives "down the road", without specifying how long the road is. It turned out that it's a 90 minutes drive, which is an indication of the relative sense of distance that you get in Australia.

In the Australian bush, Greg leads a quiet life with his wife, his horses and dogs, and a few not so distant friends, dealing occasionally with stray kangaroos invading his fields, and brewing open source beer.
The barbecue met everybody's expectations, and so did Greg's famous home brewed beer, thus stimulating that sort of hacker talk that only good food and good company can generate. The subjects ranged from the origin of the hacker's word to the openness of languages, touching virtualization, databases, operating systems, embedded libraries, and user interfaces in the process.

After lunch, we were given a demonstration of the damages kangaroos can do, along with a visual recognition of their dumpings. The peek of the visit, however, came with the open source brewery, which is controlled by a FreeBSD box, in action since 2001.

On our way back, we stopped at a wildlife center, where we had close encounters with kangaroos and koalas, before reaching back to the civilized Melbourne, where Colin gave me a crash course on "how to have fun on weekends," but I won't disclose any of its contents. Suffice it to say that Colin approaches this matter with rare professionalism, and if you need advice, you must contact him directly.