<?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>PlanetMysql.ru - информация о СУБД MySQL &#187; semisynch</title>
	<atom:link href="http://planetmysql.ru/category/semisynch/feed/" rel="self" type="application/rss+xml" />
	<link>http://planetmysql.ru</link>
	<description>Блог о самой популярной СУБД MySQL</description>
	<lastBuildDate>Fri, 10 Feb 2012 22:53:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Testing MySQL 5.5 semi-synchronous replication</title>
		<link>http://datacharmer.blogspot.com/2010/11/testing-mysql-55-semi-synchronous.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-mysql-5-5-semi-synchronous-replication</link>
		<comments>http://datacharmer.blogspot.com/2010/11/testing-mysql-55-semi-synchronous.html#comments</comments>
		<pubDate>Thu, 04 Nov 2010 00:19:00 +0000</pubDate>
		<dc:creator>Giuseppe Maxia</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[sandbox]]></category>
		<category><![CDATA[semisynch]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[A few days ago I saw an article about Semi-Synchronous Replication in MySQL 5.5. It asks questions, and doesn't give answers beyond gut feeling. So I thought that I would do some practical testing of this new feature.Before we go that way, though, let's revisit the theory.How semi-synchronous replication worksFigure 1. A transaction with regular replicationWith regular replication, you send a transaction to the master (1). When the COMMIT is received, the master executes it (2), and if successful it logs the transaction to the binary log (3). The the master answers the client request (4) with a successful result. In the meantime, the slaves replicate the record (5).What happens if the master crashes after point #4 and before a slave has had a chance of getting the data in point #5?The client will have a result for that transaction, but that data is lost, because it has never reached one slave. Figure 2. A transaction with semi-synchronous replicationLet's see the same scenario with semi-synchronous replication. All is the same until point #3. Then, things change. The master does not return to the client. Instead, it alerts the slave that a transaction is available (4). The slave gets it and stores it to the relay log (5). Without further action, the slave tells the master that the transaction was received (6) and only then the master returns the result to the client (7).What is the benefit? If the master crashes, the transaction is lost. but the client does not get the false information that the transaction was stored. Instead, if the master crashes before it returns the result to the client, the client gets an error, and knows that that transaction needs to be reworked when a new master is back.Semi-synchronous replication in practiceNow, the practicalities.How do you tell if semi-synchronous replication is working? If you leave the default timeout of 10 seconds, you have an immediate clue that something is wrong when a query takes too long to return. Investigation is possible by looking at the GLOBAL STATUS variables.Rpl_semi_sync_master_status tells you if the master is ready for semi-synchronous replication.Rpl_semi_sync_master_yes_tx is the number of positive transactions that were delivered using semi-synchronous replication.Rpl_semi_sync_master_no_tx is the number of failed attempts at delivering a transaction via semi-synchronous replication. When that happens, Rpl_semi_sync_master_status becomes "OFF", and you need investigating.The important thing to understand about this feature is that semi-synchronous replication does not guarantee that your transaction is executed in the slave. It will only tell you that the data has been transferred to the slave relay log. It can still happen that the transaction fails to execute on the slave (which could be either a bug in your application or a bug in MySQL replication). But this is not a cluster. Don't expect a two-phase commit.Testing semi-synchronous replicationIf you want to test this feature without suffering too much, you can use a tarball binary and MySQL Sandbox. Once you have installed MySQL Sandbox and have downloaded the server tarball, you can install a test replication system withmake_replication_sandbox --how_many_slaves=4 /path/to/mysql-5.5.6-yourOS.tar.gzThis will create a system with 1 master and 4 slaves.The Sandbox has a shortcut to install the plugin quickly and painlessly:sbtool -o plugin --plugin=semisynch -s $HOME/sandboxes/rsandbox_5_5_6Now you will have the semi-synchronous plugin installed in the master and all the slaves. For our tests, we will make a shell script, an easy task thanks to the sandbox utilities.#!/bin/shecho "disabling semi-synch replication in all slaves except 1"./s1 -e 'set global rpl_semi_sync_slave_enabled=1'./s1 -e 'slave stop io_thread; slave start'for E in 2 3 4do    ./s$E -e 'set global rpl_semi_sync_slave_enabled=0'    ./s$E -e 'slave stop io_thread; slave start'done## this query will show the main variables that tell# if semi-synch replication is working#Q1='select variable_name, variable_value'Q2='from information_schema.global_status'Q3='where variable_name in'Q4='("RPL_SEMI_SYNC_MASTER_YES_TX", "RPL_SEMI_SYNC_MASTER_NO_TX")'I_S_Q="$Q1 $Q2 $Q3 $Q4"echo ""echo "creating a table. it should replicate through the semi-synch"./m -vvv -e 'create table test.t1( i int)'./m -e "$I_S_Q"echo ""echo "inserting a record. The number of 'YES' should increase"./m -e 'insert into test.t1 values (1)'./m -e "$I_S_Q"echo ""echo "disabling semi-synch replication in slave 1"./s1 -e 'set global rpl_semi_sync_slave_enabled=0'./s1 -e 'slave stop io_thread; slave start'echo ""echo "enabling semi-synch replication in slave 3"./s3 -e 'set global rpl_semi_sync_slave_enabled=1'./s3 -e 'slave stop io_thread; slave start'echo ""echo "inserting a record. The number of 'YES' should increase"./m -e 'insert into test.t1 values (2)'./m -e "$I_S_Q"echo ""echo "disabling semi-synch replication in slave 3"./s3 -e 'set global rpl_semi_sync_slave_enabled=0'./s3 -e 'slave stop io_thread; slave start'echo ""echo "inserting a record. The number of 'NO' should increase"./m -vvv -e 'insert into test.t1 values (3)'./m -e "$I_S_Q"echo ""echo "enabling semi-synch replication in slave 2"./s2 -e 'set global rpl_semi_sync_slave_enabled=1'./s2 -e 'slave stop io_thread; slave start'echo ""echo "inserting a record. The number of 'YES' should increase"./m -e 'insert into test.t1 values (4)'./m -e "$I_S_Q"This script will first disable semi-synchronous replication in all the slaves except one. Then it will create a table, and check for the telling status variables.This should work quickly and without problems. Then it will disable the plugin on the only slave that was active, and enable another slave instead. Inserting a record on the master will work again quickly, as the newly enabled slave will get the record immediately.Then the slave gets disabled, and we can witness what happens. The query takes a bit longer than 10 seconds, and the status variable tells us that semi-synchronous replication has failed.We finally enable yet another slave, and when we try a further insertion, we can see that the semi-synchronous replication has resumed.Very important:To enable or disable semi-synchronous replication on a slave it is not enough to set the appropriate variable. You need also to restart the slave by issuing a STOP SLAVE IO_THREAD followed by a START SLAVE commands.Here is a sample run:disabling semi-synch replication in all slaves except 1creating a table. it should replicate through the semi-synch--------------create table test.t1( i int)--------------Query OK, 0 rows affected (0.87 sec)Bye+-----------------------------+----------------+&#124; variable_name               &#124; variable_value &#124;+-----------------------------+----------------+&#124; RPL_SEMI_SYNC_MASTER_NO_TX  &#124; 0              &#124;&#124; RPL_SEMI_SYNC_MASTER_YES_TX &#124; 1              &#124;+-----------------------------+----------------+inserting a record. The number of 'YES' should increase+-----------------------------+----------------+&#124; variable_name               &#124; variable_value &#124;+-----------------------------+----------------+&#124; RPL_SEMI_SYNC_MASTER_NO_TX  &#124; 0              &#124;&#124; RPL_SEMI_SYNC_MASTER_YES_TX &#124; 2              &#124;+-----------------------------+----------------+disabling semi-synch replication in slave 1enabling semi-synch replication in slave 3inserting a record. The number of 'YES' should increase+-----------------------------+----------------+&#124; variable_name               &#124; variable_value &#124;+-----------------------------+----------------+&#124; RPL_SEMI_SYNC_MASTER_NO_TX  &#124; 0              &#124;&#124; RPL_SEMI_SYNC_MASTER_YES_TX &#124; 3              &#124;+-----------------------------+----------------+disabling semi-synch replication in slave 3inserting a record. The number of 'NO' should increase--------------insert into test.t1 values (3)--------------Query OK, 1 row affected (10.12 sec)Bye+-----------------------------+----------------+&#124; variable_name               &#124; variable_value &#124;+-----------------------------+----------------+&#124; RPL_SEMI_SYNC_MASTER_NO_TX  &#124; 1              &#124;&#124; RPL_SEMI_SYNC_MASTER_YES_TX &#124; 3              &#124;+-----------------------------+----------------+enabling semi-synch replication in slave 2inserting a record. The number of 'YES' should increase+-----------------------------+----------------+&#124; variable_name               &#124; variable_value &#124;+-----------------------------+----------------+&#124; RPL_SEMI_SYNC_MASTER_NO_TX  &#124; 1              &#124;&#124; RPL_SEMI_SYNC_MASTER_YES_TX &#124; 4              &#124;+-----------------------------+----------------+Using the above steps, you should be able to use semi-synchronous replication and do some basic monitoring to make sure that it works as expected.]]></description>
			<content:encoded><![CDATA[A few days ago I saw an article about <a href="http://www.bluegecko.net/mysql/semi-synchronous-replication-in-mysql-5-5/">Semi-Synchronous Replication in MySQL 5.5</a>. It asks questions, and doesn't give answers beyond gut feeling. So I thought that I would do some practical testing of this new feature.<br />Before we go that way, though, let's revisit the theory.<br /><h3>How semi-synchronous replication works</h3><img border="0" src="http://lh6.ggpht.com/_gVfZHGgf5LA/TNHwuuWOkgI/AAAAAAAAA-k/kdhEL_WL1do/s640/scaling_with_replication.065.jpg" /><br /><i>Figure 1. A transaction with regular replication</i><br />With regular replication, you send a transaction to the master (1). When the <code>COMMIT</code> is received, the master executes it (2), and if successful it logs the transaction to the binary log (3). The the master answers the client request (4) with a successful result. In the meantime, the slaves replicate the record (5).<br />What happens if the master crashes after point #4 and before a slave has had a chance of getting the data in point #5?<br />The client will have a result for that transaction, but that data is lost, because it has never reached one slave. <br /><br /><img border="0" src="http://lh6.ggpht.com/_gVfZHGgf5LA/TNHwuuDum0I/AAAAAAAAA-o/kSWM5ux2f6c/s640/scaling_with_replication.066.jpg" /><br /><i>Figure 2. A transaction with semi-synchronous replication</i><br /><br />Let's see the same scenario with semi-synchronous replication. All is the same until point #3. Then, things change. The master does not return to the client. Instead, it alerts the slave that a transaction is available (4). The slave gets it and stores it to the relay log (5). Without further action, the slave tells the master that the transaction was received (6) and only then the master returns the result to the client (7).<br />What is the benefit? If the master crashes, the transaction is lost. but the client does not get the false information that the transaction was stored. Instead, if the master crashes before it returns the result to the client, the client gets an error, and knows that that transaction needs to be reworked when a new master is back.<br /><h3>Semi-synchronous replication in practice</h3>Now, the practicalities.<br />How do you tell if semi-synchronous replication is working? If you leave the default timeout of 10 seconds, you have an immediate clue that something is wrong when a query takes too long to return. Investigation is possible by looking at the GLOBAL STATUS variables.<br /><code>Rpl_semi_sync_master_status</code> tells you if the master is ready for semi-synchronous replication.<br /><code>Rpl_semi_sync_master_yes_tx</code> is the number of positive transactions that were delivered using semi-synchronous replication.<br /><code>Rpl_semi_sync_master_no_tx</code> is the number of failed attempts at delivering a transaction via semi-synchronous replication. When that happens, <code>Rpl_semi_sync_master_status</code> becomes "OFF", and you need investigating.<br /><br />The important thing to understand about this feature is that semi-synchronous replication does not guarantee that your transaction is executed in the slave. It will only tell you that the data has been transferred to the slave relay log. It can still happen that the transaction fails to execute on the slave (which could be either a bug in your application or a bug in MySQL replication). But this is not a cluster. Don't expect a two-phase commit.<br /><h3>Testing semi-synchronous replication</h3>If you want to test this feature without suffering too much, you can use a tarball binary and <a href="http://mysqlsandbox.net/">MySQL Sandbox</a>. Once you have installed MySQL Sandbox and have downloaded the server tarball, you can install a test replication system with<br /><pre><code>make_replication_sandbox --how_many_slaves=4 /path/to/mysql-5.5.6-yourOS.tar.gz</code></pre>This will create a system with 1 master and 4 slaves.<br />The Sandbox has a shortcut to install the plugin quickly and painlessly:<br /><pre><code>sbtool -o plugin --plugin=semisynch -s $HOME/sandboxes/rsandbox_5_5_6</code></pre>Now you will have the semi-synchronous plugin installed in the master and all the slaves. For our tests, we will make a shell script, an easy task thanks to the sandbox utilities.<br /><pre><code><br />#!/bin/sh<br /><br />echo "disabling semi-synch replication in all slaves except 1"<br />./s1 -e 'set global rpl_semi_sync_slave_enabled=1'<br />./s1 -e 'slave stop io_thread; slave start'<br /><br />for E in 2 3 4<br />do<br />    ./s$E -e 'set global rpl_semi_sync_slave_enabled=0'<br />    ./s$E -e 'slave stop io_thread; slave start'<br />done<br /><br />#<br /># this query will show the main variables that tell<br /># if semi-synch replication is working<br />#<br />Q1='select variable_name, variable_value'<br />Q2='from information_schema.global_status'<br />Q3='where variable_name in'<br />Q4='("RPL_SEMI_SYNC_MASTER_YES_TX", "RPL_SEMI_SYNC_MASTER_NO_TX")'<br />I_S_Q="$Q1 $Q2 $Q3 $Q4"<br /><br />echo ""<br />echo "creating a table. it should replicate through the semi-synch"<br />./m -vvv -e 'create table test.t1( i int)'<br />./m -e "$I_S_Q"<br /><br />echo ""<br />echo "inserting a record. The number of 'YES' should increase"<br />./m -e 'insert into test.t1 values (1)'<br />./m -e "$I_S_Q"<br /><br />echo ""<br />echo "disabling semi-synch replication in slave 1"<br />./s1 -e 'set global rpl_semi_sync_slave_enabled=0'<br />./s1 -e 'slave stop io_thread; slave start'<br /><br />echo ""<br />echo "enabling semi-synch replication in slave 3"<br />./s3 -e 'set global rpl_semi_sync_slave_enabled=1'<br />./s3 -e 'slave stop io_thread; slave start'<br /><br />echo ""<br />echo "inserting a record. The number of 'YES' should increase"<br />./m -e 'insert into test.t1 values (2)'<br />./m -e "$I_S_Q"<br /><br />echo ""<br />echo "disabling semi-synch replication in slave 3"<br />./s3 -e 'set global rpl_semi_sync_slave_enabled=0'<br />./s3 -e 'slave stop io_thread; slave start'<br /><br />echo ""<br />echo "inserting a record. The number of 'NO' should increase"<br />./m -vvv -e 'insert into test.t1 values (3)'<br />./m -e "$I_S_Q"<br /><br />echo ""<br />echo "enabling semi-synch replication in slave 2"<br />./s2 -e 'set global rpl_semi_sync_slave_enabled=1'<br />./s2 -e 'slave stop io_thread; slave start'<br /><br />echo ""<br />echo "inserting a record. The number of 'YES' should increase"<br />./m -e 'insert into test.t1 values (4)'<br />./m -e "$I_S_Q"<br /><code></code></code></pre>This script will first disable semi-synchronous replication in all the slaves except one. Then it will create a table, and check for the telling status variables.<br />This should work quickly and without problems. Then it will disable the plugin on the only slave that was active, and enable another slave instead. <br />Inserting a record on the master will work again quickly, as the newly enabled slave will get the record immediately.<br />Then the slave gets disabled, and we can witness what happens. The query takes a bit longer than 10 seconds, and the status variable tells us that semi-synchronous replication has failed.<br />We finally enable yet another slave, and when we try a further insertion, we can see that the semi-synchronous replication has resumed.<br /><br /><b>Very important:</b><br />To enable or disable semi-synchronous replication on a slave it is not enough to set the appropriate variable. You need also to restart the slave by issuing a <code>STOP SLAVE IO_THREAD</code> followed by a <code>START SLAVE</code> commands.<br /><br />Here is a sample run:<br /><pre>disabling semi-synch replication in all slaves except 1<br /><br />creating a table. it should replicate through the semi-synch<br />--------------<br />create table test.t1( i int)<br />--------------<br /><br />Query OK, 0 rows affected (0.87 sec)<br /><br />Bye<br />+-----------------------------+----------------+<br />| variable_name               | variable_value |<br />+-----------------------------+----------------+<br />| RPL_SEMI_SYNC_MASTER_NO_TX  | 0              |<br />| RPL_SEMI_SYNC_MASTER_YES_TX | 1              |<br />+-----------------------------+----------------+<br /><br />inserting a record. The number of 'YES' should increase<br />+-----------------------------+----------------+<br />| variable_name               | variable_value |<br />+-----------------------------+----------------+<br />| RPL_SEMI_SYNC_MASTER_NO_TX  | 0              |<br />| RPL_SEMI_SYNC_MASTER_YES_TX | 2              |<br />+-----------------------------+----------------+<br /><br />disabling semi-synch replication in slave 1<br /><br />enabling semi-synch replication in slave 3<br /><br />inserting a record. The number of 'YES' should increase<br />+-----------------------------+----------------+<br />| variable_name               | variable_value |<br />+-----------------------------+----------------+<br />| RPL_SEMI_SYNC_MASTER_NO_TX  | 0              |<br />| RPL_SEMI_SYNC_MASTER_YES_TX | 3              |<br />+-----------------------------+----------------+<br /><br />disabling semi-synch replication in slave 3<br /><br />inserting a record. The number of 'NO' should increase<br />--------------<br />insert into test.t1 values (3)<br />--------------<br /><br />Query OK, 1 row affected (10.12 sec)<br /><br />Bye<br />+-----------------------------+----------------+<br />| variable_name               | variable_value |<br />+-----------------------------+----------------+<br />| RPL_SEMI_SYNC_MASTER_NO_TX  | 1              |<br />| RPL_SEMI_SYNC_MASTER_YES_TX | 3              |<br />+-----------------------------+----------------+<br /><br />enabling semi-synch replication in slave 2<br /><br />inserting a record. The number of 'YES' should increase<br />+-----------------------------+----------------+<br />| variable_name               | variable_value |<br />+-----------------------------+----------------+<br />| RPL_SEMI_SYNC_MASTER_NO_TX  | 1              |<br />| RPL_SEMI_SYNC_MASTER_YES_TX | 4              |<br />+-----------------------------+----------------+<br /></pre>Using the above steps, you should be able to use semi-synchronous replication and do some basic monitoring to make sure that it works as expected.<div><img width="1" height="1" src="https://blogger.googleusercontent.com/tracker/16959946-7211354341709462617?l=datacharmer.blogspot.com" alt="" /></div><br/>PlanetMySQL Voting:
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=26369&vote=1&apivote=1">Vote UP</a> /
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=26369&vote=-1&apivote=1">Vote DOWN</a>]]></content:encoded>
			<wfw:commentRss>http://planetmysql.ru/2010/11/04/testing-mysql-5-5-semi-synchronous-replication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Sandbox now with plugins, more tests, instrumentation</title>
		<link>http://datacharmer.blogspot.com/2010/05/mysql-sandbox-now-with-plugins-more.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mysql-sandbox-now-with-plugins-more-tests-instrumentation</link>
		<comments>http://datacharmer.blogspot.com/2010/05/mysql-sandbox-now-with-plugins-more.html#comments</comments>
		<pubDate>Sun, 30 May 2010 19:01:00 +0000</pubDate>
		<dc:creator>Giuseppe Maxia</dc:creator>
				<category><![CDATA[InnoDB]]></category>
		<category><![CDATA[instrumentation]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[sandbox]]></category>
		<category><![CDATA[semisynch]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[The latest release of MySQL Sandbox, 3.0.12, has integrated plugin installation features, as mentioned in my previous post.Not only that. This version has also more tests, fixes a couple of bugs, and introduces basic instrumentation. Now each script released with MySQL Sandbox, and every one that the Sandbox itself installs, can leave a trail in a file.Let's start with the plugin. The documentation has been updated to cover this new feature. And 27 new tests give me some confidence that it should work as advertised.While I was waiting for the test suite to finish its 238 tests, I was wondering how much was going on under the hood. So I spent one hour implementing some basic instrumentation, not only in the make_* scripts, but also in every script that the sandbox installs. The code is quite modular, and adding this feature was easy.Now, if you want to use this instrumentation, you need to create a file, and set the operating system variable $SBINSTR to the full path of that file prior to using the Sandbox. Then, every script will leave an entry in that file, saying its name, the current time, and which parameters was using.This is what I got after running the test suite. 66 instances of MySQL installed to perform over 200 tests, in about 18 minutes.MySQL Sandbox scriptscallsmake_sandbox   66low_level_make_sandbox   66make_replication_sandbox   8make_multiple_sandbox   7make_multiple_custom_sandbox   2Installed scriptscallsuse   440stop   192start   128clear   56sandbox_action   56sbtool   34stop_all   30use_all   20clear_all   13start_all   12send_kill   11restart   9initialize_slaves   8restart_all   4change_paths   2change_ports   1total  1165The new release is available from Launchpad or directly from the CPAN]]></description>
			<content:encoded><![CDATA[<table border="0"><tbody><tr><td><a href="http://mysqlsandbox.net/"><img src="http://lh4.ggpht.com/_gVfZHGgf5LA/TAK1xS5wedI/AAAAAAAAA6o/Y56lSG4fbFY/sandbox_instrument_small_detail.png" alt="MySQL Sandbox" title="MySQL Sandbox instrumentation" border="0" width="300" /></a></td><td>The latest release of <a href="http://mysqlsandbox.net/">MySQL Sandbox</a>, 3.0.12, has integrated plugin installation features, as mentioned in my previous <a href="http://datacharmer.blogspot.com/2010/05/mysql-sandbox-meets-plugins.html">post</a>.<br />Not only that. This version has also more tests, fixes a couple of bugs, and introduces basic instrumentation. Now each script released with MySQL Sandbox, and every one that the Sandbox itself installs, can leave a trail in a file.<br /></td></tr></tbody></table><br />Let's start with the plugin. The <a href="http://search.cpan.org/~gmax/MySQL-Sandbox-3.0.12/lib/MySQL/Sandbox.pm#sbtool_-o_plugin">documentation</a> has been updated to cover this new feature. And 27 new tests give me some confidence that it should work as advertised.<br />While I was waiting for the test suite to finish its 238 tests, I was wondering how much was going on under the hood. So I spent one hour implementing some basic instrumentation, not only in the <code>make_*</code> scripts, but also in every script that the sandbox installs. The code is quite modular, and adding this feature was easy.<br />Now, if you want to use this instrumentation, you need to create a file, and set the operating system variable <code>$SBINSTR</code> to the full path of that file prior to using the Sandbox. Then, every script will leave an entry in that file, saying its name, the current time, and which parameters was using.<br />This is what I got after running the test suite. 66 instances of MySQL installed to perform over 200 tests, in about 18 minutes.<br /><table border="1"><br /><tbody><tr><th align="left">MySQL Sandbox scripts</th><th>calls</th></tr><tr><td>make_sandbox </td> <td align="right"> 66</td></tr><tr><td>low_level_make_sandbox </td> <td align="right"> 66</td></tr><tr><td>make_replication_sandbox </td> <td align="right"> 8</td></tr><tr><td>make_multiple_sandbox </td> <td align="right"> 7</td></tr><tr><td>make_multiple_custom_sandbox </td> <td align="right"> 2</td></tr><br /><tr><th align="left">Installed scripts</th><th>calls</th></tr><tr><td>use </td> <td align="right"> 440</td></tr><tr><td>stop </td> <td align="right"> 192</td></tr><tr><td>start </td> <td align="right"> 128</td></tr><tr><td>clear </td> <td align="right"> 56</td></tr><tr><td>sandbox_action </td> <td align="right"> 56</td></tr><tr><td>sbtool </td> <td align="right"> 34</td></tr><tr><td>stop_all </td> <td align="right"> 30</td></tr><tr><td>use_all </td> <td align="right"> 20</td></tr><tr><td>clear_all </td> <td align="right"> 13</td></tr><tr><td>start_all </td> <td align="right"> 12</td></tr><tr><td>send_kill </td> <td align="right"> 11</td></tr><tr><td>restart </td> <td align="right"> 9</td></tr><tr><td>initialize_slaves </td> <td align="right"> 8</td></tr><tr><td>restart_all </td> <td align="right"> 4</td></tr><tr><td>change_paths </td> <td align="right"> 2</td></tr><tr><td>change_ports </td> <td align="right"> 1</td></tr><tr><th align="left">total</th> <th align="right"> 1165</th></tr></tbody></table><br />The new release is available from <a href="http://launchpad.net/mysql-sandbox">Launchpad</a> or directly from the <a href="http://search.cpan.org/~gmax/MySQL-Sandbox-3.0.12/">CPAN</a><div><img width="1" height="1" src="https://blogger.googleusercontent.com/tracker/16959946-7929248491486139547?l=datacharmer.blogspot.com" alt="" /></div><br/>PlanetMySQL Voting:
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=24899&vote=1&apivote=1">Vote UP</a> /
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=24899&vote=-1&apivote=1">Vote DOWN</a>]]></content:encoded>
			<wfw:commentRss>http://planetmysql.ru/2010/05/30/mysql-sandbox-now-with-plugins-more-tests-instrumentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Sandbox meets plugins</title>
		<link>http://datacharmer.blogspot.com/2010/05/mysql-sandbox-meets-plugins.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mysql-sandbox-meets-plugins</link>
		<comments>http://datacharmer.blogspot.com/2010/05/mysql-sandbox-meets-plugins.html#comments</comments>
		<pubDate>Mon, 24 May 2010 20:32:00 +0000</pubDate>
		<dc:creator>Giuseppe Maxia</dc:creator>
				<category><![CDATA[Installation]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[plugin.innodb]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[sandbox]]></category>
		<category><![CDATA[semisynch]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I saw it coming.In the past year I have been working more and more with plugins. The InnoDB plugins, the semi-synchronous replication plugins, the Gearman UDFs, the Spider plugins, and every time I found myself doing a long installation process, with inevitable mistakes.So I told myself "I wish I had a tool that installed plugins instantly and painlessly, the way MySQL Sandbox installs a server.There you go. So yesterday I had enough of suffering and have put together an installation script that does a good job of installing several plugins with little or no effort.OverviewHow does it work? For now, it's a separate script, but it will soon end into SBtool, the Sandbox tool. Plugins need different operations, and the difficult part is finding a clear way of describing what you want to do, and how. But once you have come up with that set of instructions, there is seldom need to revisit it.So the principle is th create a set of templates, one for every plugin, where you explain to the installation script what you want to do.Having installed several plugins repeatedly in several versions of MySQL, I now have a good understanding of the process, and having gone through the motions of explaining the procedure to a Perl script, I feel that I know the process even more. That is, if you want to understand a process, script it. For if you want to script a process, you really need to understand what's going on.The templateThe template was not easy to write. After some bargaining with myself, I decided that the best format was Perl itself. Let's see, for example, the InnoDB plugininnodb =&#62;    {    all_servers =&#62;         {        operation_sequence =&#62; [qw(stop options_file start sql_commands )],        options_file =&#62;             [            'ignore_builtin_innodb',            'plugin-load='             .'innodb=ha_innodb_plugin.so;'             .'innodb_trx=ha_innodb_plugin.so;'             .'innodb_locks=ha_innodb_plugin.so;'             .'innodb_lock_waits=ha_innodb_plugin.so;'             .'innodb_cmp=ha_innodb_plugin.so;'             .'innodb_cmp_reset=ha_innodb_plugin.so;'             .'innodb_cmpmem=ha_innodb_plugin.so;'             .'innodb_cmpmem_reset=ha_innodb_plugin.so',            'default-storage-engine=InnoDB',            'innodb_file_per_table=1',            'innodb_file_format=barracuda',            'innodb_strict_mode=1',            ],        sql_commands =&#62;             [                'select @@innodb_version;',            ],        startup_file =&#62; [ ],        },    },The first thing that you notice is that there is an all_servers section. This means that any server can get the same treatment, as opposed to the semi-synchronous plugin, where master and slave need different plugins and commands.Then comes the operation_sequence, where we decide the order of the operations.Inside options_file we put the commands that we want inside a my.cnf. The sql_commands section has a list of queries that the script runs when instructed.semisynch =&#62; {    master =&#62;         {            operation_sequence =&#62; [qw(stop options_file start sql_commands )],            options_file =&#62;                 [                'plugin-load=rpl_semi_sync_master=semisync_master.so',                'rpl_semi_sync_master_enabled=1'                ],            sql_commands =&#62;                 [                    'select @@rpl_semi_sync_master_enabled;'                ],            startup_file =&#62; []        },    slave =&#62;         {            operation_sequence =&#62; [qw(stop options_file start sql_commands )],            options_file =&#62;                 [                'plugin-load=rpl_semi_sync_slave=semisync_slave.so',                'rpl_semi_sync_slave_enabled=1'                ],            sql_commands =&#62;                 [                    'select @@rpl_semi_sync_slave_enabled;'                ],            startup_file =&#62; []        },    },By contrast, the semisynch plugin looks comparatively more complex, with its two sections for master and slave. But as you look closely, you recognize the two operations described in the manual, and you feel that you could deal with them easily.The scriptThe script was not much difficult to write. Since it only works with MySQL Sandbox instances, it leverages on the predictability of each server.There is quite a lot of complexity inside, though, because the script checks every possible source of trouble before actually running the instructions from the template.The script needs two parameters: a directory containin a sandbox, and the name of the plugin. It expects the plugin definition template (named plugin.conf to be in the destination directory, or in the $SANDBOX_HOME directory.It recognizes if the target path is a single or multiple sandbox. If it is multiple, it installs the given plugin in every server. It also recognizes if the server is a master or a slave, and pulls the appropriate section from the template when required.$  perl set_plugin.pl $HOME/sandboxes/rsandbox_5_1_47 innodbexecuting "stop" on slave 1executing "stop" on slave 2executing "stop" on masterInstalling &#60;innodb&#62; in &#60;/$HOME/sandboxes/rsandbox_5_1_47/master/&#62;. sandbox server started--------------select @@innodb_version--------------+------------------+&#124; @@innodb_version &#124;+------------------+&#124; 1.0.8            &#124;+------------------+1 row in set (0.00 sec)ByeInstalling &#60;innodb&#62; in &#60;/$HOME/sandboxes/rsandbox_5_1_47/node1/&#62;. sandbox server started--------------select @@innodb_version--------------+------------------+&#124; @@innodb_version &#124;+------------------+&#124; 1.0.8            &#124;+------------------+1 row in set (0.00 sec)ByeInstalling &#60;innodb&#62; in &#60;/$HOME/sandboxes/rsandbox_5_1_47/node2/&#62;.. sandbox server started--------------select @@innodb_version--------------+------------------+&#124; @@innodb_version &#124;+------------------+&#124; 1.0.8            &#124;+------------------+1 row in set (0.00 sec)Now there is no excuse for testing servers with plugins. There is still some TODO, most notably testing, fixing conflicts that may happen when two plugins fight for the same plugin-load statement, and integrating with sbtool, as said before. But for now, it is enough.You can try i, by using the script and the template]]></description>
			<content:encoded><![CDATA[<table border="0"><tr><td><a href="http://mysqlsandbox.net"><img src="http://lh5.ggpht.com/_gVfZHGgf5LA/S_rWmxvTtzI/AAAAAAAAA6Y/PzZr1gzKxmk/s640/sandbox_plug.png" alt="Sandbox and plugins" title="MySQL Sandbox and plugins" border="0" width="300" /></a></td><td>I saw it coming.<br />In the past year I have been working more and more with plugins. The InnoDB plugins, the semi-synchronous replication plugins, the Gearman UDFs, the Spider plugins, and every time I found myself doing a long installation process, with inevitable mistakes.</td></tr></table><br />So I told myself "I wish I had a tool that installed plugins instantly and painlessly, the way MySQL Sandbox installs a server.<br />There you go. So yesterday I had enough of suffering and have put together an installation script that does a good job of installing several plugins with little or no effort.<br /><h3>Overview</h3>How does it work? For now, it's a separate script, but it will soon end into SBtool, the Sandbox tool. <br />Plugins need different operations, and the difficult part is finding a clear way of describing what you want to do, and how. But once you have come up with that set of instructions, there is seldom need to revisit it.<br />So the principle is th create a set of templates, one for every plugin, where you explain to the installation script what you want to do.<br />Having installed several plugins repeatedly in several versions of MySQL, I now have a good understanding of the process, and having gone through the motions of explaining the procedure to a Perl script, I feel that I know the process even more. That is, if you want to understand a process, script it. For if you want to script a process, you really need to understand what's going on.<br /><h3>The template</h3><br />The template was not easy to write. After some bargaining with myself, I decided that the best format was Perl itself. <br />Let's see, for example, the InnoDB plugin<br /><pre><code><br />innodb =>    {<br />    all_servers => <br />        {<br />        operation_sequence => [qw(stop options_file start sql_commands )],<br />        options_file => <br />            [<br />            'ignore_builtin_innodb',<br />            'plugin-load='<br />             .'innodb=ha_innodb_plugin.so;'<br />             .'innodb_trx=ha_innodb_plugin.so;'<br />             .'innodb_locks=ha_innodb_plugin.so;'<br />             .'innodb_lock_waits=ha_innodb_plugin.so;'<br />             .'innodb_cmp=ha_innodb_plugin.so;'<br />             .'innodb_cmp_reset=ha_innodb_plugin.so;'<br />             .'innodb_cmpmem=ha_innodb_plugin.so;'<br />             .'innodb_cmpmem_reset=ha_innodb_plugin.so',<br />            'default-storage-engine=InnoDB',<br />            'innodb_file_per_table=1',<br />            'innodb_file_format=barracuda',<br />            'innodb_strict_mode=1',<br />            ],<br />        sql_commands => <br />            [<br />                'select @@innodb_version;',<br />            ],<br />        startup_file => [ ],<br />        },<br />    },<br /></code></pre><br />The first thing that you notice is that there is an <i>all_servers</i> section. This means that any server can get the same treatment, as opposed to the semi-synchronous plugin, where master and slave need different plugins and commands.<br />Then comes the <i>operation_sequence</i>, where we decide the order of the operations.<br />Inside <i>options_file</i> we put the commands that we want inside a my.cnf. <br />The <i>sql_commands</i> section has a list of queries that the script runs when instructed.<br /><pre><code><br />semisynch => {<br />    master => <br />        {<br />            operation_sequence => [qw(stop options_file start sql_commands )],<br />            options_file => <br />                [<br />                'plugin-load=rpl_semi_sync_master=semisync_master.so',<br />                'rpl_semi_sync_master_enabled=1'<br />                ],<br />            sql_commands => <br />                [<br />                    'select @@rpl_semi_sync_master_enabled;'<br />                ],<br />            startup_file => []<br />        },<br />    slave => <br />        {<br />            operation_sequence => [qw(stop options_file start sql_commands )],<br />            options_file => <br />                [<br />                'plugin-load=rpl_semi_sync_slave=semisync_slave.so',<br />                'rpl_semi_sync_slave_enabled=1'<br />                ],<br />            sql_commands => <br />                [<br />                    'select @@rpl_semi_sync_slave_enabled;'<br />                ],<br />            startup_file => []<br />        },<br />    },<br /></code></pre><br />By contrast, the <i>semisynch</i> plugin looks comparatively more complex, with its two sections for <i>master</i> and <i>slave</i>. But as you look closely, you recognize the two operations described in the manual, and you feel that you could deal with them easily.<br /><h3>The script</h3><br />The script was not much difficult to write. Since it only works with MySQL Sandbox instances, it leverages on the predictability of each server.<br />There is quite a lot of complexity inside, though, because the script checks every possible source of trouble before actually running the instructions from the template.<br />The script needs two parameters: a directory containin a sandbox, and the name of the plugin. It expects the plugin definition template (named <i>plugin.conf</i> to be in the destination directory, or in the $SANDBOX_HOME directory.<br />It recognizes if the target path is a single or multiple sandbox. If it is multiple, it installs the given plugin in every server. It also recognizes if the server is a master or a slave, and pulls the appropriate section from the template when required.<br /><pre><code><br />$  perl set_plugin.pl $HOME/sandboxes/rsandbox_5_1_47 innodb<br />executing "stop" on slave 1<br />executing "stop" on slave 2<br />executing "stop" on master<br />Installing &lt;innodb&gt; in &lt;/$HOME/sandboxes/rsandbox_5_1_47/master/&gt;<br />. sandbox server started<br />--------------<br />select @@innodb_version<br />--------------<br /><br />+------------------+<br />| @@innodb_version |<br />+------------------+<br />| 1.0.8            |<br />+------------------+<br />1 row in set (0.00 sec)<br /><br />Bye<br />Installing &lt;innodb&gt; in &lt;/$HOME/sandboxes/rsandbox_5_1_47/node1/&gt;<br />. sandbox server started<br />--------------<br />select @@innodb_version<br />--------------<br /><br />+------------------+<br />| @@innodb_version |<br />+------------------+<br />| 1.0.8            |<br />+------------------+<br />1 row in set (0.00 sec)<br /><br />Bye<br />Installing &lt;innodb&gt; in &lt;/$HOME/sandboxes/rsandbox_5_1_47/node2/&gt;<br />.. sandbox server started<br />--------------<br />select @@innodb_version<br />--------------<br /><br />+------------------+<br />| @@innodb_version |<br />+------------------+<br />| 1.0.8            |<br />+------------------+<br />1 row in set (0.00 sec)<br /></code></pre><br />Now there is no excuse for testing servers with plugins. <br />There is still some TODO, most notably testing, fixing conflicts that may happen when two plugins fight for the same <i>plugin-load</i> statement, and integrating with sbtool, as said before. But for now, it is enough.<br />You can try i, by using the <a href="http://bazaar.launchpad.net/~giuseppe-maxia/mysql-sandbox/mysql-sandbox-3/annotate/head%3A/drafts/set_plugin.pl">script</a> and the <a href="http://bazaar.launchpad.net/~giuseppe-maxia/mysql-sandbox/mysql-sandbox-3/annotate/head%3A/drafts/plugin.conf">template</a><div><img width="1" height="1" src="https://blogger.googleusercontent.com/tracker/16959946-8673873908787070636?l=datacharmer.blogspot.com" alt="" /></div><br/>PlanetMySQL Voting:
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=24849&vote=1&apivote=1">Vote UP</a> /
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=24849&vote=-1&apivote=1">Vote DOWN</a>]]></content:encoded>
			<wfw:commentRss>http://planetmysql.ru/2010/05/25/mysql-sandbox-meets-plugins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

