From ac49b7a845f5b5de30d1266879a4c584f9d7c914 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 29 Aug 2022 22:54:25 +0530 Subject: [PATCH] MDEV-29342 Assertion failure in file que0que.cc line 728 - During shutdown, InnoDB fts fails to update synced doc id when there is only one doc id about to sync. While starting the server, InnoDB fetches the already synced doc id from config table. In the subsequent sync operation, InnoDB fails with DB_DUPLICATE_KEY error. --- mysql-test/suite/innodb_fts/r/misc_debug2.result | 13 +++++++++++++ mysql-test/suite/innodb_fts/t/misc_debug2.test | 15 +++++++++++++++ storage/innobase/fts/fts0fts.cc | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb_fts/r/misc_debug2.result b/mysql-test/suite/innodb_fts/r/misc_debug2.result index b3bc12f92cc..583d43bd9db 100644 --- a/mysql-test/suite/innodb_fts/r/misc_debug2.result +++ b/mysql-test/suite/innodb_fts/r/misc_debug2.result @@ -5,3 +5,16 @@ set debug_dbug="+d,fts_instrument_sync_request"; INSERT INTO mdev21563 VALUES('This is a test'); ALTER TABLE mdev21563 DISCARD TABLESPACE; DROP TABLE mdev21563; +# +# MDEV-29342 Assertion failure in file que0que.cc line 728 +# +CREATE TABLE t1(f1 CHAR(100), FULLTEXT idx(f1))ENGINE=InnoDB; +INSERT INTO t1 VALUES('mysql'), ('innodb'); +set debug_dbug="+d,fts_instrument_sync_debug"; +INSERT INTO t1 VALUES('test'); +set debug_dbug="-d,fts_instrument_sync_debug"; +INSERT INTO t1 VALUES('This is a fts issue'); +set debug_dbug="+d,fts_instrument_sync_debug"; +UPDATE t1 SET f1="mariadb"; +set debug_dbug="-d,fts_instrument_sync_debug"; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/t/misc_debug2.test b/mysql-test/suite/innodb_fts/t/misc_debug2.test index 0a9e137dd80..1ba77f2481e 100644 --- a/mysql-test/suite/innodb_fts/t/misc_debug2.test +++ b/mysql-test/suite/innodb_fts/t/misc_debug2.test @@ -10,3 +10,18 @@ INSERT INTO mdev21563 VALUES('This is a test'); ALTER TABLE mdev21563 DISCARD TABLESPACE; --source include/restart_mysqld.inc DROP TABLE mdev21563; + +--echo # +--echo # MDEV-29342 Assertion failure in file que0que.cc line 728 +--echo # +CREATE TABLE t1(f1 CHAR(100), FULLTEXT idx(f1))ENGINE=InnoDB; +INSERT INTO t1 VALUES('mysql'), ('innodb'); +set debug_dbug="+d,fts_instrument_sync_debug"; +INSERT INTO t1 VALUES('test'); +set debug_dbug="-d,fts_instrument_sync_debug"; +INSERT INTO t1 VALUES('This is a fts issue'); +--source include/restart_mysqld.inc +set debug_dbug="+d,fts_instrument_sync_debug"; +UPDATE t1 SET f1="mariadb"; +set debug_dbug="-d,fts_instrument_sync_debug"; +DROP TABLE t1; diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 6ac41ac1f03..b16bb6611b0 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -2667,7 +2667,7 @@ retry: } mutex_exit(&cache->doc_id_lock); - if (cmp_doc_id > *doc_id) { + if (cmp_doc_id && cmp_doc_id >= *doc_id) { error = fts_update_sync_doc_id( table, cache->synced_doc_id, trx); }