<?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: MySQL:  Slave lag behind master and data corruption.</title>
	<atom:link href="http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/feed/" rel="self" type="application/rss+xml" />
	<link>http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/</link>
	<description>Enterprise level solutions, LAMP, Linux, Apache, MySQL, PHP, Perl, Windows, Cache, Optimization</description>
	<lastBuildDate>Mon, 16 Apr 2012 22:54:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Paul M</title>
		<link>http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/comment-page-1/#comment-327</link>
		<dc:creator>Paul M</dc:creator>
		<pubDate>Mon, 22 Oct 2007 04:14:47 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/#comment-327</guid>
		<description>Noticed Baron (Xaprb) is too modest, use the MySQL toolkit and do checksums on the slave and you can also use the sync function to sync missing rows.

You are going to have to use mysqlbinlog to mine the binlogs to determine what SQL was not replicated.
If you combine table checksum from the toolkit, you should be able to search for the SQL (on the master) which should have updated the slave.

Other stuff. Review the use of these settings on master/slave.
innodb_flush_log_at_trx_commit = 0
innodb_lock_wait_timeout = 50

From the MySQL 5.0 doco
http://dev.mysql.com/doc/refman/5.0/en/innodb-parameters.html

Note: For the greatest possible durability and consistency in a replication setup using InnoDB with transactions, you should use innodb_flush_log_at_trx_commit=1, sync_binlog=1

Note: Both these are going to slow down the transaction per sec performance of the master, so benchmark first and change to see the difference.

