Current Path : /home/usr.opt/mysql57/mysql-test/suite/rpl/t/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //home/usr.opt/mysql57/mysql-test/suite/rpl/t/rpl_gtid_not_yet_determined.test |
# ==== Purpose ==== # # Background: For 5.7 binary logs (after WL#7592), the slave applier # thread sets GTID_NEXT according to the Gtid_log_event or # Anonymous_log_event preceding every transaction. For 5.6 binary # logs using GTID_MODE=ON, it does the same. But for 5.6 binary log # using GTID_MODE=OFF, or for 5.5 or earlier binary logs, there are no # Gtid_log_events or Anonymous_gtid_log_event. In order to set # gtid_next correctly also for this case, we use a special mechanism: # when any Format_description_log_event is applied, it sets # thd->variables.gtid_next.type=NOT_YET_DETERMINED_GROUP. The next # statement to execute then sets the real value for gtid_next: if the # next statement is SET GTID_NEXT, then gtid_next is set # accordingly. If the next statement is anything else, it assumes that # this is an old binary log and changes NOT_YET_DETERMINED_GROUP to # ANONYMOUS_GROUP (which causes an error to be generated if # GTID_MODE=ON). # # The code that changes NOT_YET_DETERMINED_GROUP to ANONYMOUS_GROUP # invoked for SQL statements (from mysql_parse). This normally covers # also the RBR case, because RBR transactions begin with a # query_log_event(BEGIN), so it will set gtid_next=ANONYMOUS for the # BEGIN statement. # # However, if the applier thread begins execution in the middle of a # transaction, it is possible that a row event is processed when # gtid_next.type is NOT_YET_DETERMINED_GROUP. This can happen if # an explicit CHANGE MASTER TO RELAY_LOG_POS statement positions the # applier thread after the BEGIN statement, or if an explicit CHANGE # MASTER TO MASTER_LOG_POS statement positions the receiver thread in # the middle of a transaction. # # Therefore, even Rows_log_events need to upgrade # NOT_YET_DETERMINED_GROUP to ANONYMOUS. This test verifies that this # logic works correctly. # # ==== Implementation ==== # # 1. Verify basic properties of GTID_NEXT = NOT_YET_DETERMINED: # 1.1. Format_description_event sets GTID_NEXT = NOT_YET_DETERMINED. # 1.2. DO, SELECT, SHOW, and SET don't change NOT_YET_DETERMINED # to ANONYMOUS. # 1.3. Other SQL statements change NOT_YET_DETERMINED to ANONYMOUS # when GTID_MODE = OFF. # 1.4. Row injection using BINLOG statement changes # NOT_YET_DETERMINED to ANONYMOUS when GTID_MODE = OFF. # 1.5. Other SQL statements generate an error if GTID_NEXT = # NOT_YET_DETERMINED and GTID_MODE = ON. # 1.6. Row injection using BINLOG statement generates an error if # GTID_NEXT = NOT_YET_DETERMINED and GTID_MODE = ON. # 1.7. It is allowed to set any other value for GTID_NEXT after # it has been set to NOT_YET_DETERMINED. # 2. Position the slave receiver thread after a BEGIN event in the # master's binary log and verify that replication works (no crash). # 3. Position the slave applier thread after a BEGIN event in the # slave's relay log and verify that replication works (no crash). # # ==== Related bugs and worklogs ==== # # WL#3584: Global Transaction Identifiers (GTIDs) # - The logic of NOT_YET_DETERMINED_GROUP was introduced in this worklog. # WL#7592: GTIDs: generate Gtid_log_event and Previous_gtids_log_event always # - The code was refactored in this worklog (and the bug introduced). # BUG#20883676: ASSERT `THD->OWNED_GTID.SIDNO == THD::OWNED_SIDNO_ANONYMOUS' # AT BINLOG.CC:1144 # - The logic was corrected again in this bug. # Not meaningful to test with GTID_MODE=ON. --source include/not_gtid_enabled.inc # Test mixed mode to verify that SQL statements convert NOT_YET_DETERMINED # to ANONYMOUS. Test row mode to verify that row events convert # NOT_YET_DETERMINED to ANONYMOUS. No need to test other formats. --source include/have_binlog_format_mixed_or_row.inc # MTS does not allow row events outside transactions. --source include/not_mts_slave_parallel_workers.inc --source include/master-slave.inc --echo #### Initialize #### CREATE TABLE t1 (a INT); --source include/sync_slave_sql_with_master.inc CALL mtr.add_suppression('QUERY.*COMMIT or ROLLBACK.* or XID_LOG_EVENT is not expected in an event stream outside a transaction'); CALL mtr.add_suppression('An unexpected event sequence was detected by the IO thread while queuing the event received from master'); --echo #### 1. Check basic properties of GTID_NEXT = NOT_YET_DETERMINED #### # This is a 5.7 Format_description_log_event. let $fd_event= 'C9BAVQ8BAAAAdwAAAHsAAAABAAQANS43LjgtcmMtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAL0EBVEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjUA AdVXOVA='; --echo ---- 1.1. Format_description_log_event sets NOT_YET_DETERMINED ---- eval BINLOG $fd_event; SELECT @@SESSION.GTID_NEXT; --echo ---- 1.2. DO, SELECT, SHOW, and SET don't change GTID_NEXT ---- DO 1; SELECT 1; SHOW VARIABLES LIKE 'whatever'; SET @foo = 1; SELECT @@SESSION.GTID_NEXT; --echo ---- 1.3. Other stm changes NOT_YET_DETERMINED to ANONYMOUS if GTID_MODE=OFF ---- BEGIN; SELECT @@SESSION.GTID_NEXT; ROLLBACK; SET @@SESSION.GTID_NEXT = 'AUTOMATIC'; --echo ---- 1.4. Row injection changes NOT_YET_DETERMINED to ANONYMOUS if GTID_MODE=OFF ---- eval BINLOG $fd_event; SELECT @@SESSION.GTID_NEXT; BINLOG ' qyhTVRMBAAAALQAAAPIBAAAAAGwAAAAAAAEABHRlc3QAAnQxAAEDAAGFeQAI qyhTVR4BAAAAKAAAABoCAAAAAGwAAAAAAAEAAgAB//4BAAAAcd2jbw== '/*!*/; SELECT @@SESSION.GTID_NEXT; ROLLBACK; SET @@SESSION.GTID_NEXT = 'AUTOMATIC'; --echo ---- 1.5. Other stm generates error for NOT_YET_DETERMINED if GTID_MODE=ON ---- --let $rpl_set_enforce_gtid_consistency= 1 --let $rpl_gtid_mode= ON --source include/rpl_set_gtid_mode.inc eval BINLOG $fd_event; SELECT @@SESSION.GTID_NEXT; --error ER_CANT_SET_GTID_NEXT_TO_ANONYMOUS_WHEN_GTID_MODE_IS_ON BEGIN; SET @@SESSION.GTID_NEXT = 'AUTOMATIC'; --echo ---- 1.6. Row injection generates error for NOT_YET_DETERMINED if GTID_MODE=ON ---- eval BINLOG $fd_event; SELECT @@SESSION.GTID_NEXT; --error ER_CANT_SET_GTID_NEXT_TO_ANONYMOUS_WHEN_GTID_MODE_IS_ON BINLOG ' qyhTVRMBAAAALQAAAPIBAAAAAGwAAAAAAAEABHRlc3QAAnQxAAEDAAGFeQAI qyhTVR4BAAAAKAAAABoCAAAAAGwAAAAAAAEAAgAB//4BAAAAcd2jbw== '/*!*/; SET @@SESSION.GTID_NEXT = 'AUTOMATIC'; --let $rpl_set_enforce_gtid_consistency= 0 --let $rpl_gtid_mode= OFF --source include/rpl_set_gtid_mode.inc --echo ---- 1.7.1 Can set AUTOMATIC after NOT_YET_DETERMINED ---- eval BINLOG $fd_event; SELECT @@SESSION.GTID_NEXT; SET @@SESSION.GTID_NEXT = 'AUTOMATIC'; SELECT @@SESSION.GTID_NEXT; --echo ---- 1.7.2 Can set DEFAULT after NOT_YET_DETERMINED ---- eval BINLOG $fd_event; SELECT @@SESSION.GTID_NEXT; SET @@SESSION.GTID_NEXT = DEFAULT; SELECT @@SESSION.GTID_NEXT; --echo ---- 1.7.3 Can set ANONYMOUS after NOT_YET_DETERMINED ---- eval BINLOG $fd_event; SELECT @@SESSION.GTID_NEXT; SET @@SESSION.GTID_NEXT = 'ANONYMOUS'; SELECT @@SESSION.GTID_NEXT; ROLLBACK; SET @@SESSION.GTID_NEXT = 'AUTOMATIC'; --echo ---- 1.7.4 Can set GTID after NOT_YET_DETERMINED ---- SET GLOBAL GTID_MODE = OFF_PERMISSIVE; eval BINLOG $fd_event; SELECT @@SESSION.GTID_NEXT; SET GTID_NEXT = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1'; SELECT @@SESSION.GTID_NEXT; ROLLBACK; SET @@SESSION.GTID_NEXT = 'AUTOMATIC'; SET GLOBAL GTID_MODE = OFF; --echo #### 2. CHANGE MASTER TO MASTER_LOG_POS #### --connection slave --source include/stop_slave_io.inc --connection master --let $file= query_get_value(SHOW MASTER STATUS, File, 1) --let $position= query_get_value(SHOW MASTER STATUS, Position, 1) INSERT INTO t1 VALUES (1); # Force slave to skip the Anonymous_gtid_log_event and # Query_log_event(BEGIN) so that the first event it sees is a # Table_map_log_event. --let $position= query_get_value(SHOW BINLOG EVENTS IN '$file' FROM $position, End_log_pos, 2) --connection slave --replace_result $file FILE $position POSITION eval CHANGE MASTER TO MASTER_LOG_FILE = '$file', MASTER_LOG_POS = $position; --source include/start_slave_io.inc --connection master --source include/sync_slave_sql_with_master.inc --echo #### 3. CHANGE MASTER TO RELAY_LOG_POS #### --let $file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1) --let $position= query_get_value(SHOW SLAVE STATUS, Relay_Log_Pos, 1) --source include/stop_slave_sql.inc --connection master INSERT INTO t1 VALUES (2); --source include/sync_slave_io_with_master.inc --let $position = query_get_value(SHOW RELAYLOG EVENTS IN '$file' FROM $position, Pos, 3) --replace_result $file FILE $position POSITION eval CHANGE MASTER TO RELAY_LOG_FILE = '$file', RELAY_LOG_POS = $position; --source include/start_slave.inc --connection master --source include/sync_slave_sql_with_master.inc --echo #### Clean up #### --connection master DROP TABLE t1; --source include/rpl_end.inc