Skip to content

Commit

Permalink
mark Aria allocations for temp tables as MY_THREAD_SPECIFIC
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Mar 8, 2021
1 parent 9742cf4 commit f24038b
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 63 deletions.
5 changes: 3 additions & 2 deletions storage/maria/ma_bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,16 @@ my_bool _ma_bitmap_init(MARIA_SHARE *share, File file,
uint max_page_size;
MARIA_FILE_BITMAP *bitmap= &share->bitmap;
uint size= share->block_size;
myf flag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
pgcache_page_no_t first_bitmap_with_space;
#ifndef DBUG_OFF
/* We want to have a copy of the bitmap to be able to print differences */
size*= 2;
#endif

if (((bitmap->map= (uchar*) my_malloc(size, MYF(MY_WME))) == NULL) ||
if (((bitmap->map= (uchar*) my_malloc(size, flag)) == NULL) ||
my_init_dynamic_array(&bitmap->pinned_pages,
sizeof(MARIA_PINNED_PAGE), 1, 1, MYF(0)))
sizeof(MARIA_PINNED_PAGE), 1, 1, flag))
return 1;

bitmap->share= share;
Expand Down
24 changes: 14 additions & 10 deletions storage/maria/ma_blockrec.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,11 @@ my_bool _ma_init_block_record(MARIA_HA *info)
{
MARIA_ROW *row= &info->cur_row, *new_row= &info->new_row;
MARIA_SHARE *share= info->s;
myf flag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
uint default_extents;
DBUG_ENTER("_ma_init_block_record");

if (!my_multi_malloc(MY_WME,
if (!my_multi_malloc(flag,
&row->empty_bits, share->base.pack_bytes,
&row->field_lengths,
share->base.max_field_lengths + 2,
Expand Down Expand Up @@ -527,13 +528,12 @@ my_bool _ma_init_block_record(MARIA_HA *info)
FULL_PAGE_SIZE(share) /
BLOB_SEGMENT_MIN_SIZE));

if (my_init_dynamic_array(&info->bitmap_blocks,
sizeof(MARIA_BITMAP_BLOCK), default_extents,
64, MYF(0)))
if (my_init_dynamic_array(&info->bitmap_blocks, sizeof(MARIA_BITMAP_BLOCK),
default_extents, 64, flag))
goto err;
info->cur_row.extents_buffer_length= default_extents * ROW_EXTENT_SIZE;
if (!(info->cur_row.extents= my_malloc(info->cur_row.extents_buffer_length,
MYF(MY_WME))))
flag)))
goto err;

info->row_base_length= share->base_length;
Expand Down Expand Up @@ -2642,6 +2642,7 @@ static my_bool write_block_record(MARIA_HA *info,
LSN lsn;
my_off_t position;
uint save_my_errno;
myf myflag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
DBUG_ENTER("write_block_record");

head_block= bitmap_blocks->block;
Expand Down Expand Up @@ -2708,7 +2709,7 @@ static my_bool write_block_record(MARIA_HA *info,
for every data segment we want to store.
*/
if (_ma_alloc_buffer(&info->rec_buff, &info->rec_buff_size,
row->head_length))
row->head_length, myflag))
DBUG_RETURN(1);

