forked from alibaba/AliSQL
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUG#16418100 ERROR "WHEN GTID_NEXT IS SET TO A GTID" ROW BASED REPLIC…
…ATION Problem & Analysis: =================== When relay log info repository is configured to be persisted in a table, it is updated when transaction commits or explicit flush is called, like on relay log rotate. If a transaction that uses non-transactional engine is split across multiple relay logs, on relay log flush it will be partially committed. If GTID_MODE=ON and when partial transaction in first relay log is committed, it uses the current GTID value and sets GTID value to UNDEFINED GROUP. Hence it causes 'ER_GTID_NEXT_TYPE_UNDEFINED_GROUP' error when it is trying to commit the rest of the transaction. It also causes many other problems if the repository is updated in between the transaction and it should be avoided. Fix: relay log info repository should be updated on relay log rotate. But when the transaction is split across two relay logs, update the repository will cause unexpected results and should be postponed till the 'commit' of the transaction is executed. Introduced a flag that set to 'true' when this type of 'forced flush'(at the time of rotate relay log) is postponed due to transaction split across the relay logs. And the flag will be checked in flush_info function to see if there is a flush that got postponed earlier. If so, it will force the flush now irrespective of sync_relay_log_info value.
- Loading branch information
Venkatesh Duggirala
committed
Aug 25, 2015
1 parent
c285e65
commit 9b0e016
Showing
7 changed files
with
158 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
mysql-test/suite/rpl/r/rpl_gtid_transaction_split_across_relay_logs.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
include/rpl_init.inc [topology=1->2->3] | ||
Warnings: | ||
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. | ||
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. | ||
Warnings: | ||
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. | ||
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. | ||
[connection server_1] | ||
CREATE TABLE t1 (i VARCHAR(8192)) ENGINE=MyISAM; | ||
INSERT INTO t1 VALUES(repeat('a',8192)), (repeat('b', 8192)); | ||
[connection server_2] | ||
SET @saved_debug=@@GLOBAL.debug; | ||
SET GLOBAL debug="d,stop_io_after_reading_write_rows_log_event"; | ||
START SLAVE IO_THREAD; | ||
include/wait_for_slave_io_to_stop.inc | ||
SET GLOBAL debug=@saved_debug; | ||
START SLAVE; | ||
[connection server_3] | ||
START SLAVE; | ||
[connection server_1] | ||
include/rpl_sync.inc | ||
include/diff_tables.inc [server_1:t1, server_2:t1, server_3:t1] | ||
[connection server_2] | ||
include/assert.inc [SQL thread position should be updated to after the split transaction] | ||
include/assert.inc [SQL thread file should be updated to after the split transaction] | ||
[connection server_1] | ||
DROP TABLE t1; | ||
include/rpl_end.inc |
16 changes: 16 additions & 0 deletions
16
mysql-test/suite/rpl/t/rpl_gtid_transaction_split_across_relay_logs.cnf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
!include include/default_mysqld.cnf | ||
|
||
[mysqld.1] | ||
|
||
[mysqld.2] | ||
log-slave-updates | ||
relay-log-info-repository=table | ||
|
||
[mysqld.3] | ||
log-slave-updates | ||
relay-log-info-repository=table | ||
|
||
[ENV] | ||
SERVER_MYPORT_1= @mysqld.1.port | ||
SERVER_MYPORT_2= @mysqld.2.port | ||
SERVER_MYPORT_3= @mysqld.3.port |
82 changes: 82 additions & 0 deletions
82
mysql-test/suite/rpl/t/rpl_gtid_transaction_split_across_relay_logs.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
############################################################################### | ||
#BUG#16418100: ERROR "WHEN GTID_NEXT IS SET TO A GTID" ROW BASED REPLICATION | ||
# Problem: When relay log info repository is configured to be persisted in a | ||
# table and if a transaction that uses non-transactional engine is split across | ||
# multiple relay logs, on relay log flush, partial transaction is | ||
# committed. If the same situation occurs when gtid-mode=ON, it will cause that | ||
# the same GTID will be used for more than one transaction and will cause | ||
# ER_GTID_NEXT_TYPE_UNDEFINED_GROUP error. | ||
# | ||
# Steps to reproduce: | ||
# 1) Generate two write_row events for non-transactional table (MyISAM) | ||
# (Default binlog_row_max_event_size= 8192). Insert two tuples with tuple | ||
# size as 8192 bytes each. This will generate two write_row events. | ||
# 2) With Auto_position=0, stopping IO thread after receving one write_row | ||
# event will split the transaction across two relay logs. | ||
# 3) If relaylog_info_repository=table, SQL thread should be able to apply | ||
# these type of relaylogs. | ||
############################################################################### | ||
# Problem happens only in gtid mode | ||
--source include/have_gtid.inc | ||
# Run only in row format | ||
--source include/have_binlog_format_row.inc | ||
# Disable auto position protocol | ||
--let use_gtids=0 | ||
--let $rpl_skip_start_slave= 1 | ||
--let $rpl_topology= 1->2->3 | ||
--source include/rpl_init.inc | ||
|
||
--let $rpl_connection_name= server_1 | ||
--source include/rpl_connection.inc | ||
|
||
# Non-transactional table (MyISAM engine) | ||
CREATE TABLE t1 (i VARCHAR(8192)) ENGINE=MyISAM; | ||
|
||
# Two tuples that will generate two write_row events. | ||
INSERT INTO t1 VALUES(repeat('a',8192)), (repeat('b', 8192)); | ||
|
||
--let $rpl_connection_name= server_2 | ||
--source include/rpl_connection.inc | ||
# Set simulation point to restart IO thread, so that the transaction | ||
# is split across the relay logs. | ||
SET @saved_debug=@@GLOBAL.debug; | ||
SET GLOBAL debug="d,stop_io_after_reading_write_rows_log_event"; | ||
START SLAVE IO_THREAD; | ||
--source include/wait_for_slave_io_to_stop.inc | ||
SET GLOBAL debug=@saved_debug; | ||
|
||
# Make sure there are no replication issues | ||
--disable_warnings | ||
START SLAVE; | ||
--enable_warnings | ||
|
||
--let $rpl_connection_name= server_3 | ||
--source include/rpl_connection.inc | ||
--disable_warnings | ||
START SLAVE; | ||
--enable_warnings | ||
|
||
--let $rpl_connection_name= server_1 | ||
--source include/rpl_connection.inc | ||
--source include/rpl_sync.inc | ||
|
||
--let $diff_tables= server_1:t1, server_2:t1, server_3:t1 | ||
--source include/diff_tables.inc | ||
|
||
# Assert that relay log info pos is stored on table | ||
--let $rpl_connection_name= server_2 | ||
--source include/rpl_connection.inc | ||
--let $sql_thread_pos=query_get_value('SHOW SLAVE STATUS', Exec_Master_Log_Pos, 1) | ||
--let $sql_thread_file=query_get_value('SHOW SLAVE STATUS', Relay_Master_Log_File, 1) | ||
--let $assert_cond= Master_log_pos = $sql_thread_pos FROM mysql.slave_relay_log_info | ||
--let $assert_text= SQL thread position should be updated to after the split transaction | ||
--source include/assert.inc | ||
--let $assert_cond= Master_log_name = "$sql_thread_file" FROM mysql.slave_relay_log_info | ||
--let $assert_text= SQL thread file should be updated to after the split transaction | ||
--source include/assert.inc | ||
|
||
# Cleanup | ||
--let $rpl_connection_name= server_1 | ||
--source include/rpl_connection.inc | ||
DROP TABLE t1; | ||
--source include/rpl_end.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters