<?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>Racker Hacker &#187; memory</title>
	<atom:link href="http://rackerhacker.com/tag/memory/feed/" rel="self" type="application/rss+xml" />
	<link>http://rackerhacker.com</link>
	<description>Words of wisdom from a server administrator</description>
	<lastBuildDate>Tue, 07 Feb 2012 14:07:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>MySQL: The total number of locks exceeds the lock table size</title>
		<link>http://rackerhacker.com/2010/02/16/mysql-the-total-number-of-locks-exceeds-the-lock-table-size-2/</link>
		<comments>http://rackerhacker.com/2010/02/16/mysql-the-total-number-of-locks-exceeds-the-lock-table-size-2/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 18:00:29 +0000</pubDate>
		<dc:creator>Major Hayden</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[innodb]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://rackerhacker.com/?p=1173</guid>
		<description><![CDATA[If you're running an operation on a large number of rows within a table that uses the InnoDB storage engine, you might see this error: ERROR 1206 (HY000): The total number of locks exceeds the lock table size MySQL is trying to tell you that it doesn't have enough room to store all of the [...]<p><a href="http://rackerhacker.com/2010/02/16/mysql-the-total-number-of-locks-exceeds-the-lock-table-size-2/">MySQL: The total number of locks exceeds the lock table size</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></description>
			<content:encoded><![CDATA[<p>If you're running an operation on a large number of rows within a table that uses the InnoDB storage engine, you might see this error:</p>
<p><code>ERROR 1206 (HY000): The total number of locks exceeds the lock table size</code></p>
<p>MySQL is trying to tell you that it doesn't have enough room to store all of the row locks that it would need to execute your query.  The only way to fix it for sure is to adjust <code>innodb_buffer_pool_size</code> and restart MySQL.  By default, this is set to only 8MB, which is too small for anyone who is using InnoDB to do anything.</p>
<p><strong>If you need a temporary workaround,</strong> reduce the amount of rows you're manipulating in one query.  For example, if you need to delete a million rows from a table, try to delete the records in chunks of 50,000 or 100,000 rows.  If you're inserting many rows, try to insert portions of the data at a single time.</p>
<p>Further reading:</p>
<ul>
<li><a href="http://bugs.mysql.com/bug.php?id=15667">MySQL Bug #15667 - The total number of locks exceeds the lock table size</a></li>
<li><a href="http://mrothouse.wordpress.com/2006/10/20/mysql-error-1206/">MySQL Error 1206 &raquo; Mike R's Blog</a></li>
</ul>
<p><a href="http://rackerhacker.com/2010/02/16/mysql-the-total-number-of-locks-exceeds-the-lock-table-size-2/">MySQL: The total number of locks exceeds the lock table size</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://rackerhacker.com/2010/02/16/mysql-the-total-number-of-locks-exceeds-the-lock-table-size-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>MySQL: The total number of locks exceeds the lock table size</title>
		<link>http://rackerhacker.com/2010/01/29/mysql-the-total-number-of-locks-exceeds-the-lock-table-size/</link>
		<comments>http://rackerhacker.com/2010/01/29/mysql-the-total-number-of-locks-exceeds-the-lock-table-size/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 13:12:21 +0000</pubDate>
		<dc:creator>Major Hayden</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[innodb]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://rackerhacker.com/?p=1156</guid>
		<description><![CDATA[This problem has cropped up for me a few times, but I've always forgotten to make a post about it. If you're working with a large InnoDB table and you're updating, inserting, or deleting a large volume of rows, you may stumble upon this error: ERROR 1206 (HY000): The total number of locks exceeds the [...]<p><a href="http://rackerhacker.com/2010/01/29/mysql-the-total-number-of-locks-exceeds-the-lock-table-size/">MySQL: The total number of locks exceeds the lock table size</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></description>
			<content:encoded><![CDATA[<p>This problem has cropped up for me a few times, but I've always forgotten to make a post about it.  If you're working with a large InnoDB table and you're updating, inserting, or deleting a large volume of rows, you may stumble upon this error:</p>
<p><code>ERROR 1206 (HY000): The total number of locks exceeds the lock table size</code></p>
<p>InnoDB stores its lock tables in the main buffer pool.  This means that the number of locks you can have at the same time is limited by the <code>innodb_buffer_pool_size</code> variable that was set when MySQL was started.  By default, MySQL leaves this at 8MB, which is pretty useless if you're doing anything with InnoDB on your server.</p>
<p>Luckily, the fix for this issue is very easy: adjust <code>innodb_buffer_pool_size</code> to a more reasonable value.  However, that fix does require a restart of the MySQL daemon.  There's simply no way to adjust this variable on the fly (with the current stable MySQL versions as of this post's writing).</p>
<p>Before you adjust the variable, make sure that your server can handle the additional memory usage.  The <code>innodb_buffer_pool_size</code> variable is a server wide variable, not a per-thread variable, so it's shared between all of the connections to the MySQL server (like the query cache).  If you set it to something like 1GB, MySQL won't use all of that up front.  As MySQL finds more things to put in the buffer, the memory usage will gradually increase until it reaches 1GB.  At that point, the oldest and least used data begins to get pruned when new data needs to be present.</p>
<p><strong>So, you need a workaround without a MySQL restart?</strong></p>
<p>If you're in a pinch, and you need a workaround, break up your statements into chunks.  If you need to delete a million rows, try deleting 5-10% of those rows per transaction.  This may allow you to sneak under the lock table size limitations and clear out some data without restarting MySQL.</p>
<p>To learn more about InnoDB's parameters, visit the <a href="http://dev.mysql.com/doc/refman/5.0/en/innodb-parameters.html">MySQL documentation</a>.</p>
<p><a href="http://rackerhacker.com/2010/01/29/mysql-the-total-number-of-locks-exceeds-the-lock-table-size/">MySQL: The total number of locks exceeds the lock table size</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://rackerhacker.com/2010/01/29/mysql-the-total-number-of-locks-exceeds-the-lock-table-size/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reduce disk I/O for small reads using memory</title>
		<link>http://rackerhacker.com/2008/08/07/reduce-disk-io-for-small-reads-using-memory/</link>
		<comments>http://rackerhacker.com/2008/08/07/reduce-disk-io-for-small-reads-using-memory/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 17:00:27 +0000</pubDate>
		<dc:creator>Major Hayden</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[iowait]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[memory]]></category>

		<guid isPermaLink="false">http://rackerhacker.com/?p=316</guid>
		<description><![CDATA[Many applications that are used on a standard server perform quite a few of small writes to the disk (like MySQL or Apache). These writes can pile up and limit the performance of your applications. If you have kernel 2.6.9 or later, you can adjust how these small writes are handled to allow for better [...]<p><a href="http://rackerhacker.com/2008/08/07/reduce-disk-io-for-small-reads-using-memory/">Reduce disk I/O for small reads using memory</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></description>
			<content:encoded><![CDATA[<p>Many applications that are used on a standard server perform quite a few of small writes to the disk (like MySQL or Apache).  These writes can pile up and limit the performance of your applications.  If you have kernel 2.6.9 or later, you can adjust how these small writes are handled to allow for better performance.</p>
<p>There's two main kernel variables to know:</p>
<p><strong>vm.dirty_ratio</strong> - The highest % of your memory that can be used to hold dirty data.  If you set this to a low value, the kernel will flush small writes to the disk more often.  Higher values allow the small writes to stack up in memory.  They'll go to the disk in bigger chunks.</p>
<p><strong>vm.dirty_background_ratio</strong> - The lowest % of your memory where pdflush is told to stop when it is writing dirty data.  You'll want to keep this set as low as possible.</p>
<p>These might confuse you.  In short, when your memory begins filling with little pieces of data that needs to be written to the disk, it will keep filling until it reaches the dirty_ratio.  At that point, pdflush will start up, and it will write data until it reduces the dirty data to the value set by dirty_background_ratio.</p>
<p>Stock 2.6.9 kernels have a dirty_background_ratio of 10% and a dirty_ratio of 40%.  Some distributions tweak these defaults to something different, so you may want to review the settings on your system.  On a system with heavy disk I/O, you can increase the dirty_ratio and reduce the dirty_background_ratio.  A little experimentation may be necessary to find the perfect setting for your server.</p>
<p>If you want to play with the variables, just use your standard echo:</p>
<p><code>echo 5 &gt; /proc/sys/vm/dirty_background_ratio<br />
echo 60 &gt; /proc/sys/vm/dirty_ratio</code></p>
<p>Once you've found the right setting, you can set it permanently by adding lines to your /etc/sysctl.conf:</p>
<p><code>vm.dirty_background_ratio = 5<br />
vm.dirty_ratio = 60</code></p>
<p>If you have a reliable server with a good RAID card and power supply, you could set the dirty_ratio to 100 and the dirty_background_ratio to 1.  This was recommended by a buddy of mine who runs quite a few servers running virtual machines.</p>
<p><a href="http://rackerhacker.com/2008/08/07/reduce-disk-io-for-small-reads-using-memory/">Reduce disk I/O for small reads using memory</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://rackerhacker.com/2008/08/07/reduce-disk-io-for-small-reads-using-memory/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