tmp_data_used= 0; /* Either 0 or last used uchar in 'data' */
Expand Down Expand Up @@ -4718,6 +4719,7 @@ int _ma_read_block_record2(MARIA_HA *info, uchar *record,
MARIA_EXTENT_CURSOR extent;
MARIA_COLUMNDEF *column, *end_column;
MARIA_ROW *cur_row= &info->cur_row;
myf myflag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
DBUG_ENTER("_ma_read_block_record2");

start_of_data= data;
Expand Down Expand Up @@ -4763,7 +4765,7 @@ int _ma_read_block_record2(MARIA_HA *info, uchar *record,
if (cur_row->extents_buffer_length < row_extent_size &&
_ma_alloc_buffer(&cur_row->extents,
&cur_row->extents_buffer_length,
row_extent_size))
row_extent_size, myflag))
DBUG_RETURN(my_errno);
memcpy(cur_row->extents, data, ROW_EXTENT_SIZE);
data+= ROW_EXTENT_SIZE;
Expand Down Expand Up @@ -4944,7 +4946,7 @@ int _ma_read_block_record2(MARIA_HA *info, uchar *record,
cur_row->blob_length= blob_lengths;
DBUG_PRINT("info", ("Total blob length: %lu", blob_lengths));
if (_ma_alloc_buffer(&info->blob_buff, &info->blob_buff_size,
blob_lengths))
blob_lengths, myflag))
DBUG_RETURN(my_errno);
blob_buffer= info->blob_buff;
}
Expand Down Expand Up @@ -5050,6 +5052,7 @@ static my_bool read_row_extent_info(MARIA_HA *info, uchar *buff,
uint flag, row_extents, row_extents_size;
uint field_lengths __attribute__ ((unused));
uchar *extents, *end;
myf myflag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
DBUG_ENTER("read_row_extent_info");

if (!(data= get_record_position(share, buff,
Expand All @@ -5073,7 +5076,7 @@ static my_bool read_row_extent_info(MARIA_HA *info, uchar *buff,
if (info->cur_row.extents_buffer_length < row_extents_size &&
_ma_alloc_buffer(&info->cur_row.extents,
&info->cur_row.extents_buffer_length,
row_extents_size))
row_extents_size, myflag))
DBUG_RETURN(1);
memcpy(info->cur_row.extents, data, ROW_EXTENT_SIZE);
data+= ROW_EXTENT_SIZE;
Expand Down Expand Up @@ -5244,6 +5247,7 @@ my_bool _ma_cmp_block_unique(MARIA_HA *info, MARIA_UNIQUEDEF *def,
my_bool _ma_scan_init_block_record(MARIA_HA *info)
{
MARIA_SHARE *share= info->s;
myf flag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
DBUG_ENTER("_ma_scan_init_block_record");
DBUG_ASSERT(info->dfile.file == share->bitmap.file.file);

Expand All @@ -5253,7 +5257,7 @@ my_bool _ma_scan_init_block_record(MARIA_HA *info)
*/
if (!(info->scan.bitmap_buff ||
((info->scan.bitmap_buff=
(uchar *) my_malloc(share->block_size * 2, MYF(MY_WME))))))
(uchar *) my_malloc(share->block_size * 2, flag)))))
DBUG_RETURN(1);
info->scan.page_buff= info->scan.bitmap_buff + share->block_size;
info->scan.bitmap_end= info->scan.bitmap_buff + share->bitmap.max_total_size;
Expand Down
11 changes: 6 additions & 5 deletions storage/maria/ma_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,7 @@ static int check_dynamic_record(HA_CHECK *param, MARIA_HA *info, int extend,
ulong UNINIT_VAR(left_length);
uint b_type;
char llbuff[22],llbuff2[22],llbuff3[22];
myf myflag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
DBUG_ENTER("check_dynamic_record");

pos= 0;
Expand Down Expand Up @@ -1378,7 +1379,7 @@ static int check_dynamic_record(HA_CHECK *param, MARIA_HA *info, int extend,
{
if (_ma_alloc_buffer(&info->rec_buff, &info->rec_buff_size,
block_info.rec_len +
share->base.extra_rec_buff_size))
share->base.extra_rec_buff_size, myflag))

{
_ma_check_print_error(param,
Expand Down Expand Up @@ -2694,7 +2695,7 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info,
(uchar *) my_malloc((uint)
share->base.default_rec_buff_size, MYF(0))) ||
_ma_alloc_buffer(&sort_param.rec_buff, &sort_param.rec_buff_size,
share->base.default_rec_buff_size))
share->base.default_rec_buff_size, MYF(0)))
{
_ma_check_print_error(param, "Not enough memory for extra record");
goto err;
Expand Down Expand Up @@ -3782,7 +3783,7 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
(uchar*) my_malloc((size_t) share->base.default_rec_buff_size,
MYF(0))) ||
_ma_alloc_buffer(&sort_param.rec_buff, &sort_param.rec_buff_size,
share->base.default_rec_buff_size))
share->base.default_rec_buff_size, MYF(0)))
{
_ma_check_print_error(param, "Not enough memory for extra record");
goto err;
Expand Down Expand Up @@ -4425,7 +4426,7 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
sort_param[i].record= (((uchar *)(sort_param+share->base.keys))+
(share->base.pack_reclength * i));
if (_ma_alloc_buffer(&sort_param[i].rec_buff, &sort_param[i].rec_buff_size,
share->base.default_rec_buff_size))
share->base.default_rec_buff_size, MYF(0)))
{
_ma_check_print_error(param,"Not enough memory!");
goto err;
Expand Down Expand Up @@ -5155,7 +5156,7 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param)
if (_ma_alloc_buffer(&sort_param->rec_buff,
&sort_param->rec_buff_size,
block_info.rec_len +
share->base.extra_rec_buff_size))
share->base.extra_rec_buff_size, MYF(0)))

