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 ...@@ -378,6 +378,8 @@ typedef struct st_mi_sort_param
uint key, key_length,real_key_length,sortbuff_size; uint key, key_length,real_key_length,sortbuff_size;
uint maxbuffers, keys, find_length, sort_keys_length; uint maxbuffers, keys, find_length, sort_keys_length;
uchar **sort_keys; uchar **sort_keys;
byte *rec_buff;
uint alloced_rec_buff_length;
void *wordlist, *wordptr; void *wordlist, *wordptr;
MI_KEYDEF *keyinfo; MI_KEYDEF *keyinfo;
SORT_INFO *sort_info; SORT_INFO *sort_info;
......
...@@ -898,7 +898,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) ...@@ -898,7 +898,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
info->checksum=mi_checksum(info,record); info->checksum=mi_checksum(info,record);
if (param->testflag & (T_EXTEND | T_MEDIUM | T_VERBOSE)) 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", mi_check_print_error(param,"Found wrong packed record at %s",
llstr(start_recpos,llbuff)); llstr(start_recpos,llbuff));
...@@ -1143,6 +1143,8 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, ...@@ -1143,6 +1143,8 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
MYF(MY_WME | MY_WAIT_IF_FULL))) MYF(MY_WME | MY_WAIT_IF_FULL)))
goto err; goto err;
info->opt_flag|=WRITE_CACHE_USED; 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, if (!(sort_param.record=(byte*) my_malloc((uint) share->base.pack_reclength,
MYF(0)))) MYF(0))))
{ {
...@@ -1787,6 +1789,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, ...@@ -1787,6 +1789,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
param->testflag|=T_REP; /* for easy checking */ param->testflag|=T_REP; /* for easy checking */
bzero((char*)&sort_info,sizeof(sort_info)); bzero((char*)&sort_info,sizeof(sort_info));
bzero((char *)&sort_param, sizeof(sort_param));
if (!(sort_info.key_block= if (!(sort_info.key_block=
alloc_key_blocks(param, alloc_key_blocks(param,
(uint) param->sort_key_blocks, (uint) param->sort_key_blocks,
...@@ -1804,6 +1807,8 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, ...@@ -1804,6 +1807,8 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
info->opt_flag|=WRITE_CACHE_USED; 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 */
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, if (!(sort_param.record=(byte*) my_malloc((uint) share->base.pack_reclength,
MYF(0)))) MYF(0))))
{ {
...@@ -2570,15 +2575,13 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) ...@@ -2570,15 +2575,13 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
my_off_t pos; my_off_t pos;
byte *to; byte *to;
MI_BLOCK_INFO block_info; MI_BLOCK_INFO block_info;
MI_INFO *info;
MYISAM_SHARE *share;
SORT_INFO *sort_info=sort_param->sort_info; SORT_INFO *sort_info=sort_param->sort_info;
MI_CHECK *param=sort_info->param; MI_CHECK *param=sort_info->param;
MI_INFO *info=sort_info->info;
MYISAM_SHARE *share=info->s;
char llbuff[22],llbuff2[22]; char llbuff[22],llbuff2[22];
DBUG_ENTER("sort_get_next_record"); DBUG_ENTER("sort_get_next_record");
info=sort_info->info;
share=info->s;
switch (share->data_file_type) { switch (share->data_file_type) {
case STATIC_RECORD: case STATIC_RECORD:
for (;;) for (;;)
...@@ -2665,8 +2668,8 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) ...@@ -2665,8 +2668,8 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
param->testflag|=T_RETRY_WITHOUT_QUICK; param->testflag|=T_RETRY_WITHOUT_QUICK;
DBUG_RETURN(1); /* Something wrong with data */ DBUG_RETURN(1); /* Something wrong with data */
} }
if (((b_type=_mi_get_block_info(&block_info,-1,pos)) & b_type=_mi_get_block_info(&block_info,-1,pos);
(BLOCK_ERROR | BLOCK_FATAL_ERROR)) || if ((b_type & (BLOCK_ERROR | BLOCK_FATAL_ERROR)) ||
((b_type & BLOCK_FIRST) && ((b_type & BLOCK_FIRST) &&
(block_info.rec_len < (uint) share->base.min_pack_length || (block_info.rec_len < (uint) share->base.min_pack_length ||
block_info.rec_len > (uint) share->base.max_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) ...@@ -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; sort_param->pos=block_info.filepos+block_info.block_len;
if (share->base.blobs) 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", mi_check_print_error(param,"Not enough memory for blob at %s",
llstr(sort_param->start_recpos,llbuff)); llstr(sort_param->start_recpos,llbuff));
...@@ -2795,7 +2800,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) ...@@ -2795,7 +2800,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
} }
} }
else else
to= info->rec_buff; to= sort_param->rec_buff;
} }
if (left_length < block_info.data_len || ! block_info.data_len) 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) ...@@ -2837,7 +2842,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
} }
} while (left_length); } 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) sort_param->find_length) != MY_FILE_ERROR)
{ {
if (sort_param->read_cache.error < 0) if (sort_param->read_cache.error < 0)
...@@ -2846,7 +2851,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) ...@@ -2846,7 +2851,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
info->checksum=mi_checksum(info,sort_param->record); info->checksum=mi_checksum(info,sort_param->record);
if ((param->testflag & (T_EXTEND | T_REP)) || searching) 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", mi_check_print_info(param,"Found wrong packed record at %s",
llstr(sort_param->start_recpos,llbuff)); llstr(sort_param->start_recpos,llbuff));
...@@ -2858,7 +2863,8 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) ...@@ -2858,7 +2863,8 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
if (!searching) if (!searching)
mi_check_print_info(param,"Found wrong stored record at %s", mi_check_print_info(param,"Key %d - Found wrong stored record at %s",
sort_param->key+1,
llstr(sort_param->start_recpos,llbuff)); llstr(sort_param->start_recpos,llbuff));
try_next: try_next:
pos=(sort_param->start_recpos+=MI_DYN_ALIGN_SIZE); pos=(sort_param->start_recpos+=MI_DYN_ALIGN_SIZE);
...@@ -2894,7 +2900,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) ...@@ -2894,7 +2900,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
llstr(sort_param->pos,llbuff)); llstr(sort_param->pos,llbuff));
continue; 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, block_info.filepos, block_info.rec_len,
READING_NEXT)) READING_NEXT))
{ {
...@@ -2903,7 +2909,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) ...@@ -2903,7 +2909,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
llstr(sort_param->pos,llbuff)); llstr(sort_param->pos,llbuff));
continue; 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)) block_info.rec_len))
{ {
if (! searching) if (! searching)
...@@ -2963,7 +2969,7 @@ int sort_write_record(MI_SORT_PARAM *sort_param) ...@@ -2963,7 +2969,7 @@ int sort_write_record(MI_SORT_PARAM *sort_param)
break; break;
case DYNAMIC_RECORD: case DYNAMIC_RECORD:
if (! info->blobs) if (! info->blobs)
from=info->rec_buff; from=sort_param->rec_buff;
else else
{ {
/* must be sure that local buffer is big enough */ /* must be sure that local buffer is big enough */
...@@ -3013,7 +3019,7 @@ int sort_write_record(MI_SORT_PARAM *sort_param) ...@@ -3013,7 +3019,7 @@ int sort_write_record(MI_SORT_PARAM *sort_param)
if (info->s->base.blobs) if (info->s->base.blobs)
length+=save_pack_length(block_buff+length,info->blob_length); length+=save_pack_length(block_buff+length,info->blob_length);
if (my_b_write(&info->rec_cache,block_buff,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); mi_check_print_error(param,"%d when writing to datafile",my_errno);
DBUG_RETURN(1); DBUG_RETURN(1);
......
...@@ -60,6 +60,7 @@ int mi_close(register MI_INFO *info) ...@@ -60,6 +60,7 @@ int mi_close(register MI_INFO *info)
myisam_open_list=list_delete(myisam_open_list,&info->open_list); myisam_open_list=list_delete(myisam_open_list,&info->open_list);
pthread_mutex_unlock(&share->intern_lock); 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 (flag)
{ {
if (share->kfile >= 0 && if (share->kfile >= 0 &&
...@@ -101,7 +102,6 @@ int mi_close(register MI_INFO *info) ...@@ -101,7 +102,6 @@ int mi_close(register MI_INFO *info)
error = my_errno; error = my_errno;
myisam_log_command(MI_LOG_CLOSE,info,NULL,0,error); 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)); my_free((gptr) info,MYF(0));
if (error) if (error)
......
...@@ -728,7 +728,7 @@ uint _mi_rec_pack(MI_INFO *info, register byte *to, register const byte *from) ...@@ -728,7 +728,7 @@ uint _mi_rec_pack(MI_INFO *info, register byte *to, register const byte *from)
Returns 0 if record is ok. 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; uint length,new_length,flag,bit,i;
char *pos,*end,*packpos,*to; char *pos,*end,*packpos,*to;
...@@ -736,7 +736,7 @@ my_bool _mi_rec_check(MI_INFO *info,const char *record) ...@@ -736,7 +736,7 @@ my_bool _mi_rec_check(MI_INFO *info,const char *record)
reg3 MI_COLUMNDEF *rec; reg3 MI_COLUMNDEF *rec;
DBUG_ENTER("_mi_rec_check"); 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; rec=info->s->rec;
flag= *packpos; bit=1; flag= *packpos; bit=1;
...@@ -820,7 +820,7 @@ my_bool _mi_rec_check(MI_INFO *info,const char *record) ...@@ -820,7 +820,7 @@ my_bool _mi_rec_check(MI_INFO *info,const char *record)
to+=length; to+=length;
} }
} }
if (info->packed_length != (uint) (to - info->rec_buff) if (info->packed_length != (uint) (to - rec_buff)
+ test(info->s->calc_checksum) || + test(info->s->calc_checksum) ||
(bit != 1 && (flag & ~(bit - 1)))) (bit != 1 && (flag & ~(bit - 1))))
goto err; goto err;
......
...@@ -530,7 +530,7 @@ extern gptr mi_get_rec_buff_ptr(MI_INFO *, byte *); ...@@ -530,7 +530,7 @@ extern gptr mi_get_rec_buff_ptr(MI_INFO *, byte *);
&((INFO)->rec_buff), &((INFO)->alloced_rec_buff_length)) &((INFO)->rec_buff), &((INFO)->alloced_rec_buff_length))
extern ulong _mi_rec_unpack(MI_INFO *info,byte *to,byte *from, extern ulong _mi_rec_unpack(MI_INFO *info,byte *to,byte *from,
ulong reclength); 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, extern int _mi_write_part_record(MI_INFO *info,my_off_t filepos,ulong length,
my_off_t next_filepos,byte **record, my_off_t next_filepos,byte **record,
ulong *reclength,int *flag); ulong *reclength,int *flag);
......
...@@ -182,7 +182,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ...@@ -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)) reinit_io_cache(&tempfile,READ_CACHE,0L,0,0))
goto err; /* purecov: inspected */ goto err; /* purecov: inspected */
if (!no_messages) 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 *), if (merge_index(info,keys,sort_keys,dynamic_element(&buffpek,0,BUFFPEK *),
maxbuffer,&tempfile)) maxbuffer,&tempfile))
goto err; /* purecov: inspected */ goto err; /* purecov: inspected */
...@@ -433,6 +433,8 @@ int thr_write_keys(MI_SORT_PARAM *sort_param) ...@@ -433,6 +433,8 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
got_error=1; got_error=1;
continue; continue;
} }
if (!got_error)
{
share->state.key_map|=(ulonglong) 1 << sinfo->key; share->state.key_map|=(ulonglong) 1 << sinfo->key;
if (param->testflag & T_STATISTICS) if (param->testflag & T_STATISTICS)
update_key_parts(sinfo->keyinfo, rec_per_key_part, update_key_parts(sinfo->keyinfo, rec_per_key_part,
...@@ -448,7 +450,9 @@ int thr_write_keys(MI_SORT_PARAM *sort_param) ...@@ -448,7 +450,9 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
flush_pending_blocks(sinfo)) flush_pending_blocks(sinfo))
got_error=1; got_error=1;
} }
}
my_free((gptr) sinfo->sort_keys,MYF(0)); 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; sinfo->sort_keys=0;
} }
...@@ -497,7 +501,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param) ...@@ -497,7 +501,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
continue; continue;
} }
if (param->testflag & T_VERBOSE) 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, if (merge_index(sinfo, keys, (uchar **)mergebuf,
dynamic_element(&sinfo->buffpek,0,BUFFPEK *), dynamic_element(&sinfo->buffpek,0,BUFFPEK *),
maxbuffer,&sinfo->tempfile) || maxbuffer,&sinfo->tempfile) ||
...@@ -512,7 +516,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param) ...@@ -512,7 +516,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
uint key_length; uint key_length;
if (param->testflag & T_VERBOSE) 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) || if (flush_io_cache(&sinfo->tempfile_for_exceptions) ||
reinit_io_cache(&sinfo->tempfile_for_exceptions,READ_CACHE,0L,0,0)) 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) ...@@ -524,13 +524,6 @@ int _my_b_read_r(register IO_CACHE *info, byte *Buffer, uint Count)
} }
if (lock_io_cache(info)) 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; info->share->active=info;
if (info->seek_not_done) /* File touched, do seek */ if (info->seek_not_done) /* File touched, do seek */
VOID(my_seek(info->file,pos_in_file,MY_SEEK_SET,MYF(0))); 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) ...@@ -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->error=(len == (int)length ? 0 : len);
info->pos_in_file=pos_in_file; info->pos_in_file=pos_in_file;
unlock_io_cache(info); unlock_io_cache(info);
PRINT_LOCK(&info->share->mutex);
} }
else else
{ {
...@@ -547,7 +539,6 @@ int _my_b_read_r(register IO_CACHE *info, byte *Buffer, uint Count) ...@@ -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->read_end= info->share->active->read_end;
info->pos_in_file= info->share->active->pos_in_file; info->pos_in_file= info->share->active->pos_in_file;
len= (info->error == -1 ? -1 : info->read_end-info->buffer); len= (info->error == -1 ? -1 : info->read_end-info->buffer);
PRINT_LOCK(&info->share->mutex);
} }
info->read_pos=info->buffer; info->read_pos=info->buffer;
info->seek_not_done=0; 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