1SET @old_log_output = @@global.log_output; 2SET @old_slow_query_log = @@global.slow_query_log; 3SET @old_general_log = @@global.general_log; 4SET @old_long_query_time = @@global.long_query_time; 5SET @old_binlog_order_commits = @@global.binlog_order_commits; 6SET GLOBAL log_output = 'TABLE'; 7SET GLOBAL general_log = 1; 8SET GLOBAL slow_query_log = 1; 9SET GLOBAL long_query_time = 1; 10SET GLOBAL binlog_order_commits = 1; 11# Case 1: Sync blocks DML(insert) on the same table. 12CREATE TABLE t1 ( 13FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, 14title VARCHAR(200), 15FULLTEXT(title) 16) ENGINE = InnoDB; 17SET GLOBAL debug="+d,fts_instrument_sync_debug,fts_instrument_sync_sleep"; 18SET DEBUG_SYNC= 'fts_sync_begin SIGNAL begin WAIT_FOR continue'; 19INSERT INTO t1(title) VALUES('mysql database'); 20SET DEBUG_SYNC= 'now WAIT_FOR begin'; 21SELECT * FROM t1 WHERE MATCH(title) AGAINST('mysql database'); 22SET DEBUG_SYNC= 'now SIGNAL continue'; 23/* connection con1 */ INSERT INTO t1(title) VALUES('mysql database'); 24/* conneciton con2 */ SELECT * FROM t1 WHERE MATCH(title) AGAINST('mysql database'); 25FTS_DOC_ID title 26# make con1 & con2 show up in mysql.slow_log 27SELECT SLEEP(2); 28SLEEP(2) 290 30# slow log results should only contain INSERT INTO t1. 31SELECT sql_text FROM mysql.slow_log WHERE query_time >= '00:00:02'; 32sql_text 33INSERT INTO t1(title) VALUES('mysql database') 34SET GLOBAL debug="-d,fts_instrument_sync_debug,fts_instrument_sync_sleep"; 35TRUNCATE TABLE mysql.slow_log; 36DROP TABLE t1; 37# Case 2: Sync blocks DML(insert) on other tables. 38CREATE TABLE t1 ( 39FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, 40title VARCHAR(200), 41FULLTEXT(title) 42) ENGINE = InnoDB; 43CREATE TABLE t2(id INT); 44SET GLOBAL debug="+d,fts_instrument_sync_request,fts_instrument_sync_sleep"; 45SET DEBUG_SYNC= 'fts_instrument_sync_request SIGNAL begin WAIT_FOR continue'; 46INSERT INTO t1(title) VALUES('mysql database'); 47SET DEBUG_SYNC= 'now WAIT_FOR begin'; 48INSERT INTO t2 VALUES(1); 49SET DEBUG_SYNC= 'now SIGNAL continue'; 50/* connection con1 */ INSERT INTO t1(title) VALUES('mysql database'); 51/* conneciton con2 */ INSERT INTO t2 VALUES(1); 52# make con1 & con2 show up in mysql.slow_log 53SELECT SLEEP(2); 54SLEEP(2) 550 56# slow log results should be empty here. 57SELECT sql_text FROM mysql.slow_log WHERE query_time >= '00:00:02'; 58sql_text 59SET GLOBAL debug="-d,fts_instrument_sync_request,fts_instrument_sync_sleep"; 60TRUNCATE TABLE mysql.slow_log; 61DROP TABLE t1,t2; 62# Restore slow log settings. 63SET GLOBAL log_output = @old_log_output; 64SET GLOBAL general_log = @old_general_log; 65SET GLOBAL slow_query_log = @old_slow_query_log; 66SET GLOBAL long_query_time = @old_long_query_time; 67SET GLOBAL binlog_order_commits = @old_binlog_order_commits; 68