Have Fun
Paul
http://blog.dbadojo.com/2007/09/mysqltoolkit-mysql-table-checksum.html</description>
		<content:encoded><![CDATA[<p>Noticed Baron (Xaprb) is too modest, use the MySQL toolkit and do checksums on the slave and you can also use the sync function to sync missing rows.</p>
<p>You are going to have to use mysqlbinlog to mine the binlogs to determine what SQL was not replicated.<br />
If you combine table checksum from the toolkit, you should be able to search for the SQL (on the master) which should have updated the slave.</p>
<p>Other stuff. Review the use of these settings on master/slave.<br />
innodb_flush_log_at_trx_commit = 0<br />
innodb_lock_wait_timeout = 50</p>
<p>From the MySQL 5.0 doco<br />
<a href="http://dev.mysql.com/doc/refman/5.0/en/innodb-parameters.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.0/en/innodb-parameters.html</a></p>
<p>Note: For the greatest possible durability and consistency in a replication setup using InnoDB with transactions, you should use innodb_flush_log_at_trx_commit=1, sync_binlog=1</p>
<p>Note: Both these are going to slow down the transaction per sec performance of the master, so benchmark first and change to see the difference.</p>
<p>Have Fun<br />
Paul<br />
<a href="http://blog.dbadojo.com/2007/09/mysqltoolkit-mysql-table-checksum.html" rel="nofollow">http://blog.dbadojo.com/2007/09/mysqltoolkit-mysql-table-checksum.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CrazyToon</title>
		<link>http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/comment-page-1/#comment-323</link>
		<dc:creator>CrazyToon</dc:creator>
		<pubDate>Wed, 17 Oct 2007 17:11:39 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/#comment-323</guid>
		<description>Mysql version 5.0.45 source install.
We fixed our sort_buffer_size.  I didn&#039;t know that if we put 128M, it would take 128M for each query.  I, for some reason, thought it was the ceiling and queries will use whatever it needs until it hit 128M.  Apparently I was wrong.  Now we set sort_buffer_size=4M


I will try out the packet size change.  Also will check for the errors in the log for the errors Dmitri mentioned.   

Thanks for all of your suggestions/comments.  Even if your suggestions might not fix the problem, I am sure we are all learning what to do or not to do.  Keep them coming.</description>
		<content:encoded><![CDATA[<p>Mysql version 5.0.45 source install.<br />
We fixed our sort_buffer_size.  I didn&#8217;t know that if we put 128M, it would take 128M for each query.  I, for some reason, thought it was the ceiling and queries will use whatever it needs until it hit 128M.  Apparently I was wrong.  Now we set sort_buffer_size=4M</p>
<p>I will try out the packet size change.  Also will check for the errors in the log for the errors Dmitri mentioned.   </p>
<p>Thanks for all of your suggestions/comments.  Even if your suggestions might not fix the problem, I am sure we are all learning what to do or not to do.  Keep them coming.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/comment-page-1/#comment-321</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Tue, 16 Oct 2007 15:30:40 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/#comment-321</guid>
		<description>I don&#039;t recommend setting up the slave via a dump/import. It&#039;s better to do it by copying the data files.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t recommend setting up the slave via a dump/import. It&#8217;s better to do it by copying the data files.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dmitri Mikhailov</title>
		<link>http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/comment-page-1/#comment-320</link>
		<dc:creator>Dmitri Mikhailov</dc:creator>
		<pubDate>Tue, 16 Oct 2007 14:58:06 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/#comment-320</guid>
		<description>Make sure read_buffer_size is less or equal to max_allowed_packet, there were few bugs related to these variables. &quot;Too many open files&quot; or &quot;Can&#039;t open file&quot; errors? Tune up open_files_limit variable.

 - Mixed myisam/innodb config? &quot;Out of memory&quot; errors in the log? Slave crashes with no traces in the logs? Upgrade the memory on the slave or tune up the server variables.

 - Repair table corrupts data/index file? Make sure myisam_repair_threads is set to 1, just to be safe, there were a few bugs regarding &quot;REPAIR TABLE&quot; corrupting the myisam data/index files.

 - thread_cache_size is defined twice in the slave config file. This just does not make sense.</description>
		<content:encoded><![CDATA[<p>Make sure read_buffer_size is less or equal to max_allowed_packet, there were few bugs related to these variables. &#8220;Too many open files&#8221; or &#8220;Can&#8217;t open file&#8221; errors? Tune up open_files_limit variable.</p>
<p> &#8211; Mixed myisam/innodb config? &#8220;Out of memory&#8221; errors in the log? Slave crashes with no traces in the logs? Upgrade the memory on the slave or tune up the server variables.</p>
<p> &#8211; Repair table corrupts data/index file? Make sure myisam_repair_threads is set to 1, just to be safe, there were a few bugs regarding &#8220;REPAIR TABLE&#8221; corrupting the myisam data/index files.</p>
<p> &#8211; thread_cache_size is defined twice in the slave config file. This just does not make sense.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dmitri Mikhailov</title>
		<link>http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/comment-page-1/#comment-319</link>
		<dc:creator>Dmitri Mikhailov</dc:creator>
		<pubDate>Tue, 16 Oct 2007 14:53:55 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/#comment-319</guid>
		<description>Few things are missing:

 - MySQL version; 
 - Error logs;
 - Slow query log;
 - Repair table output.

Without this information I can only guess...

 - Replication errors? Set max_allowed_packet to the same size on master and slave (in your case it&#039;s set to 32M on master and 1M on slave). Make sure read_buffer_size </description>
		<content:encoded><![CDATA[<p>Few things are missing:</p>
<p> &#8211; MySQL version;<br />
 &#8211; Error logs;<br />
 &#8211; Slow query log;<br />
 &#8211; Repair table output.</p>
<p>Without this information I can only guess&#8230;</p>
<p> &#8211; Replication errors? Set max_allowed_packet to the same size on master and slave (in your case it&#8217;s set to 32M on master and 1M on slave). Make sure read_buffer_size</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GOTG</title>
		<link>http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/comment-page-1/#comment-318</link>
		<dc:creator>GOTG</dc:creator>
		<pubDate>Tue, 16 Oct 2007 14:48:40 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/#comment-318</guid>
		<description>To check binary log use mysqlbinlog. It&#039;s unlikely that you have queries bigger than 1M (slave packet size) but I see master having 32M packet size. If large queries are missing from slaves then you may need to increase the packet size on slaves.</description>
		<content:encoded><![CDATA[<p>To check binary log use mysqlbinlog. It&#8217;s unlikely that you have queries bigger than 1M (slave packet size) but I see master having 32M packet size. If large queries are missing from slaves then you may need to increase the packet size on slaves.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dan</title>
		<link>http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/comment-page-1/#comment-317</link>
		<dc:creator>dan</dc:creator>
		<pubDate>Tue, 16 Oct 2007 13:18:00 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/#comment-317</guid>
		<description>what is the mysql version? we had similar problem when we were on 4.0 and it seemed to be fixed when we moved to 4.1.xx</description>
		<content:encoded><![CDATA[<p>what is the mysql version? we had similar problem when we were on 4.0 and it seemed to be fixed when we moved to 4.1.xx</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CrazyToon</title>
		<link>http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/comment-page-1/#comment-316</link>
		<dc:creator>CrazyToon</dc:creator>
		<pubDate>Tue, 16 Oct 2007 04:11:11 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/#comment-316</guid>
		<description>GOTG:  we initially thought it was the myisam tables so we moved to innodb.  Our total increase in disk usage is about 1.5x.  We also checked the server IDs and they are all unique.
Ryan:  how does one go about looking into binlogs?

All good ideas.  Keep them coming.</description>
		<content:encoded><![CDATA[<p>GOTG:  we initially thought it was the myisam tables so we moved to innodb.  Our total increase in disk usage is about 1.5x.  We also checked the server IDs and they are all unique.<br />
Ryan:  how does one go about looking into binlogs?</p>
<p>All good ideas.  Keep them coming.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ryan</title>
		<link>http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/comment-page-1/#comment-314</link>
		<dc:creator>ryan</dc:creator>
		<pubDate>Tue, 16 Oct 2007 02:51:37 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/#comment-314</guid>
		<description>One thing to check is if the missing rows are being written to the binlog at all.  I&#039;ve run into a few cases where certain statements are applied to the master but not written to the binlog so of course are not relayed to the slaves.  

And if they are, it would be worth checking to watch the binlog to try to discern a pattern from the missing data.  Is it a unusually large statement?  Does it use a particular syntax that is unlike your other code?  Is it at a regular time interval?  These will give important clues to figuring out the root of the problem.</description>
		<content:encoded><![CDATA[<p>One thing to check is if the missing rows are being written to the binlog at all.  I&#8217;ve run into a few cases where certain statements are applied to the master but not written to the binlog so of course are not relayed to the slaves.  </p>
<p>And if they are, it would be worth checking to watch the binlog to try to discern a pattern from the missing data.  Is it a unusually large statement?  Does it use a particular syntax that is unlike your other code?  Is it at a regular time interval?  These will give important clues to figuring out the root of the problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GOTG</title>
		<link>http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/comment-page-1/#comment-313</link>
		<dc:creator>GOTG</dc:creator>
		<pubDate>Tue, 16 Oct 2007 02:30:40 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/#comment-313</guid>
		<description>BTW, missing data on slaves sound like non-unique server IDs.</description>
		<content:encoded><![CDATA[<p>BTW, missing data on slaves sound like non-unique server IDs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GOTG</title>
		<link>http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/comment-page-1/#comment-312</link>
		<dc:creator>GOTG</dc:creator>
		<pubDate>Tue, 16 Oct 2007 02:07:49 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/#comment-312</guid>
		<description>Slaves lag if you run heavy queries on myisam tables. Myisam tables lock the whole table at insert/update so you need to use something else for heavy insert/update tables (innodb would be the logical choice). Warning: innodb tables are about 6 times the size of myisam tables.</description>
		<content:encoded><![CDATA[<p>Slaves lag if you run heavy queries on myisam tables. Myisam tables lock the whole table at insert/update so you need to use something else for heavy insert/update tables (innodb would be the logical choice). Warning: innodb tables are about 6 times the size of myisam tables.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xaprb</title>
		<link>http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/comment-page-1/#comment-311</link>
		<dc:creator>Xaprb</dc:creator>
		<pubDate>Tue, 16 Oct 2007 01:27:56 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/#comment-311</guid>
		<description>Your sort_buffer_size is too large; it is allocated for every query that does a filesort.  You should keep it smaller and only increase it just before each query that does a filesort:

set @@session.sort_buffer_size = (bigger value);
(query)
set @@session.sort_buffer_size = default;

You should probably do a little investigative work to see what you really need to tune. Any chance you can benchmark before tuning?  It might save you a lot of work.  Otherwise try mysqlreport or something for some basic direction on it.

As far as the slaves being behind and missing data, I don&#039;t see anything suspicious (I was initially thinking you&#039;d have some replication filters not doing what you thought).  Any errors in the master or slave error logs?

You might consider posing your question on the mysql general mailing list.  Blog comments are hard to use for a conversation about something like this.</description>
		<content:encoded><![CDATA[<p>Your sort_buffer_size is too large; it is allocated for every query that does a filesort.  You should keep it smaller and only increase it just before each query that does a filesort:</p>
<p>set @@session.sort_buffer_size = (bigger value);<br />
(query)<br />
set @@session.sort_buffer_size = default;</p>
<p>You should probably do a little investigative work to see what you really need to tune. Any chance you can benchmark before tuning?  It might save you a lot of work.  Otherwise try mysqlreport or something for some basic direction on it.</p>
<p>As far as the slaves being behind and missing data, I don&#8217;t see anything suspicious (I was initially thinking you&#8217;d have some replication filters not doing what you thought).  Any errors in the master or slave error logs?</p>
<p>You might consider posing your question on the mysql general mailing list.  Blog comments are hard to use for a conversation about something like this.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

