mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
Bug#40536: SELECT is blocked by INSERT DELAYED waiting on
upgrading lock, even with low_priority_updates
The problem is that there is no mechanism to control whether a
delayed insert takes a high or low priority lock on a table.
The solution is to modify the delayed insert thread ("handler")
to take into account the global value of low_priority_updates
when taking table locks. The value of low_priority_updates is
retrieved when the insert delayed thread is created and will
remain the same for the duration of the thread.
This commit is contained in:
@@ -1359,7 +1359,8 @@ void thr_downgrade_write_lock(THR_LOCK_DATA *in_data,
|
||||
|
||||
/* Upgrade a WRITE_DELAY lock to a WRITE_LOCK */
|
||||
|
||||
my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data)
|
||||
my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data,
|
||||
enum thr_lock_type new_lock_type)
|
||||
{
|
||||
THR_LOCK *lock=data->lock;
|
||||
DBUG_ENTER("thr_upgrade_write_delay_lock");
|
||||
@@ -1372,7 +1373,7 @@ my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data)
|
||||
}
|
||||
check_locks(lock,"before upgrading lock",0);
|
||||
/* TODO: Upgrade to TL_WRITE_CONCURRENT_INSERT in some cases */
|
||||
data->type=TL_WRITE; /* Upgrade lock */
|
||||
data->type= new_lock_type; /* Upgrade lock */
|
||||
|
||||
/* Check if someone has given us the lock */
|
||||
if (!data->cond)
|
||||
@@ -1411,6 +1412,7 @@ my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data)
|
||||
my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data)
|
||||
{
|
||||
THR_LOCK *lock=data->lock;
|
||||
enum thr_lock_type write_lock_type;
|
||||
DBUG_ENTER("thr_reschedule_write_lock");
|
||||
|
||||
pthread_mutex_lock(&lock->mutex);
|
||||
@@ -1420,6 +1422,7 @@ my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data)
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
write_lock_type= data->type;
|
||||
data->type=TL_WRITE_DELAYED;
|
||||
if (lock->update_status)
|
||||
(*lock->update_status)(data->status_param);
|
||||
@@ -1438,7 +1441,7 @@ my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data)
|
||||
free_all_read_locks(lock,0);
|
||||
|
||||
pthread_mutex_unlock(&lock->mutex);
|
||||
DBUG_RETURN(thr_upgrade_write_delay_lock(data));
|
||||
DBUG_RETURN(thr_upgrade_write_delay_lock(data, write_lock_type));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user