Commit bacaf2d4 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-29342 Assertion failure in file que0que.cc line 728

Additional fixes for 10.6:

fts_sync_commit(): Release cache->lock also on rollback.

fts_sync_write_words(): Avoid a crash if an error occurs,
by stopping at the first error.

fts_add_doc_by_id(): Sync the doc id only after adding the doc id
to the cache.
parent 1872a142
...@@ -11,12 +11,12 @@ DROP TABLE mdev21563; ...@@ -11,12 +11,12 @@ DROP TABLE mdev21563;
# #
CREATE TABLE t1(f1 CHAR(100), FULLTEXT idx(f1))ENGINE=InnoDB; CREATE TABLE t1(f1 CHAR(100), FULLTEXT idx(f1))ENGINE=InnoDB;
INSERT INTO t1 VALUES('mysql'), ('innodb'); INSERT INTO t1 VALUES('mysql'), ('innodb');
set debug_dbug="+d,fts_instrument_sync_debug"; set debug_dbug="+d,fts_instrument_sync_request";
INSERT INTO t1 VALUES('test'); INSERT INTO t1 VALUES('test');
set debug_dbug="-d,fts_instrument_sync_debug"; set debug_dbug="-d,fts_instrument_sync_request";
INSERT INTO t1 VALUES('This is a fts issue'); INSERT INTO t1 VALUES('This is a fts issue');
# restart # restart
set debug_dbug="+d,fts_instrument_sync_debug"; set debug_dbug="+d,fts_instrument_sync_request";
UPDATE t1 SET f1="mariadb"; UPDATE t1 SET f1="mariadb";
set debug_dbug="-d,fts_instrument_sync_debug"; set debug_dbug="-d,fts_instrument_sync_request";
DROP TABLE t1; DROP TABLE t1;
...@@ -16,12 +16,12 @@ DROP TABLE mdev21563; ...@@ -16,12 +16,12 @@ DROP TABLE mdev21563;
--echo # --echo #
CREATE TABLE t1(f1 CHAR(100), FULLTEXT idx(f1))ENGINE=InnoDB; CREATE TABLE t1(f1 CHAR(100), FULLTEXT idx(f1))ENGINE=InnoDB;
INSERT INTO t1 VALUES('mysql'), ('innodb'); INSERT INTO t1 VALUES('mysql'), ('innodb');
set debug_dbug="+d,fts_instrument_sync_debug"; set debug_dbug="+d,fts_instrument_sync_request";
INSERT INTO t1 VALUES('test'); INSERT INTO t1 VALUES('test');
set debug_dbug="-d,fts_instrument_sync_debug"; set debug_dbug="-d,fts_instrument_sync_request";
INSERT INTO t1 VALUES('This is a fts issue'); INSERT INTO t1 VALUES('This is a fts issue');
--source include/restart_mysqld.inc --source include/restart_mysqld.inc
set debug_dbug="+d,fts_instrument_sync_debug"; set debug_dbug="+d,fts_instrument_sync_request";
UPDATE t1 SET f1="mariadb"; UPDATE t1 SET f1="mariadb";
set debug_dbug="-d,fts_instrument_sync_debug"; set debug_dbug="-d,fts_instrument_sync_request";
DROP TABLE t1; DROP TABLE t1;
...@@ -3314,7 +3314,7 @@ fts_add_doc_by_id( ...@@ -3314,7 +3314,7 @@ fts_add_doc_by_id(
dict_index_t* fts_id_index; dict_index_t* fts_id_index;
ibool is_id_cluster; ibool is_id_cluster;
fts_cache_t* cache = ftt->table->fts->cache; fts_cache_t* cache = ftt->table->fts->cache;
bool need_sync= false;
ut_ad(cache->get_docs); ut_ad(cache->get_docs);
/* If Doc ID has been supplied by the user, then the table /* If Doc ID has been supplied by the user, then the table
...@@ -3443,7 +3443,7 @@ fts_add_doc_by_id( ...@@ -3443,7 +3443,7 @@ fts_add_doc_by_id(
shouldn't hold the cache lock for shouldn't hold the cache lock for
longer time. So cache should sync longer time. So cache should sync
whenever cache size exceeds 512 KB */ whenever cache size exceeds 512 KB */
bool need_sync = need_sync =
cache->total_size > 512*1024; cache->total_size > 512*1024;
mysql_mutex_unlock(&table->fts->cache->lock); mysql_mutex_unlock(&table->fts->cache->lock);
...@@ -3464,10 +3464,6 @@ fts_add_doc_by_id( ...@@ -3464,10 +3464,6 @@ fts_add_doc_by_id(
need_sync= true; need_sync= true;
); );
if (need_sync) {
fts_sync_table(table);
}
mtr_start(&mtr); mtr_start(&mtr);
if (i < num_idx - 1) { if (i < num_idx - 1) {
...@@ -3493,6 +3489,10 @@ fts_add_doc_by_id( ...@@ -3493,6 +3489,10 @@ fts_add_doc_by_id(
ut_free(pcur.old_rec_buf); ut_free(pcur.old_rec_buf);
mem_heap_free(heap); mem_heap_free(heap);
if (need_sync) {
fts_sync_table(table);
}
} }
...@@ -3898,6 +3898,7 @@ fts_sync_write_words( ...@@ -3898,6 +3898,7 @@ fts_sync_write_words(
ib::error() << "(" << error << ") writing" ib::error() << "(" << error << ") writing"
" word node to FTS auxiliary index table " " word node to FTS auxiliary index table "
<< table->name; << table->name;
break;
} }
} }
...@@ -3999,6 +4000,7 @@ fts_sync_commit( ...@@ -3999,6 +4000,7 @@ fts_sync_commit(
mysql_mutex_unlock(&cache->lock); mysql_mutex_unlock(&cache->lock);
fts_sql_commit(trx); fts_sql_commit(trx);
} else { } else {
mysql_mutex_unlock(&cache->lock);
fts_sql_rollback(trx); fts_sql_rollback(trx);
ib::error() << "(" << error << ") during SYNC of " ib::error() << "(" << error << ") during SYNC of "
"table " << sync->table->name; "table " << sync->table->name;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment