summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-10-21 12:57:09 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-10-21 12:57:09 +0300
commit1a2308d3f443d8fcacf5506cb96f802dee3a3519 (patch)
tree09e2e605c7fec70a433269e3b0c7dca92581e731
parent2d98b967e31623d9027c0db55330dde2c9d1d99a (diff)
downloadmariadb-git-1a2308d3f443d8fcacf5506cb96f802dee3a3519.tar.gz
MDEV-26865: Add test case and instrumentation
Based on mysql/mysql-server@bc9c46bf2894673d0df17cd0ee872d0d99663121 but without sleeps. The test was verified to hit the debug assertion if the change to fts_add_doc_by_id() in commit 2d98b967e31623d9027c0db55330dde2c9d1d99a was reverted.
-rw-r--r--mysql-test/suite/innodb_fts/r/bug_32831765.result131
-rw-r--r--mysql-test/suite/innodb_fts/t/bug_32831765.test164
-rw-r--r--storage/innobase/fts/fts0opt.cc3
3 files changed, 298 insertions, 0 deletions
diff --git a/mysql-test/suite/innodb_fts/r/bug_32831765.result b/mysql-test/suite/innodb_fts/r/bug_32831765.result
new file mode 100644
index 00000000000..1b828f4266b
--- /dev/null
+++ b/mysql-test/suite/innodb_fts/r/bug_32831765.result
@@ -0,0 +1,131 @@
+#
+# Bug#32831765 SERVER HITS OOM CONDITION WHEN LOADING TWO
+# INNODB TABLES WITH FTS INDEXES
+#
+create table t1 ( `id` int unsigned NOT NULL AUTO_INCREMENT, `col01` text,
+`col02` text, `col03` text, `col04` text, `col05` text, `col06` text, `col07`
+text, `col08` text, `col09` text, `col10` text, `col11` text, `col12` text,
+`col13` text, `col14` text, `col15` text, `col16` text, `col17` text, `col18`
+text, `col19` text, `col20` text, `col21` text, `col22` text, `col23` text,
+`col24` text, `col25` text, `col26` text, `col27` text, `col28` text, `col29`
+text, `col30` text, PRIMARY KEY (`id`), FULLTEXT KEY (`col01`), FULLTEXT KEY
+(`col02`), FULLTEXT KEY (`col03`), FULLTEXT KEY (`col04`), FULLTEXT KEY
+(`col05`), FULLTEXT KEY (`col06`), FULLTEXT KEY (`col07`), FULLTEXT KEY
+(`col08`), FULLTEXT KEY (`col09`), FULLTEXT KEY (`col10`), FULLTEXT KEY
+(`col11`), FULLTEXT KEY (`col12`), FULLTEXT KEY (`col13`), FULLTEXT KEY
+(`col14`), FULLTEXT KEY (`col15`), FULLTEXT KEY (`col16`), FULLTEXT KEY
+(`col17`), FULLTEXT KEY (`col18`), FULLTEXT KEY (`col19`), FULLTEXT KEY
+(`col20`), FULLTEXT KEY (`col21`), FULLTEXT KEY (`col22`), FULLTEXT KEY
+(`col23`), FULLTEXT KEY (`col24`), FULLTEXT KEY (`col25`), FULLTEXT KEY
+(`col26`), FULLTEXT KEY (`col27`), FULLTEXT KEY (`col28`), FULLTEXT KEY
+(`col29`), FULLTEXT KEY (`col30`)) engine=innodb;
+create table t2 ( `id` int unsigned NOT NULL AUTO_INCREMENT, `col01` text,
+`col02` text, `col03` text, `col04` text, `col05` text, `col06` text, `col07`
+text, `col08` text, `col09` text, `col10` text, `col11` text, `col12` text,
+`col13` text, `col14` text, `col15` text, `col16` text, `col17` text, `col18`
+text, `col19` text, `col20` text, `col21` text, `col22` text, `col23` text,
+`col24` text, `col25` text, `col26` text, `col27` text, `col28` text, `col29`
+text, `col30` text, PRIMARY KEY (`id`), FULLTEXT KEY (`col01`), FULLTEXT KEY
+(`col02`), FULLTEXT KEY (`col03`), FULLTEXT KEY (`col04`), FULLTEXT KEY
+(`col05`), FULLTEXT KEY (`col06`), FULLTEXT KEY (`col07`), FULLTEXT KEY
+(`col08`), FULLTEXT KEY (`col09`), FULLTEXT KEY (`col10`), FULLTEXT KEY
+(`col11`), FULLTEXT KEY (`col12`), FULLTEXT KEY (`col13`), FULLTEXT KEY
+(`col14`), FULLTEXT KEY (`col15`), FULLTEXT KEY (`col16`), FULLTEXT KEY
+(`col17`), FULLTEXT KEY (`col18`), FULLTEXT KEY (`col19`), FULLTEXT KEY
+(`col20`), FULLTEXT KEY (`col21`), FULLTEXT KEY (`col22`), FULLTEXT KEY
+(`col23`), FULLTEXT KEY (`col24`), FULLTEXT KEY (`col25`), FULLTEXT KEY
+(`col26`), FULLTEXT KEY (`col27`), FULLTEXT KEY (`col28`), FULLTEXT KEY
+(`col29`), FULLTEXT KEY (`col30`)) engine=innodb;
+create table t3 ( `id` int unsigned NOT NULL AUTO_INCREMENT, `col01` text,
+`col02` text, `col03` text, `col04` text, `col05` text, `col06` text, `col07`
+text, `col08` text, `col09` text, `col10` text, `col11` text, `col12` text,
+`col13` text, `col14` text, `col15` text, `col16` text, `col17` text, `col18`
+text, `col19` text, `col20` text, `col21` text, `col22` text, `col23` text,
+`col24` text, `col25` text, `col26` text, `col27` text, `col28` text, `col29`
+text, `col30` text, PRIMARY KEY (`id`), FULLTEXT KEY (`col01`), FULLTEXT KEY
+(`col02`), FULLTEXT KEY (`col03`), FULLTEXT KEY (`col04`), FULLTEXT KEY
+(`col05`), FULLTEXT KEY (`col06`), FULLTEXT KEY (`col07`), FULLTEXT KEY
+(`col08`), FULLTEXT KEY (`col09`), FULLTEXT KEY (`col10`), FULLTEXT KEY
+(`col11`), FULLTEXT KEY (`col12`), FULLTEXT KEY (`col13`), FULLTEXT KEY
+(`col14`), FULLTEXT KEY (`col15`), FULLTEXT KEY (`col16`), FULLTEXT KEY
+(`col17`), FULLTEXT KEY (`col18`), FULLTEXT KEY (`col19`), FULLTEXT KEY
+(`col20`), FULLTEXT KEY (`col21`), FULLTEXT KEY (`col22`), FULLTEXT KEY
+(`col23`), FULLTEXT KEY (`col24`), FULLTEXT KEY (`col25`), FULLTEXT KEY
+(`col26`), FULLTEXT KEY (`col27`), FULLTEXT KEY (`col28`), FULLTEXT KEY
+(`col29`), FULLTEXT KEY (`col30`)) engine=innodb;
+create table t4 ( `id` int unsigned NOT NULL AUTO_INCREMENT, `col01` text,
+`col02` text, `col03` text, `col04` text, `col05` text, `col06` text, `col07`
+text, `col08` text, `col09` text, `col10` text, `col11` text, `col12` text,
+`col13` text, `col14` text, `col15` text, `col16` text, `col17` text, `col18`
+text, `col19` text, `col20` text, `col21` text, `col22` text, `col23` text,
+`col24` text, `col25` text, `col26` text, `col27` text, `col28` text, `col29`
+text, `col30` text, PRIMARY KEY (`id`), FULLTEXT KEY (`col01`), FULLTEXT KEY
+(`col02`), FULLTEXT KEY (`col03`), FULLTEXT KEY (`col04`), FULLTEXT KEY
+(`col05`), FULLTEXT KEY (`col06`), FULLTEXT KEY (`col07`), FULLTEXT KEY
+(`col08`), FULLTEXT KEY (`col09`), FULLTEXT KEY (`col10`), FULLTEXT KEY
+(`col11`), FULLTEXT KEY (`col12`), FULLTEXT KEY (`col13`), FULLTEXT KEY
+(`col14`), FULLTEXT KEY (`col15`), FULLTEXT KEY (`col16`), FULLTEXT KEY
+(`col17`), FULLTEXT KEY (`col18`), FULLTEXT KEY (`col19`), FULLTEXT KEY
+(`col20`), FULLTEXT KEY (`col21`), FULLTEXT KEY (`col22`), FULLTEXT KEY
+(`col23`), FULLTEXT KEY (`col24`), FULLTEXT KEY (`col25`), FULLTEXT KEY
+(`col26`), FULLTEXT KEY (`col27`), FULLTEXT KEY (`col28`), FULLTEXT KEY
+(`col29`), FULLTEXT KEY (`col30`)) engine=innodb;
+#create procedure to inset into the table.
+CREATE PROCEDURE `proc_insert`(IN tab_name VARCHAR(40))
+BEGIN
+DECLARE i INT DEFAULT 1;
+SET @insert_tbl =CONCAT('INSERT INTO ', tab_name, '( `col01`, `col02`,
+ `col03`, `col04`, `col05`, `col06`, `col07`, `col08`, `col09`, `col10`,
+ `col11`, `col12`, `col13`, `col14`, `col15`, `col16`, `col17`, `col18`,
+ `col19`, `col20`, `col21`, `col22`, `col23`, `col24`, `col25`, `col26`,
+ `col27`, `col28`, `col29`, `col30`)
+ VALUES ( MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()),
+ MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()),
+ MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()),
+ MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()),
+ MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()),
+ MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()),
+ MD5(RAND()))');
+PREPARE ins_stmt FROM @insert_tbl;
+while (i <= 2000) DO
+EXECUTE ins_stmt;
+SET i = i + 1;
+END WHILE;
+DEALLOCATE PREPARE ins_stmt;
+END |
+SET @save_dbug= @@GLOBAL.debug_dbug;
+SET GLOBAL debug_dbug="+d,fts_optimize_wq_count_check";
+connect con1,localhost,root,,;
+call proc_insert('t1');
+connect con2,localhost,root,,;
+call proc_insert('t1');
+connect con3,localhost,root,,;
+call proc_insert('t2');
+connect con4,localhost,root,,;
+call proc_insert('t2');
+connect con5,localhost,root,,;
+call proc_insert('t3');
+connect con6,localhost,root,,;
+call proc_insert('t3');
+connect con7,localhost,root,,;
+call proc_insert('t4');
+connection default;
+call proc_insert('t4');
+SET GLOBAL debug_dbug= @save_dbug;
+connection con1;
+disconnect con1;
+connection con2;
+disconnect con2;
+connection con3;
+disconnect con3;
+connection con4;
+disconnect con4;
+connection con5;
+disconnect con5;
+connection con6;
+disconnect con6;
+connection con7;
+disconnect con7;
+connection default;
+DROP TABLE t1,t2,t3,t4;
+DROP PROCEDURE proc_insert;
diff --git a/mysql-test/suite/innodb_fts/t/bug_32831765.test b/mysql-test/suite/innodb_fts/t/bug_32831765.test
new file mode 100644
index 00000000000..a4551cf91ef
--- /dev/null
+++ b/mysql-test/suite/innodb_fts/t/bug_32831765.test
@@ -0,0 +1,164 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/big_test.inc
+
+--echo #
+--echo # Bug#32831765 SERVER HITS OOM CONDITION WHEN LOADING TWO
+--echo # INNODB TABLES WITH FTS INDEXES
+--echo #
+
+create table t1 ( `id` int unsigned NOT NULL AUTO_INCREMENT, `col01` text,
+`col02` text, `col03` text, `col04` text, `col05` text, `col06` text, `col07`
+text, `col08` text, `col09` text, `col10` text, `col11` text, `col12` text,
+`col13` text, `col14` text, `col15` text, `col16` text, `col17` text, `col18`
+text, `col19` text, `col20` text, `col21` text, `col22` text, `col23` text,
+`col24` text, `col25` text, `col26` text, `col27` text, `col28` text, `col29`
+text, `col30` text, PRIMARY KEY (`id`), FULLTEXT KEY (`col01`), FULLTEXT KEY
+(`col02`), FULLTEXT KEY (`col03`), FULLTEXT KEY (`col04`), FULLTEXT KEY
+(`col05`), FULLTEXT KEY (`col06`), FULLTEXT KEY (`col07`), FULLTEXT KEY
+(`col08`), FULLTEXT KEY (`col09`), FULLTEXT KEY (`col10`), FULLTEXT KEY
+(`col11`), FULLTEXT KEY (`col12`), FULLTEXT KEY (`col13`), FULLTEXT KEY
+(`col14`), FULLTEXT KEY (`col15`), FULLTEXT KEY (`col16`), FULLTEXT KEY
+(`col17`), FULLTEXT KEY (`col18`), FULLTEXT KEY (`col19`), FULLTEXT KEY
+(`col20`), FULLTEXT KEY (`col21`), FULLTEXT KEY (`col22`), FULLTEXT KEY
+(`col23`), FULLTEXT KEY (`col24`), FULLTEXT KEY (`col25`), FULLTEXT KEY
+(`col26`), FULLTEXT KEY (`col27`), FULLTEXT KEY (`col28`), FULLTEXT KEY
+(`col29`), FULLTEXT KEY (`col30`)) engine=innodb;
+
+create table t2 ( `id` int unsigned NOT NULL AUTO_INCREMENT, `col01` text,
+`col02` text, `col03` text, `col04` text, `col05` text, `col06` text, `col07`
+text, `col08` text, `col09` text, `col10` text, `col11` text, `col12` text,
+`col13` text, `col14` text, `col15` text, `col16` text, `col17` text, `col18`
+text, `col19` text, `col20` text, `col21` text, `col22` text, `col23` text,
+`col24` text, `col25` text, `col26` text, `col27` text, `col28` text, `col29`
+text, `col30` text, PRIMARY KEY (`id`), FULLTEXT KEY (`col01`), FULLTEXT KEY
+(`col02`), FULLTEXT KEY (`col03`), FULLTEXT KEY (`col04`), FULLTEXT KEY
+(`col05`), FULLTEXT KEY (`col06`), FULLTEXT KEY (`col07`), FULLTEXT KEY
+(`col08`), FULLTEXT KEY (`col09`), FULLTEXT KEY (`col10`), FULLTEXT KEY
+(`col11`), FULLTEXT KEY (`col12`), FULLTEXT KEY (`col13`), FULLTEXT KEY
+(`col14`), FULLTEXT KEY (`col15`), FULLTEXT KEY (`col16`), FULLTEXT KEY
+(`col17`), FULLTEXT KEY (`col18`), FULLTEXT KEY (`col19`), FULLTEXT KEY
+(`col20`), FULLTEXT KEY (`col21`), FULLTEXT KEY (`col22`), FULLTEXT KEY
+(`col23`), FULLTEXT KEY (`col24`), FULLTEXT KEY (`col25`), FULLTEXT KEY
+(`col26`), FULLTEXT KEY (`col27`), FULLTEXT KEY (`col28`), FULLTEXT KEY
+(`col29`), FULLTEXT KEY (`col30`)) engine=innodb;
+
+
+create table t3 ( `id` int unsigned NOT NULL AUTO_INCREMENT, `col01` text,
+`col02` text, `col03` text, `col04` text, `col05` text, `col06` text, `col07`
+text, `col08` text, `col09` text, `col10` text, `col11` text, `col12` text,
+`col13` text, `col14` text, `col15` text, `col16` text, `col17` text, `col18`
+text, `col19` text, `col20` text, `col21` text, `col22` text, `col23` text,
+`col24` text, `col25` text, `col26` text, `col27` text, `col28` text, `col29`
+text, `col30` text, PRIMARY KEY (`id`), FULLTEXT KEY (`col01`), FULLTEXT KEY
+(`col02`), FULLTEXT KEY (`col03`), FULLTEXT KEY (`col04`), FULLTEXT KEY
+(`col05`), FULLTEXT KEY (`col06`), FULLTEXT KEY (`col07`), FULLTEXT KEY
+(`col08`), FULLTEXT KEY (`col09`), FULLTEXT KEY (`col10`), FULLTEXT KEY
+(`col11`), FULLTEXT KEY (`col12`), FULLTEXT KEY (`col13`), FULLTEXT KEY
+(`col14`), FULLTEXT KEY (`col15`), FULLTEXT KEY (`col16`), FULLTEXT KEY
+(`col17`), FULLTEXT KEY (`col18`), FULLTEXT KEY (`col19`), FULLTEXT KEY
+(`col20`), FULLTEXT KEY (`col21`), FULLTEXT KEY (`col22`), FULLTEXT KEY
+(`col23`), FULLTEXT KEY (`col24`), FULLTEXT KEY (`col25`), FULLTEXT KEY
+(`col26`), FULLTEXT KEY (`col27`), FULLTEXT KEY (`col28`), FULLTEXT KEY
+(`col29`), FULLTEXT KEY (`col30`)) engine=innodb;
+
+create table t4 ( `id` int unsigned NOT NULL AUTO_INCREMENT, `col01` text,
+`col02` text, `col03` text, `col04` text, `col05` text, `col06` text, `col07`
+text, `col08` text, `col09` text, `col10` text, `col11` text, `col12` text,
+`col13` text, `col14` text, `col15` text, `col16` text, `col17` text, `col18`
+text, `col19` text, `col20` text, `col21` text, `col22` text, `col23` text,
+`col24` text, `col25` text, `col26` text, `col27` text, `col28` text, `col29`
+text, `col30` text, PRIMARY KEY (`id`), FULLTEXT KEY (`col01`), FULLTEXT KEY
+(`col02`), FULLTEXT KEY (`col03`), FULLTEXT KEY (`col04`), FULLTEXT KEY
+(`col05`), FULLTEXT KEY (`col06`), FULLTEXT KEY (`col07`), FULLTEXT KEY
+(`col08`), FULLTEXT KEY (`col09`), FULLTEXT KEY (`col10`), FULLTEXT KEY
+(`col11`), FULLTEXT KEY (`col12`), FULLTEXT KEY (`col13`), FULLTEXT KEY
+(`col14`), FULLTEXT KEY (`col15`), FULLTEXT KEY (`col16`), FULLTEXT KEY
+(`col17`), FULLTEXT KEY (`col18`), FULLTEXT KEY (`col19`), FULLTEXT KEY
+(`col20`), FULLTEXT KEY (`col21`), FULLTEXT KEY (`col22`), FULLTEXT KEY
+(`col23`), FULLTEXT KEY (`col24`), FULLTEXT KEY (`col25`), FULLTEXT KEY
+(`col26`), FULLTEXT KEY (`col27`), FULLTEXT KEY (`col28`), FULLTEXT KEY
+(`col29`), FULLTEXT KEY (`col30`)) engine=innodb;
+
+delimiter |;
+
+--echo #create procedure to inset into the table.
+CREATE PROCEDURE `proc_insert`(IN tab_name VARCHAR(40))
+BEGIN
+ DECLARE i INT DEFAULT 1;
+ SET @insert_tbl =CONCAT('INSERT INTO ', tab_name, '( `col01`, `col02`,
+ `col03`, `col04`, `col05`, `col06`, `col07`, `col08`, `col09`, `col10`,
+ `col11`, `col12`, `col13`, `col14`, `col15`, `col16`, `col17`, `col18`,
+ `col19`, `col20`, `col21`, `col22`, `col23`, `col24`, `col25`, `col26`,
+ `col27`, `col28`, `col29`, `col30`)
+ VALUES ( MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()),
+ MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()),
+ MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()),
+ MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()),
+ MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()),
+ MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()),
+ MD5(RAND()))');
+ PREPARE ins_stmt FROM @insert_tbl;
+ while (i <= 2000) DO
+ EXECUTE ins_stmt;
+ SET i = i + 1;
+ END WHILE;
+ DEALLOCATE PREPARE ins_stmt;
+END |
+
+delimiter ;|
+
+# Ensure that the number of SYNC requests will not exceed 1000.
+SET @save_dbug= @@GLOBAL.debug_dbug;
+SET GLOBAL debug_dbug="+d,fts_optimize_wq_count_check";
+
+connect (con1,localhost,root,,);
+send call proc_insert('t1');
+connect (con2,localhost,root,,);
+send call proc_insert('t1');
+connect (con3,localhost,root,,);
+send call proc_insert('t2');
+connect (con4,localhost,root,,);
+send call proc_insert('t2');
+connect (con5,localhost,root,,);
+send call proc_insert('t3');
+connect (con6,localhost,root,,);
+send call proc_insert('t3');
+connect (con7,localhost,root,,);
+send call proc_insert('t4');
+
+connection default;
+call proc_insert('t4');
+SET GLOBAL debug_dbug= @save_dbug;
+
+connection con1;
+reap;
+disconnect con1;
+
+connection con2;
+reap;
+disconnect con2;
+
+connection con3;
+reap;
+disconnect con3;
+
+connection con4;
+reap;
+disconnect con4;
+
+connection con5;
+reap;
+disconnect con5;
+
+connection con6;
+reap;
+disconnect con6;
+
+connection con7;
+reap;
+disconnect con7;
+
+connection default;
+DROP TABLE t1,t2,t3,t4;
+DROP PROCEDURE proc_insert;
diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc
index 2d506a757a0..13e01befe55 100644
--- a/storage/innobase/fts/fts0opt.cc
+++ b/storage/innobase/fts/fts0opt.cc
@@ -2641,6 +2641,9 @@ fts_optimize_request_sync_table(
ib_wqueue_add(fts_optimize_wq, msg, msg->heap, true);
+ DBUG_EXECUTE_IF("fts_optimize_wq_count_check",
+ DBUG_ASSERT(fts_optimize_wq->length <= 1000););
+
mutex_exit(&fts_optimize_wq->mutex);
}