<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: How we enabled threading in MySQL</title>
	<link>http://www.xaprb.com/blog/2006/07/16/how-we-enabled-threading-in-mysql/</link>
	<description>Stay curious!</description>
	<pubDate>Sun, 20 Jul 2008 22:50:15 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>

	<item>
		<title>By: LC</title>
		<link>http://www.xaprb.com/blog/2006/07/16/how-we-enabled-threading-in-mysql/#comment-12886</link>
		<author>LC</author>
		<pubDate>Thu, 02 Aug 2007 22:54:46 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/07/16/how-we-enabled-threading-in-mysql/#comment-12886</guid>
		<description>Hi, I have a problem related to this subject . We use a linux VPS(Virtual Private Server) running CentOS 4.5 and mysqld 5.0.41 . When the VPS is restarted mysqld it's running at boot time with NPTL (threads don’t have pid so they don’t appear in top, 'ps aux' and others, but you can see them using ps -eLf for example. We have only one mysqld process running). In this case, the server is running great, without any problems.
But mysqld is restarted (or I restart the VPS without starting mysqld at boot, start mysqld after the boot sequence was completed) , we'll have lots of mysqld processes, like using linuxthreads implementation (LinuxThreads has a hack to make threads visible as separated processes). In this LinuxThreads 'state', the mysqld server restart will fail(60 sec timeout while trying to do 
 /bin/kill -0 "$MYSQLPID") . Also, the server will crush in the next 2 days.
I'm not sure if it's a virtualization/kernel issue. 

GNU_LIBPTHREAD_VERSION-&#62;linuxthreads-0.10

