MDEV-32017 Auto-increment no longer works for explicit FTS_DOC_ID

- InnoDB should avoid the sync commit operation when
there is nothing in fulltext cache. This is caused by
commit 1248fe727784bb6be73f70163353cf8457cfde69 (MDEV-27582)
This commit is contained in:
Thirunarayanan Balathandayuthapani 2023-10-12 14:48:43 +05:30
parent 156bf5298f
commit a2312b6fb2
4 changed files with 33 additions and 1 deletions

View File

@ -318,3 +318,16 @@ DROP TABLE t1;
disconnect con1;
SET GLOBAL innodb_optimize_fulltext_only=OFF;
SET GLOBAL innodb_ft_aux_table = default;
#
# MDEV-32017 Auto-increment no longer works for
# explicit FTS_DOC_ID
#
CREATE TABLE t (
FTS_DOC_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
f1 char(255), f2 char(255), f3 char(255), fulltext key (f3)
) ENGINE=InnoDB;
INSERT INTO t (f1,f2,f3) VALUES ('foo','bar','baz');
ALTER TABLE t ADD FULLTEXT INDEX ft1(f1);
ALTER TABLE t ADD FULLTEXT INDEX ft2(f2);
INSERT INTO t (f1,f2,f3) VALUES ('bar','baz','qux');
DROP TABLE t;

View File

@ -397,3 +397,17 @@ DROP TABLE t1;
disconnect con1;
SET GLOBAL innodb_optimize_fulltext_only=OFF;
SET GLOBAL innodb_ft_aux_table = default;
--echo #
--echo # MDEV-32017 Auto-increment no longer works for
--echo # explicit FTS_DOC_ID
--echo #
CREATE TABLE t (
FTS_DOC_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
f1 char(255), f2 char(255), f3 char(255), fulltext key (f3)
) ENGINE=InnoDB;
INSERT INTO t (f1,f2,f3) VALUES ('foo','bar','baz');
ALTER TABLE t ADD FULLTEXT INDEX ft1(f1);
ALTER TABLE t ADD FULLTEXT INDEX ft2(f2);
INSERT INTO t (f1,f2,f3) VALUES ('bar','baz','qux');
DROP TABLE t;

View File

@ -4304,6 +4304,11 @@ fts_sync(
size_t fts_cache_size= 0;
rw_lock_x_lock(&cache->lock);
if (cache->total_size == 0) {
rw_lock_x_unlock(&cache->lock);
return DB_SUCCESS;
}
/* Check if cache is being synced.
Note: we release cache lock in fts_sync_write_words() to
avoid long wait for the lock by other threads. */

View File

@ -2828,7 +2828,7 @@ wait_again:
if (err == DB_SUCCESS) {
new_table->fts->cache->synced_doc_id = max_doc_id;
/* Update the max value as next FTS_DOC_ID */
/* Update the max value as next FTS_DOC_ID */
if (max_doc_id >= new_table->fts->cache->next_doc_id) {
new_table->fts->cache->next_doc_id =
max_doc_id + 1;