1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00
remove_table_from_cache fails to signal other thread and gets
blocked when other thread also gets blocked


include/thr_lock.h:
  Report if any threads was signalled
mysys/thr_lock.c:
  Report if any threads was signalled
sql/lock.cc:
  Report if any threads was signalled
  Use new interface for remove_table_from_cache
sql/mysql_priv.h:
  New interface for remove_table_from_cache
  + mysql_lock_abort_for_thread
sql/sql_base.cc:
  Use new interface of remove_table_cache
  Rewrote remove_table_from_cache to fix bug
sql/sql_table.cc:
  Use new interface of remove_table_from_cache
This commit is contained in:
unknown
2005-07-19 00:29:19 +02:00
parent 5c27ff06c7
commit 6d29b23b15
6 changed files with 133 additions and 77 deletions

View File

@ -178,6 +178,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
for (table=tables ; table ; table=table->next)
{
char *db=table->db;
uint flags;
mysql_ha_flush(thd, table, MYSQL_HA_CLOSE_FINAL);
if (!close_temporary_table(thd, db, table->real_name))
{
@ -186,12 +187,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
}
abort_locked_tables(thd,db,table->real_name);
while (remove_table_from_cache(thd,db,table->real_name) && !thd->killed)
{
dropping_tables++;
(void) pthread_cond_wait(&COND_refresh,&LOCK_open);
dropping_tables--;
}
flags= WAIT_OTHER_THREAD_FLAG | CHECK_KILLED_FLAG;
remove_table_from_cache(thd,db,table->real_name,flags);
drop_locked_tables(thd,db,table->real_name);
if (thd->killed)
DBUG_RETURN(-1);
@ -979,6 +976,7 @@ mysql_rename_table(enum db_type base,
static void wait_while_table_is_used(THD *thd,TABLE *table,
enum ha_extra_function function)
{
uint flags;
DBUG_PRINT("enter",("table: %s", table->real_name));
DBUG_ENTER("wait_while_table_is_used");
safe_mutex_assert_owner(&LOCK_open);
@ -988,13 +986,9 @@ static void wait_while_table_is_used(THD *thd,TABLE *table,
mysql_lock_abort(thd, table); // end threads waiting on lock
/* Wait until all there are no other threads that has this table open */
while (remove_table_from_cache(thd,table->table_cache_key,
table->real_name))
{
dropping_tables++;
(void) pthread_cond_wait(&COND_refresh,&LOCK_open);
dropping_tables--;
}
flags= WAIT_OTHER_THREAD_FLAG;
remove_table_from_cache(thd,table->table_cache_key,
table->real_name,flags);
DBUG_VOID_RETURN;
}
@ -1306,18 +1300,14 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
/* Close all instances of the table to allow repair to rename files */
if (lock_type == TL_WRITE && table->table->version)
{
uint flags;
pthread_mutex_lock(&LOCK_open);
const char *old_message=thd->enter_cond(&COND_refresh, &LOCK_open,
"Waiting to get writelock");
mysql_lock_abort(thd,table->table);
while (remove_table_from_cache(thd, table->table->table_cache_key,
table->table->real_name) &&
! thd->killed)
{
dropping_tables++;
(void) pthread_cond_wait(&COND_refresh,&LOCK_open);
dropping_tables--;
}
flags= WAIT_OTHER_THREAD_FLAG | CHECK_KILLED_FLAG;
remove_table_from_cache(thd, table->table->table_cache_key,
table->table->real_name, flags);
thd->exit_cond(old_message);
if (thd->killed)
goto err;
@ -1382,9 +1372,10 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
table->table->version=0; // Force close of table
else if (open_for_modify)
{
uint flags= 0;
pthread_mutex_lock(&LOCK_open);
remove_table_from_cache(thd, table->table->table_cache_key,
table->table->real_name);
table->table->real_name, flags);
pthread_mutex_unlock(&LOCK_open);
/* May be something modified consequently we have to invalidate cache */
query_cache_invalidate3(thd, table->table, 0);
@ -2108,8 +2099,9 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
*/
if (table)
{
uint flags= 0;
VOID(table->file->extra(HA_EXTRA_FORCE_REOPEN)); // Use new file
remove_table_from_cache(thd,db,table_name); // Mark all in-use copies old
remove_table_from_cache(thd,db,table_name,flags);// Mark in-use copies old
mysql_lock_abort(thd,table); // end threads waiting on lock
}
VOID(quick_rm_table(old_db_type,db,old_name));