mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
Replication: new code to not modify in-memory log positions until the COMMIT
is executed, even if the transaction spans on >=2 relay logs (bug #53). New variable relay_log_purge =0|1 New test to verify bug #53 sql/log.cc: Now we purge a relay log only when we are sure we won't need it, i.e. we have executed the final query (if autocommit=1) or the COMMIT. sql/log_event.cc: Better tracking of the relay log's name and position lastly executed, even if we are in a transaction which spans on 2 or more relay logs. sql/mysql_priv.h: new option relay_log_purge (the user can now decide himself if he wants his relay logs to be automatically purged or not, we don't make unsafe guesses like before) sql/mysqld.cc: new option --innodb (replaces --skip-innodb). Useful for the test suite : we have skip-innodb in mysql-test-run, but we can ('-opt.info' file) choose to start the server with InnoDB for this test only. New option --bdb sql/repl_failsafe.cc: Better tracking of the relay log's name and position lastly executed, even if we are in a transaction which spans on 2 or more relay logs. sql/set_var.cc: new variable relay_log_purge sql/slave.cc: Better tracking of the relay log's name and position lastly executed, even if we are in a transaction which spans on 2 or more relay logs. Now we purge a relay log only when we are sure we won't need it, i.e. we have executed the final query (if autocommit=1) or the COMMIT sql/slave.h: Better tracking of the relay log's name and position lastly executed, even if we are in a transaction which spans on 2 or more relay logs. sql/sql_class.h: prototypes change sql/sql_parse.cc: removed thd argument (was not used in the function's body) sql/sql_repl.cc: Better tracking of the relay log's name and position lastly executed, even if we are in a transaction which spans on 2 or more relay logs. Turn relay_log_purge silently off when someone does CHANGE MASTER TO RELAY_LOG_*
This commit is contained in:
61
mysql-test/t/rpl_relayrotate.test
Normal file
61
mysql-test/t/rpl_relayrotate.test
Normal file
@@ -0,0 +1,61 @@
|
||||
# When the relay log gets rotated while the I/O thread
|
||||
# is reading a transaction, the transaction spans on two or more
|
||||
# relay logs. If STOP SLAVE occurs while the SQL thread is
|
||||
# executing a part of the transaction in the non-first relay logs,
|
||||
# we test if START SLAVE will resume in the beginning of the
|
||||
# transaction (i.e., step back to the first relay log)
|
||||
|
||||
# The slave is started with max_binlog_size=16384 bytes,
|
||||
# to force many rotations (approximately 30 rotations)
|
||||
|
||||
# If the master or slave does not support InnoDB, this test will pass
|
||||
|
||||
source include/master-slave.inc;
|
||||
connection slave;
|
||||
stop slave;
|
||||
connection master;
|
||||
create table t1 (a int) type=innodb;
|
||||
let $1=8000;
|
||||
disable_query_log;
|
||||
begin;
|
||||
while ($1)
|
||||
{
|
||||
# eval means expand $ expressions
|
||||
eval insert into t1 values( $1 );
|
||||
dec $1;
|
||||
}
|
||||
commit;
|
||||
# This will generate a 500kB master's binlog,
|
||||
# which corresponds to 30 slave's relay logs.
|
||||
enable_query_log;
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
reset slave;
|
||||
start slave;
|
||||
# We wait 1 sec for the SQL thread to be somewhere in
|
||||
# the middle of the transaction, hopefully not in
|
||||
# the first relay log, and hopefully before the COMMIT.
|
||||
# Usually it stops when the SQL thread is around the 15th relay log.
|
||||
# We cannot use MASTER_POS_WAIT() as master's position
|
||||
# increases only when the slave executes the COMMIT.
|
||||
system sleep 1;
|
||||
stop slave;
|
||||
# We suppose the SQL thread stopped before COMMIT.
|
||||
# If so the transaction was rolled back
|
||||
# and the table is now empty.
|
||||
# Now restart
|
||||
start slave;
|
||||
# And see if the table contains '8000'
|
||||
# which proves that the transaction restarted at
|
||||
# the right place.
|
||||
# We must wait for the transaction to commit before
|
||||
# reading, MASTER_POS_WAIT() will do it for sure
|
||||
# (the only statement with position>=3000 is COMMIT).
|
||||
# Older versions of MySQL would hang forever in MASTER_POS_WAIT
|
||||
# because COMMIT was said to be position 0 in the master's log (bug).
|
||||
# Detect this with timeout.
|
||||
select master_pos_wait('master-bin.001',3000,120)=-1;
|
||||
select * from t1 where a=8000;
|
||||
# Note that the simple fact to have less than around 30 slave's binlogs
|
||||
# (the slave is started with --log-slave-updates) is already
|
||||
# a proof that the transaction was not properly resumed.
|
||||
Reference in New Issue
Block a user