{
if (param->max_record_length >= block_info.rec_len)
Expand Down
18 changes: 10 additions & 8 deletions storage/maria/ma_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ int maria_create(const char *name, enum data_file_type datafile_type,
uint uniques, MARIA_UNIQUEDEF *uniquedefs,
MARIA_CREATE_INFO *ci,uint flags)
{
register uint i,j;
uint i,j;
File UNINIT_VAR(dfile), UNINIT_VAR(file);
int errpos,save_errno, create_mode= O_RDWR | O_TRUNC, res;
myf create_flag;
myf create_flag, common_flag= MY_WME, sync_dir= 0;
uint length,max_key_length,packed,pack_bytes,pointer,real_length_diff,
key_length,info_length,key_segs,options,min_key_length,
base_pos,long_varchar_count,
Expand All @@ -93,7 +93,6 @@ int maria_create(const char *name, enum data_file_type datafile_type,
MARIA_CREATE_INFO tmp_create_info;
my_bool tmp_table= FALSE; /* cache for presence of HA_OPTION_TMP_TABLE */
my_bool forced_packed;
myf sync_dir= 0;
uchar *log_data= NULL;
my_bool encrypted= maria_encrypt_tables && datafile_type == BLOCK_RECORD;
my_bool insert_order= MY_TEST(flags & HA_PRESERVE_INSERT_ORDER);
Expand All @@ -104,6 +103,9 @@ int maria_create(const char *name, enum data_file_type datafile_type,

DBUG_ASSERT(maria_inited);

if (flags & HA_CREATE_TMP_TABLE)
common_flag|= MY_THREAD_SPECIFIC;

if (!ci)
{
bzero((char*) &tmp_create_info,sizeof(tmp_create_info));
Expand Down Expand Up @@ -148,7 +150,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
(double*) my_malloc((keys + uniques)*HA_MAX_KEY_SEG*sizeof(double) +
(keys + uniques)*HA_MAX_KEY_SEG*sizeof(ulong) +
sizeof(uint16) * columns,
MYF(MY_WME | MY_ZEROFILL))))
MYF(common_flag | MY_ZEROFILL))))
DBUG_RETURN(my_errno);
nulls_per_key_part= (ulong*) (rec_per_key_part +
(keys + uniques) * HA_MAX_KEY_SEG);
Expand Down Expand Up @@ -924,7 +926,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,

if ((file= mysql_file_create_with_symlink(key_file_kfile, klinkname_ptr,
kfilename, 0, create_mode,
MYF(MY_WME|create_flag))) < 0)
MYF(common_flag|create_flag))) < 0)
goto err;
errpos=1;

