<?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>Gary Pendergast &#187; RBR</title> <atom:link href="http://pento.net/tag/rbr/feed/" rel="self" type="application/rss+xml" /><link>http://pento.net</link> <description>I&#039;m on the Internet</description> <lastBuildDate>Sat, 03 Dec 2011 09:27:46 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <cloud
domain='pento.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' /> <item><title>Replication with InnoDB and MyISAM Transactions</title><link>http://pento.net/2009/02/13/replication-with-innodb-and-myisam-transactions/</link> <comments>http://pento.net/2009/02/13/replication-with-innodb-and-myisam-transactions/#comments</comments> <pubDate>Fri, 13 Feb 2009 05:26:57 +0000</pubDate> <dc:creator>Gary</dc:creator> <category><![CDATA[MySQL]]></category> <category><![CDATA[MySQL 5.1]]></category> <category><![CDATA[RBR]]></category> <category><![CDATA[regression]]></category> <category><![CDATA[replication]]></category> <guid
isPermaLink="false">http://pento.net/blog/?p=3</guid> <description><![CDATA[There&#8217;s a change of behaviour in MySQL 5.1.31 for Row Based Replication, if you have InnoDB transactions that also write to a MyISAM (or other non-transactional engine) table. It&#8217;s a side effect of fixing Bug #40116. Take this simple example: TRANSACTION 1: INSERT INTO myisam_tbl &#40;item, val&#41; VALUES &#40;1, 0&#41;; TRANSACTION 1: INSERT INTO innodb_tbl [...]]]></description> <content:encoded><![CDATA[<p>There&#8217;s a change of behaviour in MySQL 5.1.31 for Row Based Replication, if you have InnoDB transactions that also write to a MyISAM (or other non-transactional engine) table. It&#8217;s a side effect of fixing <a
title="MySQL Bug #40116: Uncommited changes are replicated and stay on slave after rollback on master" href="http://bugs.mysql.com/40116">Bug #40116</a>. Take this simple example:</p><div
class="wp_syntax"><div
class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">TRANSACTION</span> <span style="color: #cc66cc;">1</span>: <span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> myisam_tbl <span style="color: #66cc66;">&#40;</span>item<span style="color: #66cc66;">,</span> val<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold;">TRANSACTION</span> <span style="color: #cc66cc;">1</span>: <span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> innodb_tbl <span style="color: #66cc66;">&#40;</span>item<span style="color: #66cc66;">,</span> val<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">-</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">-</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold;">TRANSACTION</span> <span style="color: #cc66cc;">1</span>: <span style="color: #993333; font-weight: bold;">START</span> <span style="color: #993333; font-weight: bold;">TRANSACTION</span>;
<span style="color: #993333; font-weight: bold;">TRANSACTION</span> <span style="color: #cc66cc;">1</span>: <span style="color: #993333; font-weight: bold;">UPDATE</span> myisam_tbl <span style="color: #993333; font-weight: bold;">SET</span> val<span style="color: #66cc66;">=</span>val<span style="color: #66cc66;">+</span><span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">WHERE</span> item<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span>;
<span style="color: #993333; font-weight: bold;">TRANSACTION</span> <span style="color: #cc66cc;">1</span>: <span style="color: #993333; font-weight: bold;">UPDATE</span> innodb_tbl <span style="color: #993333; font-weight: bold;">SET</span> val<span style="color: #66cc66;">=</span><span style="color: #66cc66;">&#40;</span> <span style="color: #993333; font-weight: bold;">SELECT</span> val <span style="color: #993333; font-weight: bold;">FROM</span> myisam_tbl <span style="color: #993333; font-weight: bold;">WHERE</span> item<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WHERE</span> item<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span>;
<span style="color: #993333; font-weight: bold;">TRANSACTION</span> <span style="color: #cc66cc;">2</span>: <span style="color: #993333; font-weight: bold;">START</span> <span style="color: #993333; font-weight: bold;">TRANSACTION</span>;
<span style="color: #993333; font-weight: bold;">TRANSACTION</span> <span style="color: #cc66cc;">2</span>: <span style="color: #993333; font-weight: bold;">UPDATE</span> myisam_tbl <span style="color: #993333; font-weight: bold;">SET</span> val<span style="color: #66cc66;">=</span>val<span style="color: #66cc66;">+</span><span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">WHERE</span> item<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span>;
<span style="color: #993333; font-weight: bold;">TRANSACTION</span> <span style="color: #cc66cc;">2</span>: <span style="color: #993333; font-weight: bold;">UPDATE</span> innodb_tbl <span style="color: #993333; font-weight: bold;">SET</span> val<span style="color: #66cc66;">=</span><span style="color: #66cc66;">&#40;</span> <span style="color: #993333; font-weight: bold;">SELECT</span> val <span style="color: #993333; font-weight: bold;">FROM</span> myisam_tbl <span style="color: #993333; font-weight: bold;">WHERE</span> item<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WHERE</span> item<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">2</span>;
<span style="color: #993333; font-weight: bold;">TRANSACTION</span> <span style="color: #cc66cc;">2</span>: COMMIT;
<span style="color: #993333; font-weight: bold;">TRANSACTION</span> <span style="color: #cc66cc;">1</span>: COMMIT;</pre></div></div><p>After this, the Master innodb_tbl would look like this:</p><table><tbody><tr><th>item</th><th>val</th></tr><tr><td>1</td><td>1</td></tr><tr><td>2</td><td>2</td></tr></tbody></table><p>And the Master myisam_tbl will look like this:</p><table><tbody><tr><th>item</th><th>val</th></tr><tr><td>1</td><td>2</td></tr></tbody></table><p>In 5.1.30 and earlier, the Slave tables will be correct. However, in 5.1.31, the Slave myisam_tbl will be correct, but the innodb_tbl will look like this:</p><table><tbody><tr><th>item</th><th>val</th></tr><tr><td>1</td><td>0</td></tr><tr><td>2</td><td>1</td></tr></tbody></table><p>As a bonus, there&#8217;s no workaround. Statement Based Replication has never worked for this case. For an SBR Slave (In MySQL 5.0.x and 5.1.x), the Slave myisam_tbl will be correct, but the Slave innodb_tbl will look like this:</p><table><tbody><tr><th>item</th><th>val</th></tr><tr><td>1</td><td>2</td></tr><tr><td>2</td><td>2</td></tr></tbody></table><p>And so, we come to the moral of the story. Don&#8217;t use non-transactional tables in the middle of a transaction. Ever. You will only cause yourself more pain than you can possibly imagine. Instead, move the writes to the non-transactional tables outside of the transaction.</p> ]]></content:encoded> <wfw:commentRss>http://pento.net/2009/02/13/replication-with-innodb-and-myisam-transactions/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> </channel> </rss>
