1# 2# BUG#22516559 MYSQL INSTANCE STALLS WHEN SYNCING FTS INDEX 3# 4 5--source include/have_innodb.inc 6--source include/have_debug.inc 7--source include/have_debug_sync.inc 8--source include/have_log_bin.inc 9--source include/count_sessions.inc 10 11SET @old_log_output = @@global.log_output; 12SET @old_slow_query_log = @@global.slow_query_log; 13SET @old_general_log = @@global.general_log; 14SET @old_long_query_time = @@global.long_query_time; 15SET @old_debug = @@global.debug_dbug; 16 17SET GLOBAL log_output = 'TABLE'; 18SET GLOBAL general_log = 1; 19SET GLOBAL slow_query_log = 1; 20SET GLOBAL long_query_time = 1; 21 22connect (con1,localhost,root,,); 23connect (con2,localhost,root,,); 24connection default; 25 26--echo # Case 1: Sync blocks DML(insert) on the same table. 27CREATE TABLE t1 ( 28 FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, 29 title VARCHAR(200), 30 FULLTEXT(title) 31) ENGINE = InnoDB; 32 33connection con1; 34 35SET GLOBAL debug_dbug='+d,fts_instrument_sync_debug,fts_instrument_sync_sleep'; 36 37SET DEBUG_SYNC= 'fts_sync_begin SIGNAL begin WAIT_FOR continue'; 38 39send INSERT INTO t1(title) VALUES('mysql database'); 40 41connection con2; 42 43SET DEBUG_SYNC= 'now WAIT_FOR begin'; 44 45send SELECT * FROM t1 WHERE MATCH(title) AGAINST('mysql database'); 46 47connection default; 48SET DEBUG_SYNC= 'now SIGNAL continue'; 49 50connection con1; 51--echo /* connection con1 */ INSERT INTO t1(title) VALUES('mysql database'); 52--reap 53 54connection con2; 55--echo /* conneciton con2 */ SELECT * FROM t1 WHERE MATCH(title) AGAINST('mysql database'); 56--reap 57 58connection default; 59-- echo # make con1 & con2 show up in mysql.slow_log 60SELECT SLEEP(2); 61-- echo # slow log results should only contain INSERT INTO t1. 62SELECT sql_text FROM mysql.slow_log WHERE query_time >= '00:00:02'; 63 64SET GLOBAL debug_dbug = @old_debug; 65TRUNCATE TABLE mysql.slow_log; 66 67DROP TABLE t1; 68 69--echo # Case 2: Sync blocks DML(insert) on other tables. 70CREATE TABLE t1 ( 71 FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, 72 title VARCHAR(200), 73 FULLTEXT(title) 74) ENGINE = InnoDB; 75 76CREATE TABLE t2(id INT); 77 78connection con1; 79 80SET GLOBAL debug_dbug='+d,fts_instrument_sync_request,fts_instrument_sync_sleep'; 81 82SET DEBUG_SYNC= 'fts_instrument_sync_request SIGNAL begin WAIT_FOR continue'; 83 84send INSERT INTO t1(title) VALUES('mysql database'); 85 86connection con2; 87 88SET DEBUG_SYNC= 'now WAIT_FOR begin'; 89 90send INSERT INTO t2 VALUES(1); 91 92connection default; 93SET DEBUG_SYNC= 'now SIGNAL continue'; 94 95connection con1; 96--echo /* connection con1 */ INSERT INTO t1(title) VALUES('mysql database'); 97--reap 98 99connection con2; 100--echo /* conneciton con2 */ INSERT INTO t2 VALUES(1); 101--reap 102 103connection default; 104SET DEBUG_SYNC = 'RESET'; 105-- echo # make con1 & con2 show up in mysql.slow_log 106SELECT SLEEP(2); 107-- echo # slow log results should be empty here. 108SELECT sql_text FROM mysql.slow_log WHERE query_time >= '00:00:02'; 109 110SET GLOBAL debug_dbug = @old_debug; 111TRUNCATE TABLE mysql.slow_log; 112 113DROP TABLE t1,t2; 114 115disconnect con1; 116disconnect con2; 117 118--source include/wait_until_count_sessions.inc 119 120-- echo # Restore slow log settings. 121SET GLOBAL log_output = @old_log_output; 122SET GLOBAL general_log = @old_general_log; 123SET GLOBAL slow_query_log = @old_slow_query_log; 124SET GLOBAL long_query_time = @old_long_query_time; 125