Expand Down Expand Up @@ -1027,7 +1029,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
MARIA_COLUMNDEF **col_order, **pos;
if (!(col_order= (MARIA_COLUMNDEF**) my_malloc(share.base.fields *
sizeof(MARIA_COLUMNDEF*),
MYF(MY_WME))))
common_flag)))
goto err;
for (column= columndef, pos= col_order ;
column != end_column ;
Expand Down Expand Up @@ -1206,8 +1208,8 @@ int maria_create(const char *name, enum data_file_type datafile_type,
}
if ((dfile=
mysql_file_create_with_symlink(key_file_dfile, dlinkname_ptr,
dfilename, 0, create_mode,
MYF(MY_WME | create_flag | sync_dir))) < 0)
dfilename, 0, create_mode,
MYF(common_flag | create_flag | sync_dir))) < 0)
goto err;
errpos=3;

Expand Down
13 changes: 8 additions & 5 deletions storage/maria/ma_dynrec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,8 @@ int _ma_read_dynamic_record(MARIA_HA *info, uchar *buf,
File file;
uchar *UNINIT_VAR(to);
uint UNINIT_VAR(left_length);
MARIA_SHARE *share= info->s;
myf flag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
DBUG_ENTER("_ma_read_dynamic_record");

if (filepos == HA_OFFSET_ERROR)
Expand Down Expand Up @@ -1507,13 +1509,13 @@ int _ma_read_dynamic_record(MARIA_HA *info, uchar *buf,
if (block_of_record++ == 0) /* First block */
{
info->cur_row.total_length= block_info.rec_len;
if (block_info.rec_len > (uint) info->s->base.max_pack_length)
if (block_info.rec_len > (uint) share->base.max_pack_length)
goto panic;
if (info->s->base.blobs)
if (share->base.blobs)
{
if (_ma_alloc_buffer(&info->rec_buff, &info->rec_buff_size,
block_info.rec_len +
info->s->base.extra_rec_buff_size))
share->base.extra_rec_buff_size, flag))
goto err;
}
to= info->rec_buff;
Expand Down Expand Up @@ -1549,7 +1551,7 @@ int _ma_read_dynamic_record(MARIA_HA *info, uchar *buf,
there is no equivalent without seeking. We are at the right
position already. :(
*/
if (info->s->file_read(info, to, block_info.data_len,
if (share->file_read(info, to, block_info.data_len,
filepos, MYF(MY_NABP)))
goto panic;
left_length-=block_info.data_len;
Expand Down Expand Up @@ -1769,6 +1771,7 @@ int _ma_read_rnd_dynamic_record(MARIA_HA *info,
uchar *UNINIT_VAR(to);
MARIA_BLOCK_INFO block_info;
MARIA_SHARE *share= info->s;
myf flag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
DBUG_ENTER("_ma_read_rnd_dynamic_record");

#ifdef MARIA_EXTERNAL_LOCKING
Expand Down Expand Up @@ -1859,7 +1862,7 @@ int _ma_read_rnd_dynamic_record(MARIA_HA *info,
{
if (_ma_alloc_buffer(&info->rec_buff, &info->rec_buff_size,
block_info.rec_len +
info->s->base.extra_rec_buff_size))
share->base.extra_rec_buff_size, flag))
goto err;
}
to= info->rec_buff;
Expand Down
5 changes: 3 additions & 2 deletions storage/maria/ma_extra.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ int maria_reset(MARIA_HA *info)
{
int error= 0;
MARIA_SHARE *share= info->s;
myf flag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
DBUG_ENTER("maria_reset");
/*
Free buffers and reset the following flags:
Expand All @@ -553,13 +554,13 @@ int maria_reset(MARIA_HA *info)
{
info->rec_buff_size= 1; /* Force realloc */
_ma_alloc_buffer(&info->rec_buff, &info->rec_buff_size,
share->base.default_rec_buff_size);
share->base.default_rec_buff_size, flag);
}
if (info->blob_buff_size > MARIA_SMALL_BLOB_BUFFER)
{
info->blob_buff_size= 1; /* Force realloc */
_ma_alloc_buffer(&info->blob_buff, &info->blob_buff_size,
MARIA_SMALL_BLOB_BUFFER);
MARIA_SMALL_BLOB_BUFFER, flag);
}
}
#if defined(HAVE_MMAP) && defined(HAVE_MADVISE)
Expand Down
Loading

0 comments on commit f24038b

Please sign in to comment.