Thanks</description>
		<content:encoded><![CDATA[<p>Hi, I have a problem related to this subject . We use a linux VPS(Virtual Private Server) running CentOS 4.5 and mysqld 5.0.41 . When the VPS is restarted mysqld it&#8217;s running at boot time with NPTL (threads don’t have pid so they don’t appear in top, &#8216;ps aux&#8217; and others, but you can see them using ps -eLf for example. We have only one mysqld process running). In this case, the server is running great, without any problems.<br />
But mysqld is restarted (or I restart the VPS without starting mysqld at boot, start mysqld after the boot sequence was completed) , we&#8217;ll have lots of mysqld processes, like using linuxthreads implementation (LinuxThreads has a hack to make threads visible as separated processes). In this LinuxThreads &#8217;state&#8217;, the mysqld server restart will fail(60 sec timeout while trying to do<br />
 /bin/kill -0 &#8220;$MYSQLPID&#8221;) . Also, the server will crush in the next 2 days.<br />
I&#8217;m not sure if it&#8217;s a virtualization/kernel issue. </p>
<p>GNU_LIBPTHREAD_VERSION-&gt;linuxthreads-0.10</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xaprb</title>
		<link>http://www.xaprb.com/blog/2006/07/16/how-we-enabled-threading-in-mysql/#comment-3926</link>
		<author>Xaprb</author>
		<pubDate>Tue, 06 Feb 2007 13:11:06 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/07/16/how-we-enabled-threading-in-mysql/#comment-3926</guid>
		<description>&lt;p&gt;Yes, the H key toggles showing NPTL threads in top.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Yes, the H key toggles showing NPTL threads in top.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jan</title>
		<link>http://www.xaprb.com/blog/2006/07/16/how-we-enabled-threading-in-mysql/#comment-3908</link>
		<author>Jan</author>
		<pubDate>Mon, 05 Feb 2007 16:21:06 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/07/16/how-we-enabled-threading-in-mysql/#comment-3908</guid>
		<description>&lt;p&gt;Wow; thanks a bunch. I've been wrecking my brain on this problem for months! I had a hunch it had something to do with different library implementations. But now I understand my ps output is normal on my machine, because my machine use NPTL instead of LinuxThreads.
But from what I understand you rebuild glibc and now your top/ps output _does_ show the threads _with_ NPTL? This doesn't make sense; since you stated one of the things with NPTL is that it doesn't come up in ps/top?&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Wow; thanks a bunch. I&#8217;ve been wrecking my brain on this problem for months! I had a hunch it had something to do with different library implementations. But now I understand my ps output is normal on my machine, because my machine use NPTL instead of LinuxThreads.<br />
But from what I understand you rebuild glibc and now your top/ps output _does_ show the threads _with_ NPTL? This doesn&#8217;t make sense; since you stated one of the things with NPTL is that it doesn&#8217;t come up in ps/top?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Benedetto</title>
		<link>http://www.xaprb.com/blog/2006/07/16/how-we-enabled-threading-in-mysql/#comment-1234</link>
		<author>Benedetto</author>
		<pubDate>Wed, 26 Jul 2006 11:31:23 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/07/16/how-we-enabled-threading-in-mysql/#comment-1234</guid>
		<description>&lt;p&gt;Hi, thank you all, I have few servers and on just one of them I see only one process under TOP, I was scared that  my mysql installation was screwed, instead probably it's just that on this machine I have a different kernel,2.6, and is  showing one process as it should.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Hi, thank you all, I have few servers and on just one of them I see only one process under TOP, I was scared that  my mysql installation was screwed, instead probably it&#8217;s just that on this machine I have a different kernel,2.6, and is  showing one process as it should.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xaprb</title>
		<link>http://www.xaprb.com/blog/2006/07/16/how-we-enabled-threading-in-mysql/#comment-1146</link>
		<author>Xaprb</author>
		<pubDate>Thu, 20 Jul 2006 01:09:16 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/07/16/how-we-enabled-threading-in-mysql/#comment-1146</guid>
		<description>&lt;p&gt;Wow, thanks everyone for writing!  I am learning a ton now that more people are reading and commenting (I am not that experienced myself).  Our CPU utilization certainly went down after we got switched to NPTL, but it must just be that NPTL is more efficient than linuxthreads.&lt;/p&gt;

&lt;p&gt;Sorry for the delay in moderating, I was in Turkey for a week!&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Wow, thanks everyone for writing!  I am learning a ton now that more people are reading and commenting (I am not that experienced myself).  Our CPU utilization certainly went down after we got switched to NPTL, but it must just be that NPTL is more efficient than linuxthreads.</p>
<p>Sorry for the delay in moderating, I was in Turkey for a week!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://www.xaprb.com/blog/2006/07/16/how-we-enabled-threading-in-mysql/#comment-1123</link>
		<author>Peter</author>
		<pubDate>Mon, 17 Jul 2006 07:39:33 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/07/16/how-we-enabled-threading-in-mysql/#comment-1123</guid>
		<description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;MySQL always uses threads.  However if LinuxThreads are used MySQL will show up in top and ps as multiple processes as this is how LinuxThreads are implemented.  It would not be real multiple processes though as address space and other things are shared. &lt;/p&gt;

&lt;p&gt;Good to hear NPTL provided performance improvement in your case.  It should as  it was specially designed to solve number of LinuxThread design issues.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>MySQL always uses threads.  However if LinuxThreads are used MySQL will show up in top and ps as multiple processes as this is how LinuxThreads are implemented.  It would not be real multiple processes though as address space and other things are shared. </p>
<p>Good to hear NPTL provided performance improvement in your case.  It should as  it was specially designed to solve number of LinuxThread design issues.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geert Vanderkelen</title>
		<link>http://www.xaprb.com/blog/2006/07/16/how-we-enabled-threading-in-mysql/#comment-1122</link>
		<author>Geert Vanderkelen</author>
		<pubDate>Mon, 17 Jul 2006 07:22:52 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/07/16/how-we-enabled-threading-in-mysql/#comment-1122</guid>
		<description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;This blog got us puzzeled ....&lt;/p&gt;

&lt;p&gt;MySQL uses LinuxThreads or NPTL (Native POSIX Thread Library), which ever is available on your Linux box. MySQL is always threading, it doesn't fork.&lt;/p&gt;

&lt;p&gt;Fact that you 'see' more threads in a ps output on one machine, might be the fact that it used LinuxThreads, which has a hack to make them visible as seperated processes.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>This blog got us puzzeled &#8230;.</p>
<p>MySQL uses LinuxThreads or NPTL (Native POSIX Thread Library), which ever is available on your Linux box. MySQL is always threading, it doesn&#8217;t fork.</p>
<p>Fact that you &#8217;see&#8217; more threads in a ps output on one machine, might be the fact that it used LinuxThreads, which has a hack to make them visible as seperated processes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander Keremidarski</title>
		<link>http://www.xaprb.com/blog/2006/07/16/how-we-enabled-threading-in-mysql/#comment-1121</link>
		<author>Alexander Keremidarski</author>
		<pubDate>Mon, 17 Jul 2006 07:15:15 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/07/16/how-we-enabled-threading-in-mysql/#comment-1121</guid>
		<description>&lt;p&gt;I am afraid your effort was futile.  You see the only thing you achieved was to switch from LinuxThreads to NPTL.  MySQL always uses threads, but depending on library they look different to top, vmstat and other tools.  When using LinuxThreads each thread has it's own PID and that's why they appear as separate processes.&lt;/p&gt;

&lt;p&gt;If you take closer look at top output for example you will see all mysqld "processes" have exactly the same numbers for memory and CPU. That is because it is same process information repeatedly displayed for each thread.  With certain versions of top it was possible to hide/show threads.&lt;/p&gt;

&lt;p&gt;Some tools like pstree for example always show threads as such:&lt;/p&gt;

&lt;pre&gt;
  ├─mysqld_safe───mysqld───8*[{mysqld}]&lt;/pre&gt;

&lt;p&gt;With NPTL threads don't have PID so they don't appear in top and others.  You can easily verify if I am correct or wrong.  If your Linux supports LD_ASSUME_KERNEL switch between LT and NPTL simply start mysqld once with each library and observe the difference in top.&lt;/p&gt;

&lt;p&gt;Now the real problem.  On Master mysqld can utilize several threads better for very simple reason.  Each client session is handled by separate thread in mysqld. Several sessions can run queries in parallel. However in order to ensure data is replicated consistenly all statements are "serialized" in binary log and repeated in exactly the same order at the Slave.  This is only possible if at Slaev all the replicated statements are executed by single thread.&lt;/p&gt;

&lt;p&gt;So if you have 10 threads on Master running 10 statements parallel these 10 statements will come to Slave in serialized manner and single thread will run them one at a time.&lt;/p&gt;

&lt;p&gt;I hope that helps.&lt;/p&gt;

&lt;p&gt;Best regards&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>I am afraid your effort was futile.  You see the only thing you achieved was to switch from LinuxThreads to NPTL.  MySQL always uses threads, but depending on library they look different to top, vmstat and other tools.  When using LinuxThreads each thread has it&#8217;s own PID and that&#8217;s why they appear as separate processes.</p>
<p>If you take closer look at top output for example you will see all mysqld &#8220;processes&#8221; have exactly the same numbers for memory and CPU. That is because it is same process information repeatedly displayed for each thread.  With certain versions of top it was possible to hide/show threads.</p>
<p>Some tools like pstree for example always show threads as such:</p>
<pre>
  ├─mysqld_safe───mysqld───8*[{mysqld}]</pre>
<p>With NPTL threads don&#8217;t have PID so they don&#8217;t appear in top and others.  You can easily verify if I am correct or wrong.  If your Linux supports LD_ASSUME_KERNEL switch between LT and NPTL simply start mysqld once with each library and observe the difference in top.</p>
<p>Now the real problem.  On Master mysqld can utilize several threads better for very simple reason.  Each client session is handled by separate thread in mysqld. Several sessions can run queries in parallel. However in order to ensure data is replicated consistenly all statements are &#8220;serialized&#8221; in binary log and repeated in exactly the same order at the Slave.  This is only possible if at Slaev all the replicated statements are executed by single thread.</p>
<p>So if you have 10 threads on Master running 10 statements parallel these 10 statements will come to Slave in serialized manner and single thread will run them one at a time.</p>
<p>I hope that helps.</p>
<p>Best regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jim</title>
		<link>http://www.xaprb.com/blog/2006/07/16/how-we-enabled-threading-in-mysql/#comment-1119</link>
		<author>jim</author>
		<pubDate>Mon, 17 Jul 2006 06:01:34 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/07/16/how-we-enabled-threading-in-mysql/#comment-1119</guid>
		<description>&lt;p&gt;MySQL is never multi-process, it is always threaded.  But LinuxThreads are not "true" threads, they are processes that share the same address space using the &lt;code&gt;clone()&lt;/code&gt; system call, so they are reported as distinct processes by the &lt;code&gt;ps&lt;/code&gt; utility. but as far as the mysql server is concerned, they are threads.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>MySQL is never multi-process, it is always threaded.  But LinuxThreads are not &#8220;true&#8221; threads, they are processes that share the same address space using the <code>clone()</code> system call, so they are reported as distinct processes by the <code>ps</code> utility. but as far as the mysql server is concerned, they are threads.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arjen Lentz</title>
		<link>http://www.xaprb.com/blog/2006/07/16/how-we-enabled-threading-in-mysql/#comment-1118</link>
		<author>Arjen Lentz</author>
		<pubDate>Mon, 17 Jul 2006 05:27:17 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/07/16/how-we-enabled-threading-in-mysql/#comment-1118</guid>
		<description>&lt;p&gt;Nah... if you check the MySQL server code, you will not find a single &lt;code&gt;fork()&lt;/code&gt; call.  It's just that unless you use NPTL, you're likely to see multiple mysqld's listed in "&lt;code&gt;ps xa &#124; grep mysqld&lt;/code&gt;". However, that's just the kernel lying to you. You will notice that all those "processes" in fact use the exact same amount of memory, etc. What in fact happens is that the threads are reported as processes. But they're threads anyway.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Nah&#8230; if you check the MySQL server code, you will not find a single <code>fork()</code> call.  It&#8217;s just that unless you use NPTL, you&#8217;re likely to see multiple mysqld&#8217;s listed in &#8220;<code>ps xa | grep mysqld</code>&#8220;. However, that&#8217;s just the kernel lying to you. You will notice that all those &#8220;processes&#8221; in fact use the exact same amount of memory, etc. What in fact happens is that the threads are reported as processes. But they&#8217;re threads anyway.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
