Re: second version of proposed patch for delayed replication (Bug#28760)
Hi Kay.
What's the master_delay global variable for? Here's how I see it
used, with "grep".
+uint32 master_delay= 0;
+ mi->delay= master_delay;
+ /* added value of master_delay */
+ init_intvar_from_file(&delay, &mi->file, master_delay))
+extern uint32 master_delay;
Perhaps it's the first step in something you're planning to submit?
Since the patch came with no test, I took the time to create one.
Here's my first try of a test file.
I welcome ideas for new tests or implementations of the ideas at the
end. I want to prove that there are no bugs or unexpected behavior
in adding this feature. Help!
> source include/master-slave.inc; > disable_warnings; > sync_slave_with_master; > reset master; > enable_warnings; > > > ## > # > # First test: Create a table, delay the slave, insert into the > master, and die > # if the slave presents that data before the delay has elapsed. > # > ## > > # This is an arbitrary value. Smaller means that the test could > yeild false > # passing results. Larger means unnecessary delay in the tests. > let $delay=5; > ### > > # Create work table > connection master; > drop table if exists delay_test; > create table delay_test ( c1 int ); > select count(*) as c from delay_test; > insert into delay_test values (1); > > # Wait until the table is replicated. (Just being paranoid.) > connection slave; > let $t = 0; > let $time_remaining = 60; > > disable_result_log; > error 0,ER_NO_SUCH_TABLE; > select count(*) as c from delay_test; > enable_result_log; > while ($mysql_errno == 1146) > { > if (!$time_remaining) > { > echo $t, $time_remaining; > exit; > die "Table DDL replication took more than a minute! $i"; > } > > sleep 1; > inc $t; > dec $time_remaining; > > disable_result_log; > error 0,ER_NO_SUCH_TABLE; > select count(*) as c from delay_test; > enable_result_log; > } > delete from delay_test; > > # While we're connected to the slave, verify that we can't change > the value > # without shutting it down. > error ER_SLAVE_MUST_STOP; > eval change master to master_delay=$delay; > > # Actually change the delay value. > stop slave; > eval change master to master_delay=$delay; > start slave; > > # Insert values into the master. > connection master; > delete from delay_test; > insert into delay_test values (1); > insert into delay_test values (2); > insert into delay_test values (3); > insert into delay_test values (4); > > connection slave; > let $elapsed = 0; > let $row_count = 0; > let $time_remaining = 60; > > # Assert that there is nothing in the table yet. > select c1 from delay_test order by c1; > > # Time how long it takes to arrive in the table. > while (!$row_count) > { > sleep 1; > let $row_count = query_get_value("select count(*) as c from > delay_test", c, 1); > inc $elapsed; > dec $time_remaining; > > if (!$time_remaining) > { > echo $row_count, $t, $time_remaining; > exit; > die "Replication delay test got out of hand. Aborting."; > } > } > select c1 from delay_test order by c1; > > # If the elapsed time is shorter than the delay, then the delay > didn't work. > if (`select $elapsed < $delay`) > { > echo $row_count, $t, $time_remaining; > echo "Failed! Statement showed up on master before delay had > elapsed."; > } > > # Clean up. > stop slave; > connection slave; > eval change master to master_delay=0; > start slave; > connection master; > drop table delay_test; > > ## > > > # Other tests that may be a good idea: Prove that one can: > # - Delay, stop the master, after delay elapsed start the master. > # - Delay, reduce the delay. > # - Delay, increase the delay. > # - Delay, remove the delay. > # - Replicate in a circle with a delay on one node. > # - Replicate in a circle with a delay on both nodes.
--
Chad Miller, Software Developer chad@mysql.com
MySQL Inc., www.mysql.com
Orlando, Florida, USA 13-20z, UTC-0400
Office: +1 408 213 6740 sip:6740@sip.mysql.com
(If it's not cryptographically signed, it's not from Chad)
Received on Fri Sep 7 10:58:24 2007
This archive was generated by hypermail 2.1.8
: Sun Oct 07 2007 - 07:59:20 EDT
|