<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Xaprb</title>
	<atom:link href="http://www.xaprb.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xaprb.com/blog</link>
	<description>Stay curious!</description>
	<lastBuildDate>Sun, 06 May 2012 15:46:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How Percona Toolkit divides tables into chunks</title>
		<link>http://www.xaprb.com/blog/2012/05/06/how-percona-toolkit-divides-tables-into-chunks/</link>
		<comments>http://www.xaprb.com/blog/2012/05/06/how-percona-toolkit-divides-tables-into-chunks/#comments</comments>
		<pubDate>Sun, 06 May 2012 15:46:26 +0000</pubDate>
		<dc:creator>Xaprb</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=2339</guid>
		<description><![CDATA[The tools we&#8217;ve redesigned in Percona Toolkit recently have moved away from a legacy technique for operating on small numbers of rows at a time, towards a more reliable and predictable method. We call the old version &#8220;chunking&#8221; and the new version &#8220;nibbling.&#8221; Many other MySQL tools I&#8217;ve seen either operate on entire tables, or [...]


<strong>Further Reading:</strong><ul><li><a href='http://www.xaprb.com/blog/2012/04/17/percona-toolkit-gripes-welcome/' rel='bookmark' title='Permanent Link: Percona Toolkit gripes welcome'>Percona Toolkit gripes welcome</a></li>
<li><a href='http://www.xaprb.com/blog/2007/07/05/mysql-toolkit-distribution-620-released/' rel='bookmark' title='Permanent Link: MySQL Toolkit distribution 620 released'>MySQL Toolkit distribution 620 released</a></li>
<li><a href='http://www.xaprb.com/blog/2006/05/10/when-to-avoid-and-when-to-use-surrogate-keys-in-innodb-tables/' rel='bookmark' title='Permanent Link: When to use surrogate keys in InnoDB tables'>When to use surrogate keys in InnoDB tables</a></li>
<li><a href='http://www.xaprb.com/blog/2005/09/26/sql-subqueries-and-derived-tables/' rel='bookmark' title='Permanent Link: The difference between subqueries and derived tables in SQL'>The difference between subqueries and derived tables in SQL</a></li>
<li><a href='http://www.xaprb.com/blog/2007/10/03/mysql-toolkit-version-989-released/' rel='bookmark' title='Permanent Link: MySQL Toolkit version 989 released'>MySQL Toolkit version 989 released</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>The tools we&#8217;ve redesigned in Percona Toolkit recently have moved away from a legacy technique for operating on small numbers of rows at a time, towards a more reliable and predictable method. We call the old version &#8220;chunking&#8221; and the new version &#8220;nibbling.&#8221; Many other MySQL tools I&#8217;ve seen either operate on entire tables, or use the &#8220;chunking&#8221; technique and are exposed to the problems it creates. I&#8217;ll compare the two briefly to explain the differences.</p>

<p>Chunking attempts to divide a table into ranges of rows of a desired size, such as 1000 rows. It does this by examining the minimum and maximum value of the primary key (or other suitable index), estimating the number of rows in the table, and dividing one by the other to create a list of boundary values. Suppose that the minimum value is 1 and the maximum is 1000000, and there are an estimated 100000 rows in the table. The chunk boundaries will fall on intervals of 10000. We can operate on 1-10000, 10001-20000, and so on.</p>

<p>This has a number of problems that might not be obvious at first. It practically requires a numeric, single-column index[1]. It can (and does, in practice) create oversized chunks when values are sparse in some places and packed tightly in others.  It leads to a lot of code complexity and bugs when the table&#8217;s data changes (especially if new rows are inserted) as the tool works. It has edge cases related to special values such as 0, NULL, the date &#8217;0000-00-00&#8242;, the beginning of the table, and the end of the table. In short, through years of experience we found that it simply doesn&#8217;t work well enough. It works in 95% of cases, but not all that well, and in a small fraction of cases it causes serious problems, such as a massively oversized chunk that interferes with other processes on the server. If you&#8217;d like more details on these types of problems, there is a lot of information in old bug reports.</p>

<p>The new &#8220;nibbling&#8221; technique we are using is actually not new at all. It is something I learned before I was even involved in MySQL very much. The context is in some old blog posts I wrote about <a href="http://www.xaprb.com/blog/2007/06/15/archive-strategies-for-oltp-servers-part-3/" title="Archive strategies for OLTP servers, Part 3">archiving and purging</a>. The idea is to fetch a row and use that as the lower bound of the first chunk (or &#8220;nibble&#8221; &#8212; we use the terms pretty interchangeably) of rows. Then use a SELECT with a LIMIT to find the upper boundary of the nibble, as well as the lower bound of the next nibble. After processing the nibble, repeat the steps with the lower bound of the next nibble. The disadvantage of this process is that there is quite a bit of code complexity when you get multi-column indexes, with NULL-able columns adding a whole new twist to the game. However, this is long since solved, and we have a reliable and well-tested library of routines for dealing with this. In return we get predictable behavior on practically any table with an index, even if it isn&#8217;t a unique index. The only remaining edge case is when a non-unique index contains a range of identical values that is larger than the desired chunk size, but that is easily detected and handled in application-specific ways.</p>

<p>The result of the work we&#8217;ve been doing recently, replacing &#8220;chunking&#8221; with &#8220;nibbling&#8221; in pt-table-checksum and pt-online-schema-change, is reliable and safe nibbling behavior. This has the further benefit of allowing us to do much more sophisticated techniques, such as dynamically varying the size of each chunk of rows in response to changing conditions such as server load or varying row size and complexity. Our recent tools are designed to target a predictable query time for each nibble, rather than a specific number of rows.  I am happy to report that, in extensive real-world usage, they are able to stay extremely close to the target time even as conditions vary dramatically.</p>

<p>[1] Although in theory you can operate on the first column in a multi-column index, real-world experience shows that the first column in such indexes tends to have low cardinality, thus creating enormous chunks. And although it is possible to treat date, timestamp, and some other types as numeric, in practice it is very difficult. What number corresponds to 0000-00-00? Our attempts to create algorithms that would work on non-numeric types such as character-based columns were tremendously difficult and the results were discouraging; again, in the real world it doesn&#8217;t work well.</p>

<p><strong>Further Reading:</strong><ul><li><a href='http://www.xaprb.com/blog/2012/04/17/percona-toolkit-gripes-welcome/' rel='bookmark' title='Permanent Link: Percona Toolkit gripes welcome'>Percona Toolkit gripes welcome</a></li>
<li><a href='http://www.xaprb.com/blog/2007/07/05/mysql-toolkit-distribution-620-released/' rel='bookmark' title='Permanent Link: MySQL Toolkit distribution 620 released'>MySQL Toolkit distribution 620 released</a></li>
<li><a href='http://www.xaprb.com/blog/2006/05/10/when-to-avoid-and-when-to-use-surrogate-keys-in-innodb-tables/' rel='bookmark' title='Permanent Link: When to use surrogate keys in InnoDB tables'>When to use surrogate keys in InnoDB tables</a></li>
<li><a href='http://www.xaprb.com/blog/2005/09/26/sql-subqueries-and-derived-tables/' rel='bookmark' title='Permanent Link: The difference between subqueries and derived tables in SQL'>The difference between subqueries and derived tables in SQL</a></li>
<li><a href='http://www.xaprb.com/blog/2007/10/03/mysql-toolkit-version-989-released/' rel='bookmark' title='Permanent Link: MySQL Toolkit version 989 released'>MySQL Toolkit version 989 released</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://www.xaprb.com/blog/2012/05/06/how-percona-toolkit-divides-tables-into-chunks/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>The first guest post on Xaprb blog</title>
		<link>http://www.xaprb.com/blog/2012/05/03/the-first-guest-post-on-xaprb-blog/</link>
		<comments>http://www.xaprb.com/blog/2012/05/03/the-first-guest-post-on-xaprb-blog/#comments</comments>
		<pubDate>Thu, 03 May 2012 15:14:46 +0000</pubDate>
		<dc:creator>Xaprb</dc:creator>
				<category><![CDATA[About]]></category>
		<category><![CDATA[Commentary]]></category>

		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=2737</guid>
		<description><![CDATA[I got a really intriguing email today. As you might imagine, I get a lot of email offering to advertise, or trade links, or guest post, etc etc. But this is the most compelling one I&#8217;ve ever gotten: I came across your blog http://www.xaprb.com/blog/2009/03/13/50-things-to-know-before-migrating-oracle-to-mysql/ a few weeks ago as while conducting research for a website [...]


<strong>Further Reading:</strong><ul><li><a href='http://www.xaprb.com/blog/2012/04/19/a-post-conference-tradition/' rel='bookmark' title='Permanent Link: A post-conference tradition'>A post-conference tradition</a></li>
<li><a href='http://www.xaprb.com/blog/2009/07/11/one-of-the-best-blog-headlines-i-have-ever-read/' rel='bookmark' title='Permanent Link: One of the best blog headlines I have ever read'>One of the best blog headlines I have ever read</a></li>
<li><a href='http://www.xaprb.com/blog/2005/12/01/about-xaprb/' rel='bookmark' title='Permanent Link: Why you need to read this blog'>Why you need to read this blog</a></li>
<li><a href='http://www.xaprb.com/blog/2006/02/08/ie-blog-is-a-great-experience/' rel='bookmark' title='Permanent Link: IE blog is a great experience'>IE blog is a great experience</a></li>
<li><a href='http://www.xaprb.com/blog/2008/10/11/three-steps-to-stopping-blog-comment-spam/' rel='bookmark' title='Permanent Link: Three steps to stopping blog comment spam'>Three steps to stopping blog comment spam</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>I got a really intriguing email today. As you might imagine, I get a lot of email offering to advertise, or trade links, or guest post, etc etc. But this is the most compelling one I&#8217;ve ever gotten:</p>

<blockquote><p>I came across your blog http://www.xaprb.com/blog/2009/03/13/50-things-to-know-before-migrating-oracle-to-mysql/ a few weeks ago as while conducting research for a website that I contribute to. The website aims to look at the progressive areas of early childhood psychology. The idea was originally to create an objective collection of resources for people interested in psychology but it has since grown into something much wider (the resources come together at [redacted]). Today, the project looks at important factors in childhood development that pay dividends in the future.</p>

<p>I think a guest blog post that illuminates the the advancement of our understanding of childhood development would be interesting for your audience. If you&#8217;re interested, I would love to write something for you and perhaps start a friendly dialogue. What do you think?</p>

<p>Thanks, and I look forward to hearing from you.</p>

<p>All my best,</p>

<p>Sarah Thompson (sarahjthompson5@gmail.com)</p>
</blockquote>

<p>The thing is, I know someone who&#8217;s been on the Oprah show and written many, many bestselling books on child psychology, so this perked up my ears right away. The more I thought about it, the more I realized that this is an incredible value to my readers. Everyone interested in migrating between database servers ought to know about childhood psychology. I plan to say yes and to start an entire series of blog posts on this and other highly relevant topics, such as the mating behavior of slugs, the history of central Asia, air pressure in a vacuum, and how many disciples Jesus really had. Look forward to the first installment shortly.</p>

<p><strong>Further Reading:</strong><ul><li><a href='http://www.xaprb.com/blog/2012/04/19/a-post-conference-tradition/' rel='bookmark' title='Permanent Link: A post-conference tradition'>A post-conference tradition</a></li>
<li><a href='http://www.xaprb.com/blog/2009/07/11/one-of-the-best-blog-headlines-i-have-ever-read/' rel='bookmark' title='Permanent Link: One of the best blog headlines I have ever read'>One of the best blog headlines I have ever read</a></li>
<li><a href='http://www.xaprb.com/blog/2005/12/01/about-xaprb/' rel='bookmark' title='Permanent Link: Why you need to read this blog'>Why you need to read this blog</a></li>
<li><a href='http://www.xaprb.com/blog/2006/02/08/ie-blog-is-a-great-experience/' rel='bookmark' title='Permanent Link: IE blog is a great experience'>IE blog is a great experience</a></li>
<li><a href='http://www.xaprb.com/blog/2008/10/11/three-steps-to-stopping-blog-comment-spam/' rel='bookmark' title='Permanent Link: Three steps to stopping blog comment spam'>Three steps to stopping blog comment spam</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://www.xaprb.com/blog/2012/05/03/the-first-guest-post-on-xaprb-blog/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Free webinar: non-blocking MySQL schema changes</title>
		<link>http://www.xaprb.com/blog/2012/05/01/free-webinar-non-blocking-mysql-schema-changes/</link>
		<comments>http://www.xaprb.com/blog/2012/05/01/free-webinar-non-blocking-mysql-schema-changes/#comments</comments>
		<pubDate>Wed, 02 May 2012 00:46:46 +0000</pubDate>
		<dc:creator>Xaprb</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=2485</guid>
		<description><![CDATA[Please join me tomorrow (Wednesday) for a webinar about the new version of pt-online-schema-change, Percona Toolkit&#8217;s tool for performing nonblocking ALTER TABLE operations. Registration is free. I will explain how the tool works and cover some typical use scenarios. This might be helpful if you&#8217;re trying to decide whether the tool is right for you. [...]


<strong>Further Reading:</strong><ul><li><a href='http://www.xaprb.com/blog/2010/08/23/free-webinar-on-mysql-performance-this-thursday/' rel='bookmark' title='Permanent Link: Free webinar on MySQL performance this Thursday'>Free webinar on MySQL performance this Thursday</a></li>
<li><a href='http://www.xaprb.com/blog/2011/10/13/free-webinar-on-preventing-mysql-downtime/' rel='bookmark' title='Permanent Link: Free webinar on preventing MySQL downtime'>Free webinar on preventing MySQL downtime</a></li>
<li><a href='http://www.xaprb.com/blog/2012/03/19/free-webinar-on-monitoring-mysql/' rel='bookmark' title='Permanent Link: Free webinar on monitoring MySQL'>Free webinar on monitoring MySQL</a></li>
<li><a href='http://www.xaprb.com/blog/2012/01/16/free-webinar-wednesday-verifying-replication-integrity/' rel='bookmark' title='Permanent Link: Free webinar Wednesday: verifying replication integrity'>Free webinar Wednesday: verifying replication integrity</a></li>
<li><a href='http://www.xaprb.com/blog/2007/10/14/high-performance-mysql-second-edition-schema-optimization-and-indexing/' rel='bookmark' title='Permanent Link: High Performance MySQL, Second Edition: Schema Optimization and Indexing'>High Performance MySQL, Second Edition: Schema Optimization and Indexing</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>Please join me tomorrow (Wednesday) for a webinar about the new version of <a href="http://www.percona.com/doc/percona-toolkit/2.1/pt-online-schema-change.html">pt-online-schema-change</a>, Percona Toolkit&#8217;s tool for performing nonblocking ALTER TABLE operations. <a href="http://www.percona.com/webinars/2012-05-02-zero-downtime-schema-changes-in-mysql/">Registration</a> is free. I will explain how the tool works and cover some typical use scenarios. This might be helpful if you&#8217;re trying to decide whether the tool is right for you. I am also planning to leave plenty of time for questions!</p>

<p><strong>Further Reading:</strong><ul><li><a href='http://www.xaprb.com/blog/2010/08/23/free-webinar-on-mysql-performance-this-thursday/' rel='bookmark' title='Permanent Link: Free webinar on MySQL performance this Thursday'>Free webinar on MySQL performance this Thursday</a></li>
<li><a href='http://www.xaprb.com/blog/2011/10/13/free-webinar-on-preventing-mysql-downtime/' rel='bookmark' title='Permanent Link: Free webinar on preventing MySQL downtime'>Free webinar on preventing MySQL downtime</a></li>
<li><a href='http://www.xaprb.com/blog/2012/03/19/free-webinar-on-monitoring-mysql/' rel='bookmark' title='Permanent Link: Free webinar on monitoring MySQL'>Free webinar on monitoring MySQL</a></li>
<li><a href='http://www.xaprb.com/blog/2012/01/16/free-webinar-wednesday-verifying-replication-integrity/' rel='bookmark' title='Permanent Link: Free webinar Wednesday: verifying replication integrity'>Free webinar Wednesday: verifying replication integrity</a></li>
<li><a href='http://www.xaprb.com/blog/2007/10/14/high-performance-mysql-second-edition-schema-optimization-and-indexing/' rel='bookmark' title='Permanent Link: High Performance MySQL, Second Edition: Schema Optimization and Indexing'>High Performance MySQL, Second Edition: Schema Optimization and Indexing</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://www.xaprb.com/blog/2012/05/01/free-webinar-non-blocking-mysql-schema-changes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interest building in Percona XtraDB Cluster</title>
		<link>http://www.xaprb.com/blog/2012/04/26/interest-building-in-percona-xtradb-cluster/</link>
		<comments>http://www.xaprb.com/blog/2012/04/26/interest-building-in-percona-xtradb-cluster/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 19:51:09 +0000</pubDate>
		<dc:creator>Xaprb</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=2507</guid>
		<description><![CDATA[In the last few weeks I&#8217;ve been caught off guard by the number of people who&#8217;ve told me they have been evaluating Percona XtraDB Cluster (link), and even more surprised at the projects they&#8217;re considering it for. Yesterday alone I spoke to several people who have been evaluating it for large, mission-critical enterprise deployments. Some [...]


<strong>Further Reading:</strong><ul><li><a href='http://www.xaprb.com/blog/2011/02/08/building-a-mysql-server-with-xtradb-for-speed/' rel='bookmark' title='Permanent Link: Building a MySQL server with XtraDB for speed'>Building a MySQL server with XtraDB for speed</a></li>
<li><a href='http://www.xaprb.com/blog/2009/04/17/sessions-of-interest-at-the-percona-performance-conference/' rel='bookmark' title='Permanent Link: Sessions of interest at the Percona Performance Conference'>Sessions of interest at the Percona Performance Conference</a></li>
<li><a href='http://www.xaprb.com/blog/2010/04/21/whats-different-about-xtradb/' rel='bookmark' title='Permanent Link: What&#8217;s different about XtraDB?'>What&#8217;s different about XtraDB?</a></li>
<li><a href='http://www.xaprb.com/blog/2009/06/08/xtrabackup-is-for-innodb-tables-too-not-just-xtradb/' rel='bookmark' title='Permanent Link: Xtrabackup is for InnoDB tables too, not just XtraDB'>Xtrabackup is for InnoDB tables too, not just XtraDB</a></li>
<li><a href='http://www.xaprb.com/blog/2008/07/20/book-review-building-powerful-and-robust-websites-with-drupal-6/' rel='bookmark' title='Permanent Link: Book Review: Building powerful and robust websites with Drupal 6'>Book Review: Building powerful and robust websites with Drupal 6</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>In the last few weeks I&#8217;ve been caught off guard by the number of people who&#8217;ve told me they have been evaluating Percona XtraDB Cluster (<a href="http://www.percona.com/software/percona-xtradb-cluster/">link</a>), and even more surprised at the projects they&#8217;re considering it for. Yesterday alone I spoke to several people who have been evaluating it for large, mission-critical enterprise deployments. Some new, some to replace existing systems that use standard MySQL replication. What was interesting is that some people said they&#8217;ve been putting it through its paces for months &#8212; before we even released it as GA.</p>

<p>Another person said he was evaluating it and tried a bunch of things like killing nodes, and it &#8220;just worked.&#8221; He sounded like he&#8217;d been suspicious: had it REALLY worked? But then, on further investigation, he was able to confirm that yes, it had just worked. The node went away; the cluster as a whole was healthy and happy.</p>

<p>It&#8217;s funny how you can get a feeling about the momentum on a product or idea or event. It probably builds upon the little things, like tone of voice or expressions on peoples&#8217; faces. In any case I have this gut feeling about Percona XtraDB Cluster: it&#8217;s about to happen.</p>

<p><strong>Further Reading:</strong><ul><li><a href='http://www.xaprb.com/blog/2011/02/08/building-a-mysql-server-with-xtradb-for-speed/' rel='bookmark' title='Permanent Link: Building a MySQL server with XtraDB for speed'>Building a MySQL server with XtraDB for speed</a></li>
<li><a href='http://www.xaprb.com/blog/2009/04/17/sessions-of-interest-at-the-percona-performance-conference/' rel='bookmark' title='Permanent Link: Sessions of interest at the Percona Performance Conference'>Sessions of interest at the Percona Performance Conference</a></li>
<li><a href='http://www.xaprb.com/blog/2010/04/21/whats-different-about-xtradb/' rel='bookmark' title='Permanent Link: What&#8217;s different about XtraDB?'>What&#8217;s different about XtraDB?</a></li>
<li><a href='http://www.xaprb.com/blog/2009/06/08/xtrabackup-is-for-innodb-tables-too-not-just-xtradb/' rel='bookmark' title='Permanent Link: Xtrabackup is for InnoDB tables too, not just XtraDB'>Xtrabackup is for InnoDB tables too, not just XtraDB</a></li>
<li><a href='http://www.xaprb.com/blog/2008/07/20/book-review-building-powerful-and-robust-websites-with-drupal-6/' rel='bookmark' title='Permanent Link: Book Review: Building powerful and robust websites with Drupal 6'>Book Review: Building powerful and robust websites with Drupal 6</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://www.xaprb.com/blog/2012/04/26/interest-building-in-percona-xtradb-cluster/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The MySQL init-script mess</title>
		<link>http://www.xaprb.com/blog/2012/04/24/the-mysql-init-script-mess/</link>
		<comments>http://www.xaprb.com/blog/2012/04/24/the-mysql-init-script-mess/#comments</comments>
		<pubDate>Wed, 25 Apr 2012 01:25:26 +0000</pubDate>
		<dc:creator>Xaprb</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=2729</guid>
		<description><![CDATA[I don&#8217;t think there is a single good-quality MySQL init script for a Unix-like operating system. On Windows, there is the service facility, and I used to write Windows services. Based on that, I believe Windows has a pretty good claim to better reliability for start/stop services with MySQL. What&#8217;s wrong with the init scripts? [...]


<strong>Further Reading:</strong><ul><li><a href='http://www.xaprb.com/blog/2006/03/12/gnucash-to-mysql-export-script/' rel='bookmark' title='Permanent Link: GnuCash to MySQL export script'>GnuCash to MySQL export script</a></li>
<li><a href='http://www.xaprb.com/blog/2009/06/05/a-tweak-to-column-alignment-for-the-mext-script/' rel='bookmark' title='Permanent Link: A tweak to column alignment for the mext script'>A tweak to column alignment for the mext script</a></li>
<li><a href='http://www.xaprb.com/blog/2009/08/30/a-script-snippet-for-aggregating-gdb-backtraces/' rel='bookmark' title='Permanent Link: A script snippet for aggregating GDB backtraces'>A script snippet for aggregating GDB backtraces</a></li>
<li><a href='http://www.xaprb.com/blog/2009/09/01/a-script-snippet-to-relative-ize-numbers-embedded-in-text/' rel='bookmark' title='Permanent Link: A script snippet to relative-ize numbers embedded in text'>A script snippet to relative-ize numbers embedded in text</a></li>
<li><a href='http://www.xaprb.com/blog/2007/03/08/what-to-do-when-mysql-says-skip-innodb-is-defined/' rel='bookmark' title='Permanent Link: What to do when MySQL says skip-innodb is defined'>What to do when MySQL says skip-innodb is defined</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t think there is a single good-quality MySQL init script for a Unix-like operating system. On Windows, there is the service facility, and I used to write Windows services. Based on that, I believe Windows has a pretty good claim to better reliability for start/stop services with MySQL.</p>

<p>What&#8217;s wrong with the init scripts? Well, let me count the reasons! Wait, I&#8217;m out of fingers and toes.</p>

<p>I&#8217;ll just mention the two annoying ones that I&#8217;ve run into most recently. Both are on Debian, though there is nothing especially broken about Debian&#8217;s init scripts.  The first one comes from parsing my.cnf wrong and not treating pid-file and pid_file identically. The server treats them identically, thus, so should any other program that reads the my.cnf file (there&#8217;s this program called my_print_defaults&#8230; use it!).  The second bug is because Debian uses two configuration files for start/stop services: the init script reads /etc/mysql/debian.cnf for no discernable reason. (I guess they never heard of using [sections] in the /etc/mysql/my.cnf file, or just reading the [mysqld] section.)  So if you configure your server to place its socket in a non-default location, you have to redundantly update /etc/mysql/debian.cnf too, or the init script will fail.  Duplication of configuration parameters is just stupid, period.</p>

<p>These are fairly mundane bugs. I&#8217;ve seen literally dozens more. Part of the problem is that each distribution that packages up and redistributes MySQL tends to ship with their own init script, instead of reusing the official scripts provided by MySQL. Understandable, because mysqld_safe is generic and doesn&#8217;t really integrate well with any system&#8217;s init facilities. But man, do they reinvent a bunch of lovely bugs, mostly related to things like parsing the .cnf files, handling pid files, handling sockets, special user accounts, braindead look-before-you-leap patterns of pinging before actually doing a task, stupid timeouts, wrong handling of log files and log file rotation, dumb hacks with syslog, failing to check for real evidence of a running process (you can&#8217;t trust what a cache file on disk says!), adding facepalm-worthy CHECK TABLES automatically on every table on server startup,  and on and on.</p>

<p>The official mysqld_safe script tends to be a little less broken, in my experience, but still has many unlovely behaviors and missing features that I&#8217;d consider to be bugs.</p>

<p>I haven&#8217;t even mentioned the &#8220;manage multiple instances&#8221; scripts yet. Boy, do those have a ton of bugs. They do stupid things like grepping configuration files for strings that may or may not be in the configuration files. I remember one emergency case where MySQL couldn&#8217;t be started on a box because the string &#8220;mysql_multi&#8221; didn&#8217;t exist in a my.cnf file clearly designed for multiple instances to run. I added a comment to the effect of &#8220;# This comment is necessary for mysql_multi to work&#8221; and the problem was solved. A sane script would actually check for multiple instance definitions, not for some arbitrary string of characters. Anyway, this is just one tiny example, I don&#8217;t mean to dwell on it.</p>

<p>What happens when you have a bad init script? <a href="http://www.percona.com/files/white-papers/causes-of-downtime-in-mysql.pdf">All kinds of things</a>. You can&#8217;t shut down the server gracefully, so if you shut down the system, you hard-crash MySQL eventually, and good luck getting replication back after that in most cases. You can&#8217;t start the server correctly, or it reports the wrong thing and then tries to start several instances, and the second one borks the first one&#8217;s pid file and/or socket, causing the aforementioned shutdown problem or worse. And on it goes.</p>

<p>My principle is usually &#8220;don&#8217;t complain, do something about it.&#8221; But there&#8217;s a problem, in this case: writing a good init script is actually a significantly complex software engineering project. It is NOT &#8220;just a script.&#8221; (Insert my usual rant about the need for an actual test suite.) And that is not something I am working on at the moment, nor has it ever become my priority for the last several years.  So in this case I&#8217;m complaining, because the writing on the wall says that I am probably never going to work on this, and I&#8217;d at least like there to be some visibility about what a serious problem this is.</p>

<p>Distribution maintainers could probably improve the situation significantly by taking a look at each other&#8217;s bug reports. If everyone solved the same bugs everyone else has solved (and don&#8217;t forget bugs in mysqld_safe, too) that would be a big step forward.</p>

<p><strong>Further Reading:</strong><ul><li><a href='http://www.xaprb.com/blog/2006/03/12/gnucash-to-mysql-export-script/' rel='bookmark' title='Permanent Link: GnuCash to MySQL export script'>GnuCash to MySQL export script</a></li>
<li><a href='http://www.xaprb.com/blog/2009/06/05/a-tweak-to-column-alignment-for-the-mext-script/' rel='bookmark' title='Permanent Link: A tweak to column alignment for the mext script'>A tweak to column alignment for the mext script</a></li>
<li><a href='http://www.xaprb.com/blog/2009/08/30/a-script-snippet-for-aggregating-gdb-backtraces/' rel='bookmark' title='Permanent Link: A script snippet for aggregating GDB backtraces'>A script snippet for aggregating GDB backtraces</a></li>
<li><a href='http://www.xaprb.com/blog/2009/09/01/a-script-snippet-to-relative-ize-numbers-embedded-in-text/' rel='bookmark' title='Permanent Link: A script snippet to relative-ize numbers embedded in text'>A script snippet to relative-ize numbers embedded in text</a></li>
<li><a href='http://www.xaprb.com/blog/2007/03/08/what-to-do-when-mysql-says-skip-innodb-is-defined/' rel='bookmark' title='Permanent Link: What to do when MySQL says skip-innodb is defined'>What to do when MySQL says skip-innodb is defined</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://www.xaprb.com/blog/2012/04/24/the-mysql-init-script-mess/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>

