Skip to content
Permalink
Browse files
MDEV-29277 On error, fts_sync_table() fails to release a table handle
 fts_sync_commit() fails to release the auxiliary table handle
when it encounters error. This issue is caused by
commit 1fd7d3a(MDEV-25581).
fts_cache_clear() releases the auxiliary table handles.
MDEV-25581's patch clear the cache only if fts_sync_commit was
successful.
  • Loading branch information
Thirunarayanan committed Sep 23, 2022
1 parent ca51c9f commit 673243c
Showing 1 changed file with 39 additions and 39 deletions.
@@ -3960,6 +3960,43 @@ fts_sync_index(
return(fts_sync_write_words(trx, index_cache));
}

/** Rollback a sync operation
@param[in,out] sync sync state */
static
void
fts_sync_rollback(
fts_sync_t* sync)
{
trx_t* trx = sync->trx;
fts_cache_t* cache = sync->table->fts->cache;

for (ulint i = 0; i < ib_vector_size(cache->indexes); ++i) {
ulint j;
fts_index_cache_t* index_cache;

index_cache = static_cast<fts_index_cache_t*>(
ib_vector_get(cache->indexes, i));

for (j = 0; fts_index_selector[j].value; ++j) {

if (index_cache->ins_graph[j] != NULL) {

que_graph_free(index_cache->ins_graph[j]);

index_cache->ins_graph[j] = NULL;
}
}
}

mysql_mutex_unlock(&cache->lock);

fts_sql_rollback(trx);

/* Avoid assertion in trx_t::free(). */
trx->dict_operation_lock_mode = false;
trx->free();
}

/** Commit the SYNC, change state of processed doc ids etc.
@param[in,out] sync sync state
@return DB_SUCCESS if all OK */
@@ -4000,10 +4037,10 @@ 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;
fts_sync_rollback(sync);
return error;
}

if (UNIV_UNLIKELY(fts_enable_diag_print) && elapsed_time) {
@@ -4023,43 +4060,6 @@ fts_sync_commit(
return(error);
}

/** Rollback a sync operation
@param[in,out] sync sync state */
static
void
fts_sync_rollback(
fts_sync_t* sync)
{
trx_t* trx = sync->trx;
fts_cache_t* cache = sync->table->fts->cache;

for (ulint i = 0; i < ib_vector_size(cache->indexes); ++i) {
ulint j;
fts_index_cache_t* index_cache;

index_cache = static_cast<fts_index_cache_t*>(
ib_vector_get(cache->indexes, i));

for (j = 0; fts_index_selector[j].value; ++j) {

if (index_cache->ins_graph[j] != NULL) {

que_graph_free(index_cache->ins_graph[j]);

index_cache->ins_graph[j] = NULL;
}
}
}

mysql_mutex_unlock(&cache->lock);

fts_sql_rollback(trx);

/* Avoid assertion in trx_t::free(). */
trx->dict_operation_lock_mode = false;
trx->free();
}

/** Run SYNC on the table, i.e., write out data from the cache to the
FTS auxiliary INDEX table and clear the cache at the end.
@param[in,out] sync sync state

0 comments on commit 673243c

Please sign in to comment.