Skip to content

Commit

Permalink
MDEV-29342 Assertion failure in file que0que.cc line 728
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dr-m committed Sep 7, 2022
1 parent 1872a14 commit bacaf2d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
8 changes: 4 additions & 4 deletions mysql-test/suite/innodb_fts/r/misc_debug2.result
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ DROP TABLE mdev21563;
#
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";
set debug_dbug="+d,fts_instrument_sync_request";
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');
# restart
set debug_dbug="+d,fts_instrument_sync_debug";
set debug_dbug="+d,fts_instrument_sync_request";
UPDATE t1 SET f1="mariadb";
set debug_dbug="-d,fts_instrument_sync_debug";
set debug_dbug="-d,fts_instrument_sync_request";
DROP TABLE t1;
8 changes: 4 additions & 4 deletions mysql-test/suite/innodb_fts/t/misc_debug2.test
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ DROP TABLE mdev21563;
--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";
set debug_dbug="+d,fts_instrument_sync_request";
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');
--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";
set debug_dbug="-d,fts_instrument_sync_debug";
set debug_dbug="-d,fts_instrument_sync_request";
DROP TABLE t1;
14 changes: 8 additions & 6 deletions storage/innobase/fts/fts0fts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3314,7 +3314,7 @@ fts_add_doc_by_id(
dict_index_t* fts_id_index;
ibool is_id_cluster;
fts_cache_t* cache = ftt->table->fts->cache;

bool need_sync= false;
ut_ad(cache->get_docs);

/* If Doc ID has been supplied by the user, then the table
Expand Down Expand Up @@ -3443,7 +3443,7 @@ fts_add_doc_by_id(
shouldn't hold the cache lock for
longer time. So cache should sync
whenever cache size exceeds 512 KB */
bool need_sync =
need_sync =
cache->total_size > 512*1024;

mysql_mutex_unlock(&table->fts->cache->lock);
Expand All @@ -3464,10 +3464,6 @@ fts_add_doc_by_id(
need_sync= true;
);

if (need_sync) {
fts_sync_table(table);
}

mtr_start(&mtr);

if (i < num_idx - 1) {
Expand All @@ -3493,6 +3489,10 @@ fts_add_doc_by_id(
ut_free(pcur.old_rec_buf);

mem_heap_free(heap);

if (need_sync) {
fts_sync_table(table);
}
}


Expand Down Expand Up @@ -3898,6 +3898,7 @@ fts_sync_write_words(
ib::error() << "(" << error << ") writing"
" word node to FTS auxiliary index table "
<< table->name;
break;
}
}

Expand Down Expand Up @@ -3999,6 +4000,7 @@ fts_sync_commit(
mysql_mutex_unlock(&cache->lock);
fts_sql_commit(trx);
} else {
mysql_mutex_unlock(&cache->lock);
fts_sql_rollback(trx);
ib::error() << "(" << error << ") during SYNC of "
"table " << sync->table->name;
Expand Down

0 comments on commit bacaf2d

Please sign in to comment.