Commit af2d5f3d authored by unknown's avatar unknown

parallel repair needs rec_buff local for thread !!!


mysys/mf_iocache.c:
  remove debug output
parent d8093cf6
......@@ -378,6 +378,8 @@ typedef struct st_mi_sort_param
uint key, key_length,real_key_length,sortbuff_size;
uint maxbuffers, keys, find_length, sort_keys_length;
uchar **sort_keys;
byte *rec_buff;
uint alloced_rec_buff_length;
void *wordlist, *wordptr;
MI_KEYDEF *keyinfo;
SORT_INFO *sort_info;
......
......@@ -898,7 +898,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
info->checksum=mi_checksum(info,record);
if (param->testflag & (T_EXTEND | T_MEDIUM | T_VERBOSE))
{
if (_mi_rec_check(info,record))
if (_mi_rec_check(info,record, info->rec_buff))
{
mi_check_print_error(param,"Found wrong packed record at %s",
llstr(start_recpos,llbuff));
......@@ -1143,6 +1143,8 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
MYF(MY_WME | MY_WAIT_IF_FULL)))
goto err;
info->opt_flag|=WRITE_CACHE_USED;
sort_param.rec_buff=info->rec_buff;
sort_param.alloced_rec_buff_length=info->alloced_rec_buff_length;
if (!(sort_param.record=(byte*) my_malloc((uint) share->base.pack_reclength,
MYF(0))))
{
......@@ -1787,6 +1789,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
param->testflag|=T_REP; /* for easy checking */
bzero((char*)&sort_info,sizeof(sort_info));
bzero((char *)&sort_param, sizeof(sort_param));
if (!(sort_info.key_block=
alloc_key_blocks(param,
(uint) param->sort_key_blocks,
......@@ -1804,6 +1807,8 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
info->opt_flag|=WRITE_CACHE_USED;
info->rec_cache.file=info->dfile; /* for sort_delete_record */
sort_param.rec_buff=info->rec_buff;
sort_param.alloced_rec_buff_length=info->alloced_rec_buff_length;
if (!(sort_param.record=(byte*) my_malloc((uint) share->base.pack_reclength,
MYF(0))))
{
......@@ -2164,7 +2169,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
goto err;
sort_info.key_block_end=sort_info.key_block+param->sort_key_blocks;
info->opt_flag|=WRITE_CACHE_USED;
info->rec_cache.file=info->dfile; /* for sort_delete_record */
info->rec_cache.file=info->dfile; /* for sort_delete_record */
if (!rep_quick)
{
......@@ -2570,15 +2575,13 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
my_off_t pos;
byte *to;
MI_BLOCK_INFO block_info;
MI_INFO *info;
MYISAM_SHARE *share;
SORT_INFO *sort_info=sort_param->sort_info;
MI_CHECK *param=sort_info->param;
MI_INFO *info=sort_info->info;
MYISAM_SHARE *share=info->s;
char llbuff[22],llbuff2[22];
DBUG_ENTER("sort_get_next_record");
info=sort_info->info;
share=info->s;
switch (share->data_file_type) {
case STATIC_RECORD:
for (;;)
......@@ -2665,9 +2668,9 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
param->testflag|=T_RETRY_WITHOUT_QUICK;
DBUG_RETURN(1); /* Something wrong with data */
}
if (((b_type=_mi_get_block_info(&block_info,-1,pos)) &
(BLOCK_ERROR | BLOCK_FATAL_ERROR)) ||
((b_type & BLOCK_FIRST) &&
b_type=_mi_get_block_info(&block_info,-1,pos);
if ((b_type & (BLOCK_ERROR | BLOCK_FATAL_ERROR)) ||
((b_type & BLOCK_FIRST) &&
(block_info.rec_len < (uint) share->base.min_pack_length ||
block_info.rec_len > (uint) share->base.max_pack_length)))
{
......@@ -2787,7 +2790,9 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
sort_param->pos=block_info.filepos+block_info.block_len;
if (share->base.blobs)
{
if (!(to=mi_fix_rec_buff_for_blob(info,block_info.rec_len)))
if (!(to=mi_alloc_rec_buff(info,block_info.rec_len,
&(sort_param->rec_buff),
&(sort_param->alloced_rec_buff_length))))
{
mi_check_print_error(param,"Not enough memory for blob at %s",
llstr(sort_param->start_recpos,llbuff));
......@@ -2795,7 +2800,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
}
}
else
to= info->rec_buff;
to= sort_param->rec_buff;
}
if (left_length < block_info.data_len || ! block_info.data_len)
{
......@@ -2837,7 +2842,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
}
} while (left_length);
if (_mi_rec_unpack(info,sort_param->record,info->rec_buff,
if (_mi_rec_unpack(info,sort_param->record,sort_param->rec_buff,
sort_param->find_length) != MY_FILE_ERROR)
{
if (sort_param->read_cache.error < 0)
......@@ -2846,7 +2851,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
info->checksum=mi_checksum(info,sort_param->record);
if ((param->testflag & (T_EXTEND | T_REP)) || searching)
{
if (_mi_rec_check(info, sort_param->record))
if (_mi_rec_check(info, sort_param->record, sort_param->rec_buff))
{
mi_check_print_info(param,"Found wrong packed record at %s",
llstr(sort_param->start_recpos,llbuff));
......@@ -2858,8 +2863,9 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
DBUG_RETURN(0);
}
if (!searching)
mi_check_print_info(param,"Found wrong stored record at %s",
llstr(sort_param->start_recpos,llbuff));
mi_check_print_info(param,"Key %d - Found wrong stored record at %s",
sort_param->key+1,
llstr(sort_param->start_recpos,llbuff));
try_next:
pos=(sort_param->start_recpos+=MI_DYN_ALIGN_SIZE);
searching=1;
......@@ -2894,7 +2900,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
llstr(sort_param->pos,llbuff));
continue;
}
if (_mi_read_cache(&sort_param->read_cache,(byte*) info->rec_buff,
if (_mi_read_cache(&sort_param->read_cache,(byte*) sort_param->rec_buff,
block_info.filepos, block_info.rec_len,
READING_NEXT))
{
......@@ -2903,7 +2909,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
llstr(sort_param->pos,llbuff));
continue;
}
if (_mi_pack_rec_unpack(info,sort_param->record,info->rec_buff,
if (_mi_pack_rec_unpack(info,sort_param->record,sort_param->rec_buff,
block_info.rec_len))
{
if (! searching)
......@@ -2963,7 +2969,7 @@ int sort_write_record(MI_SORT_PARAM *sort_param)
break;
case DYNAMIC_RECORD:
if (! info->blobs)
from=info->rec_buff;
from=sort_param->rec_buff;
else
{
/* must be sure that local buffer is big enough */
......@@ -3013,7 +3019,7 @@ int sort_write_record(MI_SORT_PARAM *sort_param)
if (info->s->base.blobs)
length+=save_pack_length(block_buff+length,info->blob_length);
if (my_b_write(&info->rec_cache,block_buff,length) ||
my_b_write(&info->rec_cache,(byte*) info->rec_buff,reclength))
my_b_write(&info->rec_cache,(byte*) sort_param->rec_buff,reclength))
{
mi_check_print_error(param,"%d when writing to datafile",my_errno);
DBUG_RETURN(1);
......
......@@ -60,6 +60,7 @@ int mi_close(register MI_INFO *info)
myisam_open_list=list_delete(myisam_open_list,&info->open_list);
pthread_mutex_unlock(&share->intern_lock);
my_free(mi_get_rec_buff_ptr(info, info->rec_buff), MYF(MY_ALLOW_ZERO_PTR));
if (flag)
{
if (share->kfile >= 0 &&
......@@ -101,7 +102,6 @@ int mi_close(register MI_INFO *info)
error = my_errno;
myisam_log_command(MI_LOG_CLOSE,info,NULL,0,error);
my_free(mi_get_rec_buff_ptr(info, info->rec_buff), MYF(MY_ALLOW_ZERO_PTR));
my_free((gptr) info,MYF(0));
if (error)
......
......@@ -728,7 +728,7 @@ uint _mi_rec_pack(MI_INFO *info, register byte *to, register const byte *from)
Returns 0 if record is ok.
*/
my_bool _mi_rec_check(MI_INFO *info,const char *record)
my_bool _mi_rec_check(MI_INFO *info,const char *record, byte *rec_buff)
{
uint length,new_length,flag,bit,i;
char *pos,*end,*packpos,*to;
......@@ -736,7 +736,7 @@ my_bool _mi_rec_check(MI_INFO *info,const char *record)
reg3 MI_COLUMNDEF *rec;
DBUG_ENTER("_mi_rec_check");
packpos=info->rec_buff; to= info->rec_buff+info->s->base.pack_bits;
packpos=rec_buff; to= rec_buff+info->s->base.pack_bits;
rec=info->s->rec;
flag= *packpos; bit=1;
......@@ -820,7 +820,7 @@ my_bool _mi_rec_check(MI_INFO *info,const char *record)
to+=length;
}
}
if (info->packed_length != (uint) (to - info->rec_buff)
if (info->packed_length != (uint) (to - rec_buff)
+ test(info->s->calc_checksum) ||
(bit != 1 && (flag & ~(bit - 1))))
goto err;
......
......@@ -530,7 +530,7 @@ extern gptr mi_get_rec_buff_ptr(MI_INFO *, byte *);
&((INFO)->rec_buff), &((INFO)->alloced_rec_buff_length))
extern ulong _mi_rec_unpack(MI_INFO *info,byte *to,byte *from,
ulong reclength);
extern my_bool _mi_rec_check(MI_INFO *info,const char *from);
extern my_bool _mi_rec_check(MI_INFO *info,const char *record, byte *packpos);
extern int _mi_write_part_record(MI_INFO *info,my_off_t filepos,ulong length,
my_off_t next_filepos,byte **record,
ulong *reclength,int *flag);
......
......@@ -182,7 +182,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
reinit_io_cache(&tempfile,READ_CACHE,0L,0,0))
goto err; /* purecov: inspected */
if (!no_messages)
puts(" - Last merge and dumping keys"); /* purecov: tested */
puts(" - Last merge and dumping keys\n"); /* purecov: tested */
if (merge_index(info,keys,sort_keys,dynamic_element(&buffpek,0,BUFFPEK *),
maxbuffer,&tempfile))
goto err; /* purecov: inspected */
......@@ -433,22 +433,26 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
got_error=1;
continue;
}
share->state.key_map|=(ulonglong) 1 << sinfo->key;
if (param->testflag & T_STATISTICS)
update_key_parts(sinfo->keyinfo, rec_per_key_part,
sinfo->unique, (ulonglong) info->state->records);
if (!sinfo->buffpek.elements)
if (!got_error)
{
if (param->testflag & T_VERBOSE)
share->state.key_map|=(ulonglong) 1 << sinfo->key;
if (param->testflag & T_STATISTICS)
update_key_parts(sinfo->keyinfo, rec_per_key_part,
sinfo->unique, (ulonglong) info->state->records);
if (!sinfo->buffpek.elements)
{
printf("Key %d - Dumping %u keys\n",sinfo->key+1, sinfo->keys);
fflush(stdout);
if (param->testflag & T_VERBOSE)
{
printf("Key %d - Dumping %u keys\n",sinfo->key+1, sinfo->keys);
fflush(stdout);
}
if (write_index(sinfo, sinfo->sort_keys, sinfo->keys) ||
flush_pending_blocks(sinfo))
got_error=1;
}
if (write_index(sinfo, sinfo->sort_keys, sinfo->keys) ||
flush_pending_blocks(sinfo))
got_error=1;
}
my_free((gptr) sinfo->sort_keys,MYF(0));
my_free(mi_get_rec_buff_ptr(info, sinfo->rec_buff), MYF(MY_ALLOW_ZERO_PTR));
sinfo->sort_keys=0;
}
......@@ -497,7 +501,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
continue;
}
if (param->testflag & T_VERBOSE)
printf("Key %d - Last merge and dumping keys", sinfo->key+1);
printf("Key %d - Last merge and dumping keys\n", sinfo->key+1);
if (merge_index(sinfo, keys, (uchar **)mergebuf,
dynamic_element(&sinfo->buffpek,0,BUFFPEK *),
maxbuffer,&sinfo->tempfile) ||
......@@ -512,7 +516,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
uint key_length;
if (param->testflag & T_VERBOSE)
printf("Key %d - Dumping 'long' keys", sinfo->key+1);
printf("Key %d - Dumping 'long' keys\n", sinfo->key+1);
if (flush_io_cache(&sinfo->tempfile_for_exceptions) ||
reinit_io_cache(&sinfo->tempfile_for_exceptions,READ_CACHE,0L,0,0))
......
......@@ -524,13 +524,6 @@ int _my_b_read_r(register IO_CACHE *info, byte *Buffer, uint Count)
}
if (lock_io_cache(info))
{
#if 0 && SAFE_MUTEX
#define PRINT_LOCK(M) printf("Thread %d: mutex is %s\n", my_thread_id(), \
(((safe_mutex_t *)(M))->count ? "Locked" : "Unlocked"))
#else
#define PRINT_LOCK(M)
#endif
PRINT_LOCK(&info->share->mutex);
info->share->active=info;
if (info->seek_not_done) /* File touched, do seek */
VOID(my_seek(info->file,pos_in_file,MY_SEEK_SET,MYF(0)));
......@@ -539,7 +532,6 @@ int _my_b_read_r(register IO_CACHE *info, byte *Buffer, uint Count)
info->error=(len == (int)length ? 0 : len);
info->pos_in_file=pos_in_file;
unlock_io_cache(info);
PRINT_LOCK(&info->share->mutex);
}
else
{
......@@ -547,7 +539,6 @@ int _my_b_read_r(register IO_CACHE *info, byte *Buffer, uint Count)
info->read_end= info->share->active->read_end;
info->pos_in_file= info->share->active->pos_in_file;
len= (info->error == -1 ? -1 : info->read_end-info->buffer);
PRINT_LOCK(&info->share->mutex);
}
info->read_pos=info->buffer;
info->seek_not_done=0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment