1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

Bug #29154: LOCK TABLES is not atomic when >1 InnoDB tables are locked

LOCK TABLES takes a list of tables to lock. It may lock several 
  tables successfully and then encounter a tables that it can't lock, 
  e.g. because it's locked. In such case it needs to undo the locks on
  the already locked tables. And it does that. But it has also notified
  the relevant table storage engine handlers that they should lock.
  The only reliable way to ensure that the table handlers will give up
  their locks is to end the transaction. This is what UNLOCK TABLE 
  does : it ends the transaction if there were locked tables by LOCK 
  tables.
  It is possible to end the transaction when the lock fails in 
  LOCK TABLES because LOCK TABLES ends the transaction at its start 
  already. 
  Fixed by ending (again) the transaction when LOCK TABLES fails to
  lock a table.
This commit is contained in:
gkodinov/kgeorge@magare.gmz
2007-06-25 10:44:52 +03:00
parent 8a6b7f7cca
commit f93607d2ea
3 changed files with 62 additions and 1 deletions

View File

@ -3837,7 +3837,10 @@ end_with_restore_list:
break;
case SQLCOM_LOCK_TABLES:
unlock_locked_tables(thd);
if (check_db_used(thd, all_tables) || end_active_trans(thd))
/* we must end the trasaction first, regardless of anything */
if (end_active_trans(thd))
goto error;
if (check_db_used(thd, all_tables))
goto error;
if (check_table_access(thd, LOCK_TABLES_ACL | SELECT_ACL, all_tables, 0))
goto error;
@ -3855,7 +3858,15 @@ end_with_restore_list:
send_ok(thd);
}
else
{
/*
Need to end the current transaction, so the storage engine (InnoDB)
can free its locks if LOCK TABLES locked some tables before finding
that it can't lock a table in its list
*/
end_active_trans(thd);
thd->options&= ~(ulong) (OPTION_TABLE_LOCK);
}
thd->in_lock_tables=0;
break;
case SQLCOM_CREATE_DB: