<?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 to track what owns a MySQL connection</title>
	<link>http://www.xaprb.com/blog/2006/07/23/how-to-track-what-owns-a-mysql-connection/</link>
	<description>Stay curious!</description>
	<pubDate>Thu, 24 Jul 2008 00:12:16 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>

	<item>
		<title>By: innotop 1.5.0 released at Xaprb</title>
		<link>http://www.xaprb.com/blog/2006/07/23/how-to-track-what-owns-a-mysql-connection/#comment-13388</link>
		<author>innotop 1.5.0 released at Xaprb</author>
		<pubDate>Mon, 10 Sep 2007 21:59:06 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/07/23/how-to-track-what-owns-a-mysql-connection/#comment-13388</guid>
		<description>[...] and InnoDB Transaction List modes. These show the originating program and PID for connections by querying tables in which this data is stored. The plugin adds the columns and expressions for them, and then adds the data in by using [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] and InnoDB Transaction List modes. These show the originating program and PID for connections by querying tables in which this data is stored. The plugin adds the columns and expressions for them, and then adds the data in by using [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dmitriy</title>
		<link>http://www.xaprb.com/blog/2006/07/23/how-to-track-what-owns-a-mysql-connection/#comment-11568</link>
		<author>Dmitriy</author>
		<pubDate>Wed, 13 Jun 2007 23:23:02 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/07/23/how-to-track-what-owns-a-mysql-connection/#comment-11568</guid>
		<description>SoftTree Technologies now provides full MySQL auditing including both network based and local access as part of the DB Audit solution. The solution comes with graphical tools for setting up the auditing and for monitoring and reporting on database access and user activities within MySQL databases; and also includes a back-end API that allows hooking the auditing into third-party applications. 

For details, see http://www.softtreetech.com/idbaudit.htm


For more details contact SoftTree Technologies</description>
		<content:encoded><![CDATA[<p>SoftTree Technologies now provides full MySQL auditing including both network based and local access as part of the DB Audit solution. The solution comes with graphical tools for setting up the auditing and for monitoring and reporting on database access and user activities within MySQL databases; and also includes a back-end API that allows hooking the auditing into third-party applications. </p>
<p>For details, see <a href="http://www.softtreetech.com/idbaudit.htm" rel="nofollow">http://www.softtreetech.com/idbaudit.htm</a></p>
<p>For more details contact SoftTree Technologies</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tobin Harris</title>
		<link>http://www.xaprb.com/blog/2006/07/23/how-to-track-what-owns-a-mysql-connection/#comment-1972</link>
		<author>Tobin Harris</author>
		<pubDate>Mon, 25 Sep 2006 13:12:25 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/07/23/how-to-track-what-owns-a-mysql-connection/#comment-1972</guid>
		<description>&lt;p&gt;Nice idea that, totally understand why you needs this. &lt;/p&gt;

&lt;p&gt;Another approach is to have a different user for each "application" that connects. It isn't quite as good since you can't see what process opened the connection, but it does mean you can monitor which applications are doing what if you know that application A corresponds to a certain user. I used it to see which applications aren't releasing connections. &lt;/p&gt;

&lt;p&gt;Something that might help solve all problems would be the ability to pass a token in when opening a connection. Such as this&lt;/p&gt;

&lt;pre&gt;conStr = "blah=blah;token=" + this.Process.Id;
con = new MySqlConnection(con);&lt;/pre&gt;

&lt;p&gt;Then, you could see in MySQL process list the token associated with the connection. This would help me greatly as then you could even indicate in the token which function/subroutine the connection was opened from if tha twas the level of granularity required. &lt;/p&gt;

&lt;p&gt;Tobin&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Nice idea that, totally understand why you needs this. </p>
<p>Another approach is to have a different user for each &#8220;application&#8221; that connects. It isn&#8217;t quite as good since you can&#8217;t see what process opened the connection, but it does mean you can monitor which applications are doing what if you know that application A corresponds to a certain user. I used it to see which applications aren&#8217;t releasing connections. </p>
<p>Something that might help solve all problems would be the ability to pass a token in when opening a connection. Such as this</p>
<pre>conStr = "blah=blah;token=" + this.Process.Id;
con = new MySqlConnection(con);</pre>
<p>Then, you could see in MySQL process list the token associated with the connection. This would help me greatly as then you could even indicate in the token which function/subroutine the connection was opened from if tha twas the level of granularity required. </p>
<p>Tobin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xaprb</title>
		<link>http://www.xaprb.com/blog/2006/07/23/how-to-track-what-owns-a-mysql-connection/#comment-1810</link>
		<author>Xaprb</author>
		<pubDate>Thu, 14 Sep 2006 17:35:33 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/07/23/how-to-track-what-owns-a-mysql-connection/#comment-1810</guid>
		<description>&lt;p&gt;Yes, I know, and I've known that for years :-)  But what is the UNIX process ID of the program that made the connection?&lt;/p&gt;

&lt;p&gt;This article isn't about knowing what your connection ID is, or what your connection is doing.  This article is about being a DBA and seeing a connection that is doing something ridiculous, or hung, or just staying open for three days.  You don't want to just kill the connection.  You want to find the code that made the connection, and fix it.  OK, you can easily find out the connection ID (in fact, by definition, you should already know that information before any of the rest of my article is of any use to you), and the machine where the connection was made.  But can you find out the program on that machine that made the connection?  Let's pretend you can (probably impossible for most of you).  And if it's "/usr/sbin/apache2," what then?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The connection is not the source of the trouble.  Knowing the connection ID is trivial, and doesn't get you anywhere.  The program that made the connection is the problem, and that is what you need to find out.&lt;/strong&gt;  That is the point of this article.  The further point of this article is that &lt;strong&gt;you cannot find this information from within MySQL&lt;/strong&gt;.  You have to do some sort of technique such as the ones I suggest here.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Yes, I know, and I&#8217;ve known that for years :-)  But what is the UNIX process ID of the program that made the connection?</p>
<p>This article isn&#8217;t about knowing what your connection ID is, or what your connection is doing.  This article is about being a DBA and seeing a connection that is doing something ridiculous, or hung, or just staying open for three days.  You don&#8217;t want to just kill the connection.  You want to find the code that made the connection, and fix it.  OK, you can easily find out the connection ID (in fact, by definition, you should already know that information before any of the rest of my article is of any use to you), and the machine where the connection was made.  But can you find out the program on that machine that made the connection?  Let&#8217;s pretend you can (probably impossible for most of you).  And if it&#8217;s &#8220;/usr/sbin/apache2,&#8221; what then?</p>
<p><strong>The connection is not the source of the trouble.  Knowing the connection ID is trivial, and doesn&#8217;t get you anywhere.  The program that made the connection is the problem, and that is what you need to find out.</strong>  That is the point of this article.  The further point of this article is that <strong>you cannot find this information from within MySQL</strong>.  You have to do some sort of technique such as the ones I suggest here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Javier</title>
		<link>http://www.xaprb.com/blog/2006/07/23/how-to-track-what-owns-a-mysql-connection/#comment-1808</link>
		<author>Javier</author>
		<pubDate>Thu, 14 Sep 2006 16:19:28 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/07/23/how-to-track-what-owns-a-mysql-connection/#comment-1808</guid>
		<description>&lt;pre&gt;SELECT connection_id();&lt;/pre&gt;

&lt;p&gt;Returns the connection ID (thread ID) for the connection. Every connection has its own unique ID.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<pre>SELECT connection_id();</pre>
<p>Returns the connection ID (thread ID) for the connection. Every connection has its own unique ID.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xaprb</title>
		<link>http://www.xaprb.com/blog/2006/07/23/how-to-track-what-owns-a-mysql-connection/#comment-1621</link>
		<author>Xaprb</author>
		<pubDate>Sat, 26 Aug 2006 01:16:19 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/07/23/how-to-track-what-owns-a-mysql-connection/#comment-1621</guid>
		<description>&lt;p&gt;Selwin,&lt;/p&gt;

&lt;p&gt;Thanks!  No, because &lt;code&gt;SHOW PROCESSLIST&lt;/code&gt; doesn't say what program connected and what its UNIX process ID is.  When you have a bunch of cloned machines and programs all running the same queries, and one of them is causing trouble, knowing what queries it's running doesn't narrow it down.&lt;/p&gt;

&lt;p&gt;In fact, we even found the need to add &lt;em&gt;more&lt;/em&gt; information in -- a few days ago I tweaked the connection code to add the REQUEST_URI in cases where the connection was coming from our intranet, because tracing back to the UNIX process ID just tells us /usr/bin/apache2, and it really helps to know exactly what code is using the connection.&lt;/p&gt;

&lt;p&gt;As if that weren't enough, I even added one more thing in: what Class::DBI module made the connection.&lt;/p&gt;

&lt;p&gt;All these things have been absolutely indispensable for finding badly behaved code and dealing with it.  Much of the code was written by people who freely admit they knew nothing about transactions, and sprinkled BEGIN and COMMIT through the code without knowing what they meant.  It's pretty disconcerting when that code goes into wider production and the mysterious side effects begin piling up.  "Hey!  I just entered that information and now it disappeared!  Where did it go?"&lt;/p&gt;

&lt;p&gt;Definitely not something &lt;code&gt;SHOW PROCESSLIST&lt;/code&gt; can even start to do.  But your needs may be different from ours.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Selwin,</p>
<p>Thanks!  No, because <code>SHOW PROCESSLIST</code> doesn&#8217;t say what program connected and what its UNIX process ID is.  When you have a bunch of cloned machines and programs all running the same queries, and one of them is causing trouble, knowing what queries it&#8217;s running doesn&#8217;t narrow it down.</p>
<p>In fact, we even found the need to add <em>more</em> information in &#8212; a few days ago I tweaked the connection code to add the REQUEST_URI in cases where the connection was coming from our intranet, because tracing back to the UNIX process ID just tells us /usr/bin/apache2, and it really helps to know exactly what code is using the connection.</p>
<p>As if that weren&#8217;t enough, I even added one more thing in: what Class::DBI module made the connection.</p>
<p>All these things have been absolutely indispensable for finding badly behaved code and dealing with it.  Much of the code was written by people who freely admit they knew nothing about transactions, and sprinkled BEGIN and COMMIT through the code without knowing what they meant.  It&#8217;s pretty disconcerting when that code goes into wider production and the mysterious side effects begin piling up.  &#8220;Hey!  I just entered that information and now it disappeared!  Where did it go?&#8221;</p>
<p>Definitely not something <code>SHOW PROCESSLIST</code> can even start to do.  But your needs may be different from ours.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Selwin</title>
		<link>http://www.xaprb.com/blog/2006/07/23/how-to-track-what-owns-a-mysql-connection/#comment-1619</link>
		<author>Selwin</author>
		<pubDate>Fri, 25 Aug 2006 23:39:12 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/07/23/how-to-track-what-owns-a-mysql-connection/#comment-1619</guid>
		<description>&lt;p&gt;Nice article. But isn't "SHOW processlist" enough to do this type of troubleshooting?&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Nice article. But isn&#8217;t &#8220;SHOW processlist&#8221; enough to do this type of troubleshooting?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xaprb</title>
		<link>http://www.xaprb.com/blog/2006/07/23/how-to-track-what-owns-a-mysql-connection/#comment-1199</link>
		<author>Xaprb</author>
		<pubDate>Mon, 24 Jul 2006 12:00:57 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/07/23/how-to-track-what-owns-a-mysql-connection/#comment-1199</guid>
		<description>&lt;p&gt;That's interesting, I never knew about it (&lt;a href="http://dev.mysql.com/doc/refman/4.1/en/server-system-variables.html" rel="nofollow"&gt;init_connect&lt;/a&gt;).  I'm not sure how I could get the same functionality though, since that SQL statement executing on the MySQL server would not know the UNIX process ID or program name of whatever was trying to connect.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>That&#8217;s interesting, I never knew about it (<a href="http://dev.mysql.com/doc/refman/4.1/en/server-system-variables.html" rel="nofollow">init_connect</a>).  I&#8217;m not sure how I could get the same functionality though, since that SQL statement executing on the MySQL server would not know the UNIX process ID or program name of whatever was trying to connect.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tobias "flupps" Asplund</title>
		<link>http://www.xaprb.com/blog/2006/07/23/how-to-track-what-owns-a-mysql-connection/#comment-1196</link>
		<author>Tobias "flupps" Asplund</author>
		<pubDate>Mon, 24 Jul 2006 09:34:21 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/07/23/how-to-track-what-owns-a-mysql-connection/#comment-1196</guid>
		<description>&lt;p&gt;If you want a global solution you could add it to --init-connect instead of having to modify your db access layer.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>If you want a global solution you could add it to &#8211;init-connect instead of having to modify your db access layer.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
