1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Bug#9459 - deadlock with flush with lock, and lock table write

Added a check before taking a global read lock if
the own thread has a write locked table.


mysql-test/r/flush.result:
  Bug#9459 - deadlock with flush with lock, and lock table write
  The test result.
mysql-test/t/flush.test:
  Bug#9459 - deadlock with flush with lock, and lock table write
  The test case.
This commit is contained in:
unknown
2005-08-05 15:37:24 +02:00
parent 75c06af277
commit 2977a3a4b1
3 changed files with 69 additions and 0 deletions

View File

@ -5027,6 +5027,23 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
{
if ((options & REFRESH_READ_LOCK) && thd)
{
/*
We must not try to aspire a global read lock if we have a write
locked table. This would lead to a deadlock when trying to
reopen (and re-lock) the table after the flush.
*/
if (thd->locked_tables)
{
THR_LOCK_DATA **lock_p= thd->locked_tables->locks;
THR_LOCK_DATA **end_p= lock_p + thd->locked_tables->lock_count;
for (; lock_p < end_p; lock_p++)
if ((*lock_p)->type == TL_WRITE)
{
my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
return 1;
}
}
/*
Writing to the binlog could cause deadlocks, as we don't log
UNLOCK TABLES