From 10b88deb74a77e75c49b8fc63fef666eaddc2e6e Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 3 Jun 2020 19:40:41 +0300 Subject: Changes needed for ColumnStore and insert cache MCOL-3875 Columnstore write cache The main change is to change thr_lock function get_status to return a value that indicates we have to abort the lock. Other thing: - Made start_bulk_insert() and end_bulk_insert() protected so that the insert cache can use these --- mysys/thr_lock.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'mysys/thr_lock.c') diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index 07ba1ec9eac..5004428505a 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -634,9 +634,10 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data, else { result= THR_LOCK_SUCCESS; - if (data->lock->get_status) - (*data->lock->get_status)(data->status_param, - data->type == TL_WRITE_CONCURRENT_INSERT); + if (data->lock->get_status && + (*data->lock->get_status)(data->status_param, + data->type == TL_WRITE_CONCURRENT_INSERT)) + result= THR_LOCK_ABORTED; check_locks(data->lock,"got wait_for_lock", data->type, 0); } mysql_mutex_unlock(&data->lock->mutex); @@ -811,8 +812,8 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout) if (lock_type == TL_READ_NO_INSERT) lock->read_no_write_count++; check_locks(lock,"read lock with old write lock", lock_type, 0); - if (lock->get_status) - (*lock->get_status)(data->status_param, 0); + if ((lock->get_status) && (*lock->get_status)(data->status_param, 0)) + result= THR_LOCK_ABORTED; statistic_increment(locks_immediate,&THR_LOCK_lock); goto end; } @@ -835,8 +836,8 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout) if (lock_type == TL_READ_NO_INSERT) lock->read_no_write_count++; check_locks(lock,"read lock with no write locks", lock_type, 0); - if (lock->get_status) - (*lock->get_status)(data->status_param, 0); + if ((lock->get_status) && (*lock->get_status)(data->status_param, 0)) + result= THR_LOCK_ABORTED; statistic_increment(locks_immediate,&THR_LOCK_lock); goto end; } @@ -951,9 +952,10 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout) data->prev=lock->write.last; lock->write.last= &data->next; check_locks(lock,"second write lock", lock_type, 0); - if (lock->get_status) - (*lock->get_status)(data->status_param, - lock_type == TL_WRITE_CONCURRENT_INSERT); + if ((lock->get_status) && + (*lock->get_status)(data->status_param, + lock_type == TL_WRITE_CONCURRENT_INSERT)) + result= THR_LOCK_ABORTED; statistic_increment(locks_immediate,&THR_LOCK_lock); goto end; } @@ -986,8 +988,9 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout) (*lock->write.last)=data; /* Add as current write lock */ data->prev=lock->write.last; lock->write.last= &data->next; - if (lock->get_status) - (*lock->get_status)(data->status_param, concurrent_insert); + if ((lock->get_status) && + (*lock->get_status)(data->status_param, concurrent_insert)) + result= THR_LOCK_ABORTED; check_locks(lock,"only write lock", lock_type, 0); statistic_increment(locks_immediate,&THR_LOCK_lock); goto end; @@ -1581,6 +1584,7 @@ my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data, { if (!lock->read.data) /* No read locks */ { /* We have the lock */ + /* For this function, get_status is not allowed to fail */ if (data->lock->get_status) (*data->lock->get_status)(data->status_param, 0); mysql_mutex_unlock(&lock->mutex); @@ -1781,9 +1785,10 @@ static ulong sum=0; /* The following functions is for WRITE_CONCURRENT_INSERT */ -static void test_get_status(void* param __attribute__((unused)), - my_bool concurrent_insert __attribute__((unused))) +static my_bool test_get_status(void* param __attribute__((unused)), + my_bool concurrent_insert __attribute__((unused))) { + return 0; } static void test_update_status(void* param __attribute__((unused))) -- cgit v1.2.1