1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

BUG#26395: if crash during autocommit update to transactional table on master, slave fails

Now, every transaction (including autocommit transactions) starts with
a BEGIN and ends with a COMMIT/ROLLBACK in the binlog.
Added a test case, and updated lots of test case result files.


mysql-test/r/multi_update.result:
  Updated result file
mysql-test/r/sp_trans_log.result:
  Updated result file
mysql-test/suite/binlog/r/binlog_innodb.result:
  Updated result file
mysql-test/suite/binlog/r/binlog_multi_engine.result:
  Updated result file
mysql-test/suite/binlog/r/binlog_stm_blackhole.result:
  Updated result file
mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result:
  Updated result file
mysql-test/suite/ndb/r/ndb_binlog_format.result:
  Updated result file
mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result:
  Updated result file
mysql-test/suite/rpl/r/rpl_row_charset_innodb.result:
  Updated result file
mysql-test/suite/rpl/r/rpl_row_create_table.result:
  Updated result file
mysql-test/suite/rpl/r/rpl_row_log_innodb.result:
  Updated result file
mysql-test/suite/rpl/r/rpl_switch_stm_row_mixed.result:
  Updated result file
mysql-test/suite/rpl/r/rpl_truncate_3innodb.result:
  Updated result file
mysql-test/suite/rpl/t/rpl_row_create_table.test:
  Updated result file
mysql-test/suite/rpl_ndb/r/rpl_ndb_stm_innodb.result:
  Updated result file
sql/log.cc:
   - Always write BEGIN and COMMIT around statements, even in autocommit
     mode.
   - Added comments for binlog_commit and binlog_rollback.
sql/log_event.cc:
  Added debug trigger to avoid writing xid events to the binlog.
mysql-test/suite/rpl_ndb/r/rpl_ndb_transaction.result:
  Results for new test case
mysql-test/suite/rpl_ndb/t/rpl_ndb_transaction-master.opt:
  Options for new test case
mysql-test/suite/rpl_ndb/t/rpl_ndb_transaction-slave.opt:
  Options for new test case
mysql-test/suite/rpl_ndb/t/rpl_ndb_transaction.test:
  Added new test case.
This commit is contained in:
unknown
2007-12-14 14:40:45 +01:00
parent 89a89950ae
commit 44efa9c18b
21 changed files with 542 additions and 64 deletions

View File

@ -22,11 +22,11 @@ from mysql.ndb_apply_status;
show binlog events from <start_pos> limit 1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 <start_pos> Query 1 # use `test`; insert into t1 values (1,2)
master-bin.000001 <start_pos> Query 1 # use `test`; BEGIN
show binlog events from <start_pos> limit 1,1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Xid 1 445 COMMIT /* XID */
master-bin.000001 # Query 1 486 use `test`; insert into t1 values (1,2)
begin;
insert into t1 values (2,3);

View File

@ -0,0 +1,140 @@
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
CREATE TABLE tmyisam (a int) ENGINE = MYISAM;
CREATE TABLE tinnodb (a int) ENGINE = INNODB;
CREATE TABLE tndb (a int) ENGINE = NDB;
SHOW CREATE TABLE tmyisam;
Table Create Table
tmyisam CREATE TABLE `tmyisam` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SHOW CREATE TABLE tinnodb;
Table Create Table
tinnodb CREATE TABLE `tinnodb` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SHOW CREATE TABLE tndb;
Table Create Table
tndb CREATE TABLE `tndb` (
`a` int(11) DEFAULT NULL
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
==== Test 1: Non-XA Engines ====
--- on master ---
SET AUTOCOMMIT = 1;
INSERT INTO tndb VALUES (1);
INSERT INTO tmyisam VALUES (1);
BEGIN;
INSERT INTO tndb VALUES (2);
INSERT INTO tndb VALUES (3);
COMMIT;
BEGIN;
INSERT INTO tmyisam VALUES (2);
INSERT INTO tmyisam VALUES (3);
COMMIT;
BEGIN;
INSERT INTO tndb VALUES (4);
INSERT INTO tmyisam VALUES (4);
COMMIT;
BEGIN;
INSERT INTO tndb VALUES (5);
INSERT INTO tndb VALUES (6);
ROLLBACK;
BEGIN;
INSERT INTO tmyisam VALUES (5);
INSERT INTO tmyisam VALUES (6);
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
INSERT INTO tndb VALUES (7);
INSERT INTO tmyisam VALUES (7);
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
SELECT * FROM tndb ORDER BY a;
a
1
2
3
4
SELECT * FROM tmyisam ORDER BY a;
a
1
2
3
4
5
6
7
--- on slave ---
SELECT * FROM tndb ORDER BY a;
a
1
2
3
4
SELECT * FROM tmyisam ORDER BY a;
a
1
2
3
4
5
6
7
==== Test 2: Master crash before writing XID event on XA engine ====
--- on master ---
INSERT INTO tinnodb VALUES (1);
SELECT * FROM tinnodb ORDER BY a;
a
1
--- on slave ---
STOP SLAVE;
SHOW SLAVE STATUS;
Slave_IO_State #
Master_Host 127.0.0.1
Master_User root
Master_Port MASTER_PORT
Connect_Retry 1
Master_Log_File master-bin.000001
Read_Master_Log_Pos 1740
Relay_Log_File #
Relay_Log_Pos #
Relay_Master_Log_File master-bin.000001
Slave_IO_Running No
Slave_SQL_Running No
Replicate_Do_DB
Replicate_Ignore_DB
Replicate_Do_Table
Replicate_Ignore_Table #
Replicate_Wild_Do_Table
Replicate_Wild_Ignore_Table
Last_Errno 0
Last_Error
Skip_Counter 0
Exec_Master_Log_Pos 1579
Relay_Log_Space #
Until_Condition None
Until_Log_File
Until_Log_Pos 0
Master_SSL_Allowed No
Master_SSL_CA_File
Master_SSL_CA_Path
Master_SSL_Cert
Master_SSL_Cipher
Master_SSL_Key
Seconds_Behind_Master #
Master_SSL_Verify_Server_Cert No
Last_IO_Errno #
Last_IO_Error #
Last_SQL_Errno 0
Last_SQL_Error
SELECT * FROM tinnodb ORDER BY a;
a
DROP TABLE tmyisam;
DROP TABLE tinnodb;
DROP TABLE tndb;