Barriers & ext4 & MySQL

We are going to release openSUSE 11.2 soon, so I want to let you know about one problem you may expect. One of the openSUSE 11.2 features is support for ext4. Well, if you will just click on next all the time during the installation, default filesystem for your root partition will be ext4. What is the problem with that? Well, ext4 in current kernel has barriers enabled by default. It’s not a problem, it’s a feature, but it has some unpleasant side effects which you may encounter. Let’s take a closer look.

Barriers

Barriers are used to make sure that journal is really written to your filesystem and that nothing is missing. It has one big advantage – your data are safe. On the other hand it has disadvantage as well. You have to make sure that everything is written so you can’t really take full advantage of all caches and such. There is a nice article on LWN.net about barriers.

Consequences

Well and why I mention it? Barriers has some impact on performance. Sometimes this impact can be quite notable as mentioned in bug #549534. This bug was about importing some sample 1.6M SQL dump into MySQL. One friend reported this to me on IRC. On ext4 with barriers enabled this import takes 527 seconds. But after disabling barriers on the same machine same SQL dump can be imported in 21 seconds. So if you plan using MySQL for some large and heavily used database and you have UPS or something similar you may consider disabling it.

Disabling barriers

So if you want to disable barriers, you ca easily do so by using barrier=0 in mount options. You can do it by adding this option after comma to the fourth column in your /etc/fstab. Or if you want something user friendlier, run ‘yast2 disk‘, select your partition, using right click choose to Edit it and in following dialog use Fstab Options to invoke another dialog. In Fstab Options dialog, enter barrier=0 to the Arbitrary option value field. If you can’t find it, follow the screenshot or run YaST in English by using ‘LANG=C yast2 disk‘.

 

Fstab Options