<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Rare evil MySQL Bug</title>
	<atom:link href="http://www.mysqlperformanceblog.com/2009/11/20/rare-evil-mysql-bug/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mysqlperformanceblog.com/2009/11/20/rare-evil-mysql-bug/</link>
	<description>Percona&#039;s MySQL &#38; InnoDB performance and scalability blog</description>
	<lastBuildDate>Sat, 11 Feb 2012 16:45:54 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Antony</title>
		<link>http://www.mysqlperformanceblog.com/2009/11/20/rare-evil-mysql-bug/comment-page-1/#comment-681491</link>
		<dc:creator>Antony</dc:creator>
		<pubDate>Sat, 21 Nov 2009 16:45:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=1769#comment-681491</guid>
		<description>Or simply rearrange the server code so that the socket handles are created first, before any storage engine is initialized.</description>
		<content:encoded><![CDATA[<p>Or simply rearrange the server code so that the socket handles are created first, before any storage engine is initialized.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: domas</title>
		<link>http://www.mysqlperformanceblog.com/2009/11/20/rare-evil-mysql-bug/comment-page-1/#comment-681488</link>
		<dc:creator>domas</dc:creator>
		<pubDate>Sat, 21 Nov 2009 16:28:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=1769#comment-681488</guid>
		<description>yet more arguments for shared tablespaces, mwaha.</description>
		<content:encoded><![CDATA[<p>yet more arguments for shared tablespaces, mwaha.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2009/11/20/rare-evil-mysql-bug/comment-page-1/#comment-681083</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Sat, 21 Nov 2009 05:23:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=1769#comment-681083</guid>
		<description>Ryan,

Looks like this series of posts of workings with large amount of tables matches your envinronment significantly :)</description>
		<content:encoded><![CDATA[<p>Ryan,</p>
<p>Looks like this series of posts of workings with large amount of tables matches your envinronment significantly <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan H</title>
		<link>http://www.mysqlperformanceblog.com/2009/11/20/rare-evil-mysql-bug/comment-page-1/#comment-681072</link>
		<dc:creator>Ryan H</dc:creator>
		<pubDate>Sat, 21 Nov 2009 04:07:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=1769#comment-681072</guid>
		<description>Thanks for this. We have this problem all the time on our production servers.

-Ryan</description>
		<content:encoded><![CDATA[<p>Thanks for this. We have this problem all the time on our production servers.</p>
<p>-Ryan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brant</title>
		<link>http://www.mysqlperformanceblog.com/2009/11/20/rare-evil-mysql-bug/comment-page-1/#comment-681061</link>
		<dc:creator>Brant</dc:creator>
		<pubDate>Sat, 21 Nov 2009 02:17:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=1769#comment-681061</guid>
		<description>I don&#039;t have anything to add other than Kristian is awesome.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t have anything to add other than Kristian is awesome.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2009/11/20/rare-evil-mysql-bug/comment-page-1/#comment-680747</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Fri, 20 Nov 2009 16:35:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=1769#comment-680747</guid>
		<description>Kristian,

Thanks. Good catch. This matches my guess as well.  select() is way to the trouble especially these days when we deal with a lot of connections, a lot of open files etc.  

I filed a bug on it BTW:
http://bugs.mysql.com/bug.php?id=48929</description>
		<content:encoded><![CDATA[<p>Kristian,</p>
<p>Thanks. Good catch. This matches my guess as well.  select() is way to the trouble especially these days when we deal with a lot of connections, a lot of open files etc.  </p>
<p>I filed a bug on it BTW:<br />
<a href="http://bugs.mysql.com/bug.php?id=48929" rel="nofollow">http://bugs.mysql.com/bug.php?id=48929</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kristian Nielsen</title>
		<link>http://www.mysqlperformanceblog.com/2009/11/20/rare-evil-mysql-bug/comment-page-1/#comment-680467</link>
		<dc:creator>Kristian Nielsen</dc:creator>
		<pubDate>Fri, 20 Nov 2009 08:22:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=1769#comment-680467</guid>
		<description>Ah, I think I see it now.

The select() and accept() calls in the trace are from
handle_connections_sockets() in sql/mysqld.cc. It is supposed to select() on
(at most) 2 file descriptors: the IP server socket and the unix server socket.

Now in this case, one of these somehow ended up with file descriptor number
16393.

From `man 2 select`:

  &quot;An fd_set is a fixed size buffer.  Executing FD_CLR() or FD_SET() with a
  value of fd that is negative or is equal to or larger than FD_SETSIZE will
  result in undefined behavior.  Moreover, POSIX requires fd to be a valid
  file descriptor.&quot;

And FD_SETSIZE seems to be 1024 on Linux!

So basically mysqld is now passing random stack memory to select() for file
descriptors 1024-16393 :-(. This also explains why accept() fails with EAGAIN:
there isn&#039;t any new connection pending, it is just that select() gets lots of
random file descriptors in the undefined memory, and one of them happens to
return ready.

So the code in handle_connections_sockets() is really broken, the only reason
it works at all is probably that the server sockets are usually created early
and hence get low file descriptors. But in this case for some reason at least
one of them got the very high number 16393.

Even if we do not exceed the FD_SETSIZE it can still be inefficient to
search a potentially big fd_set for just two descriptors. The code should be
changed to use poll(). I seem to remember seeing a patch for this, or I might
make on up for MariaDB.</description>
		<content:encoded><![CDATA[<p>Ah, I think I see it now.</p>
<p>The select() and accept() calls in the trace are from<br />
handle_connections_sockets() in sql/mysqld.cc. It is supposed to select() on<br />
(at most) 2 file descriptors: the IP server socket and the unix server socket.</p>
<p>Now in this case, one of these somehow ended up with file descriptor number<br />
16393.</p>
<p>From `man 2 select`:</p>
<p>  &#8220;An fd_set is a fixed size buffer.  Executing FD_CLR() or FD_SET() with a<br />
  value of fd that is negative or is equal to or larger than FD_SETSIZE will<br />
  result in undefined behavior.  Moreover, POSIX requires fd to be a valid<br />
  file descriptor.&#8221;</p>
<p>And FD_SETSIZE seems to be 1024 on Linux!</p>
<p>So basically mysqld is now passing random stack memory to select() for file<br />
descriptors 1024-16393 <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> . This also explains why accept() fails with EAGAIN:<br />
there isn&#8217;t any new connection pending, it is just that select() gets lots of<br />
random file descriptors in the undefined memory, and one of them happens to<br />
return ready.</p>
<p>So the code in handle_connections_sockets() is really broken, the only reason<br />
it works at all is probably that the server sockets are usually created early<br />
and hence get low file descriptors. But in this case for some reason at least<br />
one of them got the very high number 16393.</p>
<p>Even if we do not exceed the FD_SETSIZE it can still be inefficient to<br />
search a potentially big fd_set for just two descriptors. The code should be<br />
changed to use poll(). I seem to remember seeing a patch for this, or I might<br />
make on up for MariaDB.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

