Skip to content

Commit 10b88de

Browse files
committed
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
1 parent 74df3c8 commit 10b88de

File tree

12 files changed

+42
-33
lines changed

12 files changed

+42
-33
lines changed

include/thr_lock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ typedef struct st_thr_lock {
126126
/* write_lock_count is incremented for write locks and reset on read locks */
127127
ulong write_lock_count;
128128
uint read_no_write_count;
129-
void (*get_status)(void*, my_bool); /* When one gets a lock */
129+
my_bool (*get_status)(void*, my_bool);/* Called when one gets a lock */
130130
void (*copy_status)(void*,void*);
131131
void (*update_status)(void*); /* Before release of write */
132132
void (*restore_status)(void*); /* Before release of read */

mysys/thr_lock.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -634,9 +634,10 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
634634
else
635635
{
636636
result= THR_LOCK_SUCCESS;
637-
if (data->lock->get_status)
638-
(*data->lock->get_status)(data->status_param,
639-
data->type == TL_WRITE_CONCURRENT_INSERT);
637+
if (data->lock->get_status &&
638+
(*data->lock->get_status)(data->status_param,
639+
data->type == TL_WRITE_CONCURRENT_INSERT))
640+
result= THR_LOCK_ABORTED;
640641
check_locks(data->lock,"got wait_for_lock", data->type, 0);
641642
}
642643
mysql_mutex_unlock(&data->lock->mutex);
@@ -811,8 +812,8 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout)
811812
if (lock_type == TL_READ_NO_INSERT)
812813
lock->read_no_write_count++;
813814
check_locks(lock,"read lock with old write lock", lock_type, 0);
814-
if (lock->get_status)
815-
(*lock->get_status)(data->status_param, 0);
815+
if ((lock->get_status) && (*lock->get_status)(data->status_param, 0))
816+
result= THR_LOCK_ABORTED;
816817
statistic_increment(locks_immediate,&THR_LOCK_lock);
817818
goto end;
818819
}
@@ -835,8 +836,8 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout)
835836
if (lock_type == TL_READ_NO_INSERT)
836837
lock->read_no_write_count++;
837838
check_locks(lock,"read lock with no write locks", lock_type, 0);
838-
if (lock->get_status)
839-
(*lock->get_status)(data->status_param, 0);
839+
if ((lock->get_status) && (*lock->get_status)(data->status_param, 0))
840+
result= THR_LOCK_ABORTED;
840841
statistic_increment(locks_immediate,&THR_LOCK_lock);
841842
goto end;
842843
}
@@ -951,9 +952,10 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout)
951952
data->prev=lock->write.last;
952953
lock->write.last= &data->next;
953954
check_locks(lock,"second write lock", lock_type, 0);
954-
if (lock->get_status)
955-
(*lock->get_status)(data->status_param,
956-
lock_type == TL_WRITE_CONCURRENT_INSERT);
955+
if ((lock->get_status) &&
956+
(*lock->get_status)(data->status_param,
957+
lock_type == TL_WRITE_CONCURRENT_INSERT))
958+
result= THR_LOCK_ABORTED;
957959
statistic_increment(locks_immediate,&THR_LOCK_lock);
958960
goto end;
959961
}
@@ -986,8 +988,9 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout)
986988
(*lock->write.last)=data; /* Add as current write lock */
987989
data->prev=lock->write.last;
988990
lock->write.last= &data->next;
989-
if (lock->get_status)
990-
(*lock->get_status)(data->status_param, concurrent_insert);
991+
if ((lock->get_status) &&
992+
(*lock->get_status)(data->status_param, concurrent_insert))
993+
result= THR_LOCK_ABORTED;
991994
check_locks(lock,"only write lock", lock_type, 0);
992995
statistic_increment(locks_immediate,&THR_LOCK_lock);
993996
goto end;
@@ -1581,6 +1584,7 @@ my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data,
15811584
{
15821585
if (!lock->read.data) /* No read locks */
15831586
{ /* We have the lock */
1587+
/* For this function, get_status is not allowed to fail */
15841588
if (data->lock->get_status)
15851589
(*data->lock->get_status)(data->status_param, 0);
15861590
mysql_mutex_unlock(&lock->mutex);
@@ -1781,9 +1785,10 @@ static ulong sum=0;
17811785

17821786
/* The following functions is for WRITE_CONCURRENT_INSERT */
17831787

1784-
static void test_get_status(void* param __attribute__((unused)),
1785-
my_bool concurrent_insert __attribute__((unused)))
1788+
static my_bool test_get_status(void* param __attribute__((unused)),
1789+
my_bool concurrent_insert __attribute__((unused)))
17861790
{
1791+
return 0;
17871792
}
17881793

17891794
static void test_update_status(void* param __attribute__((unused)))

sql/handler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4866,9 +4866,9 @@ class handler :public Sql_alloc
48664866
DBUG_ASSERT(!(ha_table_flags() & HA_CAN_REPAIR));
48674867
return HA_ADMIN_NOT_IMPLEMENTED;
48684868
}
4869+
protected:
48694870
virtual void start_bulk_insert(ha_rows rows, uint flags) {}
48704871
virtual int end_bulk_insert() { return 0; }
4871-
protected:
48724872
virtual int index_read(uchar * buf, const uchar * key, uint key_len,
48734873
enum ha_rkey_function find_flag)
48744874
{ return HA_ERR_WRONG_COMMAND; }

storage/csv/ha_tina.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,10 +883,11 @@ int ha_tina::find_current_row(uchar *buf)
883883
for CSV engine. For more details see mysys/thr_lock.c
884884
*/
885885

886-
void tina_get_status(void* param, my_bool concurrent_insert)
886+
my_bool tina_get_status(void* param, my_bool concurrent_insert)
887887
{
888888
ha_tina *tina= (ha_tina*) param;
889889
tina->get_status();
890+
return 0;
890891
}
891892

892893
void tina_update_status(void* param)

storage/maria/ha_maria.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ extern ulonglong maria_recover_options;
4040

4141
class ha_maria :public handler
4242
{
43+
public:
4344
MARIA_HA *file;
45+
private:
4446
ulonglong int_table_flags;
4547
MARIA_RECORD_POS remember_pos;
4648
char *data_file_name, *index_file_name;

storage/maria/ma_blockrec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ my_bool write_hook_for_file_id(enum translog_record_type type,
306306
my_bool write_hook_for_commit(enum translog_record_type type,
307307
TRN *trn, MARIA_HA *tbl_info, LSN *lsn,
308308
void *hook_arg);
309-
void _ma_block_get_status(void *param, my_bool concurrent_insert);
309+
my_bool _ma_block_get_status(void *param, my_bool concurrent_insert);
310310
my_bool _ma_block_start_trans(void* param);
311311
my_bool _ma_block_start_trans_no_versioning(void *param);
312312
void _ma_block_update_status(void *param);

storage/maria/ma_check.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2372,7 +2372,7 @@ static int initialize_variables_for_repair(HA_CHECK *param,
23722372

23732373
/* Repair code relies on share->state.state so we have to update it here */
23742374
if (share->lock.update_status)
2375-
(*share->lock.update_status)(info);
2375+
(*share->lock.update_status)(info->lock.status_param);
23762376

23772377
bzero((char*) sort_info, sizeof(*sort_info));
23782378
bzero((char*) sort_param, sizeof(*sort_param));

storage/maria/ma_state.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ void _ma_reset_state(MARIA_HA *info)
282282
(THR_WRITE_CONCURRENT_INSERT was used)
283283
*/
284284

285-
void _ma_get_status(void* param, my_bool concurrent_insert)
285+
my_bool _ma_get_status(void* param, my_bool concurrent_insert)
286286
{
287287
MARIA_HA *info=(MARIA_HA*) param;
288288
DBUG_ENTER("_ma_get_status");
@@ -301,7 +301,7 @@ void _ma_get_status(void* param, my_bool concurrent_insert)
301301
info->state= &info->state_save;
302302
info->state->changed= 0;
303303
info->append_insert_at_end= concurrent_insert;
304-
DBUG_VOID_RETURN;
304+
DBUG_RETURN(0);
305305
}
306306

307307

@@ -359,7 +359,7 @@ void _ma_update_status_with_lock(MARIA_HA *info)
359359
locked= 1;
360360
mysql_mutex_lock(&info->s->lock.mutex);
361361
}
362-
(*info->s->lock.update_status)(info);
362+
(*info->s->lock.update_status)(info->lock.status_param);
363363
if (locked)
364364
mysql_mutex_unlock(&info->s->lock.mutex);
365365
}
@@ -379,11 +379,12 @@ void _ma_copy_status(void* to, void *from)
379379
}
380380

381381

382-
void _ma_reset_update_flag(void *param,
383-
my_bool concurrent_insert __attribute__((unused)))
382+
my_bool _ma_reset_update_flag(void *param,
383+
my_bool concurrent_insert __attribute__((unused)))
384384
{
385385
MARIA_HA *info=(MARIA_HA*) param;
386386
info->state->changed= 0;
387+
return 0;
387388
}
388389

389390
my_bool _ma_start_trans(void* param)
@@ -628,7 +629,7 @@ void _ma_remove_table_from_trnman(MARIA_HA *info)
628629
(THR_WRITE_CONCURRENT_INSERT was used)
629630
*/
630631

631-
void _ma_block_get_status(void* param, my_bool concurrent_insert)
632+
my_bool _ma_block_get_status(void* param, my_bool concurrent_insert)
632633
{
633634
MARIA_HA *info=(MARIA_HA*) param;
634635
DBUG_ENTER("_ma_block_get_status");
@@ -647,7 +648,7 @@ void _ma_block_get_status(void* param, my_bool concurrent_insert)
647648
{
648649
DBUG_ASSERT(info->lock.type != TL_WRITE_CONCURRENT_INSERT);
649650
}
650-
DBUG_VOID_RETURN;
651+
DBUG_RETURN(0);
651652
}
652653

653654

storage/maria/ma_state.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ MARIA_STATE_HISTORY *_ma_remove_not_visible_states(MARIA_STATE_HISTORY
6161
my_bool all,
6262
my_bool trman_is_locked);
6363
void _ma_reset_state(MARIA_HA *info);
64-
void _ma_get_status(void* param, my_bool concurrent_insert);
64+
my_bool _ma_get_status(void* param, my_bool concurrent_insert);
6565
void _ma_update_status(void* param);
6666
void _ma_update_status_with_lock(MARIA_HA *info);
6767
void _ma_restore_status(void *param);
6868
void _ma_copy_status(void* to, void *from);
69-
void _ma_reset_update_flag(void *param, my_bool concurrent_insert);
69+
my_bool _ma_reset_update_flag(void *param, my_bool concurrent_insert);
7070
my_bool _ma_start_trans(void* param);
7171
my_bool _ma_check_status(void *param);
72-
void _ma_block_get_status(void* param, my_bool concurrent_insert);
72+
my_bool _ma_block_get_status(void* param, my_bool concurrent_insert);
7373
void _ma_block_update_status(void *param);
7474
void _ma_block_restore_status(void *param);
7575
my_bool _ma_block_check_status(void *param);

storage/maria/maria_def.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ my_bool _ma_cmp_dynamic_unique(MARIA_HA *info, MARIA_UNIQUEDEF *def,
13701370
const uchar *record, MARIA_RECORD_POS pos);
13711371
my_bool _ma_unique_comp(MARIA_UNIQUEDEF *def, const uchar *a, const uchar *b,
13721372
my_bool null_are_equal);
1373-
void _ma_get_status(void *param, my_bool concurrent_insert);
1373+
my_bool _ma_get_status(void *param, my_bool concurrent_insert);
13741374
void _ma_update_status(void *param);
13751375
void _ma_restore_status(void *param);
13761376
void _ma_copy_status(void *to, void *from);

0 commit comments

Comments
 (0)