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.
include/thr_lock.h:
Update prototype.
mysql-test/r/delayed.result:
Add test case result for Bug#40536
mysql-test/t/delayed.test:
Add test case for Bug#40536
mysys/thr_lock.c:
Add function parameter which specifies the write lock type.
sql/sql_insert.cc:
Take a low priority write lock if global value of low_priority_updates
was ON when the thread was created.
This commit is contained in:
@@ -1690,6 +1690,7 @@ public:
|
||||
|
||||
class Delayed_insert :public ilink {
|
||||
uint locks_in_memory;
|
||||
thr_lock_type delayed_lock;
|
||||
public:
|
||||
THD thd;
|
||||
TABLE *table;
|
||||
@@ -1731,6 +1732,8 @@ public:
|
||||
pthread_cond_init(&cond_client,NULL);
|
||||
VOID(pthread_mutex_lock(&LOCK_thread_count));
|
||||
delayed_insert_threads++;
|
||||
delayed_lock= global_system_variables.low_priority_updates ?
|
||||
TL_WRITE_LOW_PRIORITY : TL_WRITE;
|
||||
VOID(pthread_mutex_unlock(&LOCK_thread_count));
|
||||
}
|
||||
~Delayed_insert()
|
||||
@@ -2540,7 +2543,7 @@ bool Delayed_insert::handle_inserts(void)
|
||||
table->use_all_columns();
|
||||
|
||||
thd_proc_info(&thd, "upgrading lock");
|
||||
if (thr_upgrade_write_delay_lock(*thd.lock->locks))
|
||||
if (thr_upgrade_write_delay_lock(*thd.lock->locks, delayed_lock))
|
||||
{
|
||||
/*
|
||||
This can happen if thread is killed either by a shutdown
|
||||
|
||||
Reference in New Issue
Block a user