diff options
-rw-r--r-- | storage/maria/ma_bitmap.c | 4 | ||||
-rw-r--r-- | storage/maria/ma_blockrec.c | 1 | ||||
-rw-r--r-- | storage/maria/ma_loghandler.c | 194 | ||||
-rw-r--r-- | storage/maria/ma_loghandler_lsn.h | 2 |
4 files changed, 139 insertions, 62 deletions
diff --git a/storage/maria/ma_bitmap.c b/storage/maria/ma_bitmap.c index 4046857d2a7..d7b073356b2 100644 --- a/storage/maria/ma_bitmap.c +++ b/storage/maria/ma_bitmap.c @@ -1176,6 +1176,7 @@ static my_bool find_blob(MARIA_HA *info, ulong length) MARIA_BITMAP_BLOCK *first_block= 0; DBUG_ENTER("find_blob"); DBUG_PRINT("enter", ("length: %lu", length)); + LINT_INIT(first_block_pos); pages= length / full_page_size; rest_length= (uint) (length - pages * full_page_size); @@ -2007,6 +2008,9 @@ my_bool _ma_check_bitmap_data(MARIA_HA *info, case BLOB_PAGE: bits= FULL_TAIL_PAGE; break; + default: + bits= 0; /* to satisfy compiler */ + DBUG_ASSERT(0); } return (*bitmap_pattern= get_page_bits(info, &info->s->bitmap, page)) != bits; diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c index 0d1a530dbfc..bdad9538b62 100644 --- a/storage/maria/ma_blockrec.c +++ b/storage/maria/ma_blockrec.c @@ -5514,6 +5514,7 @@ my_bool _ma_apply_undo_row_update(MARIA_HA *info, LSN undo_lsn, MARIA_RECORD_POS record_pos; ha_checksum checksum_delta; DBUG_ENTER("_ma_apply_undo_row_update"); + LINT_INIT(checksum_delta); page= page_korr(header); header+= PAGE_STORE_SIZE; diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index 342da3a2da4..c82b716d858 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -25,6 +25,8 @@ translog_assert_owner() could be added. */ +#define TRANSLOG_FILLER 0xFF + /* number of opened log files in the pagecache (should be at least 2) */ #define OPENED_FILES_NUM 3 @@ -62,6 +64,31 @@ #define COMPRESSED_LSN_MAX_STORE_SIZE (2 + LSN_STORE_SIZE) #define MAX_NUMBER_OF_LSNS_PER_RECORD 2 +#ifndef DBUG_OFF +static int translog_mutex_lock(pthread_mutex_t *M) +{ + int rc; + DBUG_PRINT("info", ("Going lock mutex 0x%lx...", (ulong)(M))); + rc= pthread_mutex_lock(M); + DBUG_PRINT("info", ("Mutex locked 0x%lx rc: %d", (ulong)(M), rc)); + return (rc); +} + +static int translog_mutex_unlock(pthread_mutex_t *M) +{ + int rc; + DBUG_PRINT("info", ("Going unlock mutex 0x%lx...", (ulong)(M))); + rc= pthread_mutex_unlock(M); + DBUG_PRINT("info", ("Mutex unlocked 0x%lx rc: %d", (ulong)(M), rc)); + return(rc); +} + +#else +#define translog_mutex_lock(M) pthread_mutex_lock(M) +#define translog_mutex_unlock(M) pthread_mutex_unlock(M) +#endif + + /* log write buffer descriptor */ struct st_translog_buffer { @@ -187,6 +214,7 @@ static struct st_translog_descriptor log_descriptor; /* Marker for end of log */ static uchar end_of_log= 0; +#define END_OF_LOG &end_of_log my_bool translog_inited= 0; @@ -726,13 +754,9 @@ static my_bool translog_write_file_header() /* file number */ int3store(page, LSN_FILE_NO(log_descriptor.horizon)); page+= 3; - /* - Here should be max lsn storing for current file (which is LSN_IPOSSIBLE): - lsn_store(page, LSN_IPOSSIBLE); + lsn_store(page, LSN_IMPOSSIBLE); page+= LSN_STORE_SIZE; - But it is zeros so we can rely on bzero() in this case - */ - bzero(page, sizeof(page_buff) - (page- page_buff)); + memset(page, TRANSLOG_FILLER, sizeof(page_buff) - (page- page_buff)); DBUG_RETURN(my_pwrite(log_descriptor.log_file_num[0], page_buff, sizeof(page_buff), 0, log_write_flags) != 0); @@ -868,7 +892,7 @@ static my_bool translog_set_lsn_for_files(uint32 from_file, uint32 to_file, translog_unlock(); /* Checks finished files if they are */ - pthread_mutex_lock(&log_descriptor.file_header_lock); + translog_mutex_lock(&log_descriptor.file_header_lock); for (file= from_file; file <= to_file; file++) { LOGHANDLER_FILE_INFO info; @@ -879,7 +903,7 @@ static my_bool translog_set_lsn_for_files(uint32 from_file, uint32 to_file, translog_max_lsn_to_header(fd, lsn))) DBUG_RETURN(1); } - pthread_mutex_unlock(&log_descriptor.file_header_lock); + translog_mutex_unlock(&log_descriptor.file_header_lock); DBUG_RETURN(0); } @@ -908,7 +932,7 @@ static void translog_mark_file_unfinished(uint32 file) DBUG_ENTER("translog_mark_file_unfinished"); DBUG_PRINT("enter", ("file: %lu", (ulong) file)); - pthread_mutex_lock(&log_descriptor.unfinished_files_lock); + translog_mutex_lock(&log_descriptor.unfinished_files_lock); if (log_descriptor.unfinished_files.elements == 0) { @@ -959,7 +983,7 @@ static void translog_mark_file_unfinished(uint32 file) place + 1, struct st_file_counter *), &fc, sizeof(struct st_file_counter)); end: - pthread_mutex_unlock(&log_descriptor.unfinished_files_lock); + translog_mutex_unlock(&log_descriptor.unfinished_files_lock); DBUG_VOID_RETURN; } @@ -980,7 +1004,7 @@ static void translog_mark_file_finished(uint32 file) LINT_INIT(fc_ptr); - pthread_mutex_lock(&log_descriptor.unfinished_files_lock); + translog_mutex_lock(&log_descriptor.unfinished_files_lock); DBUG_ASSERT(log_descriptor.unfinished_files.elements > 0); for (i= 0; @@ -998,7 +1022,7 @@ static void translog_mark_file_finished(uint32 file) if (! --fc_ptr->counter) delete_dynamic_element(&log_descriptor.unfinished_files, i); - pthread_mutex_unlock(&log_descriptor.unfinished_files_lock); + translog_mutex_unlock(&log_descriptor.unfinished_files_lock); DBUG_VOID_RETURN; } @@ -1021,7 +1045,7 @@ LSN translog_get_file_max_lsn_stored(uint32 file) DBUG_PRINT("enter", ("file: %lu", (ulong)file)); DBUG_ASSERT(translog_inited == 1); - pthread_mutex_lock(&log_descriptor.unfinished_files_lock); + translog_mutex_lock(&log_descriptor.unfinished_files_lock); /* find file with minimum file number "in progress" */ if (log_descriptor.unfinished_files.elements > 0) @@ -1031,7 +1055,7 @@ LSN translog_get_file_max_lsn_stored(uint32 file) 0, struct st_file_counter *); limit= fc_ptr->file; /* minimal file number "in progress" */ } - pthread_mutex_unlock(&log_descriptor.unfinished_files_lock); + translog_mutex_unlock(&log_descriptor.unfinished_files_lock); /* if there is no "in progress file" then unfinished file is in progress @@ -1084,7 +1108,7 @@ static my_bool translog_buffer_init(struct st_translog_buffer *buffer) buffer->file= -1; buffer->overlay= 0; /* IO cache for current log */ - bzero(buffer->buffer, TRANSLOG_WRITE_BUFFER); + memset(buffer->buffer, TRANSLOG_FILLER, TRANSLOG_WRITE_BUFFER); /* Buffer size */ buffer->size= 0; /* cond of thread which is waiting for buffer filling */ @@ -1194,7 +1218,7 @@ static my_bool translog_buffer_lock(struct st_translog_buffer *buffer) ("Lock buffer #%u: (0x%lx) mutex: 0x%lx", (uint) buffer->buffer_no, (ulong) buffer, (ulong) &buffer->mutex)); - res= (pthread_mutex_lock(&buffer->mutex) != 0); + res= (translog_mutex_lock(&buffer->mutex) != 0); DBUG_RETURN(res); } #else @@ -1225,7 +1249,7 @@ static my_bool translog_buffer_unlock(struct st_translog_buffer *buffer) (uint) buffer->buffer_no, (ulong) buffer, (ulong) &buffer->mutex)); - res= (pthread_mutex_unlock(&buffer->mutex) != 0); + res= (translog_mutex_unlock(&buffer->mutex) != 0); DBUG_PRINT("enter", ("Unlocked buffer... #%u: 0x%lx mutex: 0x%lx", (uint) buffer->buffer_no, (ulong) buffer, (ulong) &buffer->mutex)); @@ -1266,7 +1290,9 @@ static void translog_new_page_header(TRANSLOG_ADDRESS *horizon, /* File number */ int3store(ptr, LSN_FILE_NO(*horizon)); ptr+= 3; - *(ptr++)= (uchar) log_descriptor.flags; + DBUG_ASSERT(TRANSLOG_PAGE_FLAGS == (ptr - cursor->ptr)); + cursor->ptr[TRANSLOG_PAGE_FLAGS]= (uchar) log_descriptor.flags; + ptr++; if (log_descriptor.flags & TRANSLOG_PAGE_CRC) { #ifndef DBUG_OFF @@ -1397,7 +1423,7 @@ static void translog_finish_page(TRANSLOG_ADDRESS *horizon, struct st_buffer_cursor *cursor) { uint16 left= TRANSLOG_PAGE_SIZE - cursor->current_page_fill; - uchar *page= cursor->ptr -cursor->current_page_fill; + uchar *page= cursor->ptr - cursor->current_page_fill; DBUG_ENTER("translog_finish_page"); DBUG_PRINT("enter", ("Buffer: #%u 0x%lx " "Buffer addr: (%lu,0x%lx) " @@ -1424,7 +1450,7 @@ static void translog_finish_page(TRANSLOG_ADDRESS *horizon, if (left != 0) { DBUG_PRINT("info", ("left: %u", (uint) left)); - bzero(cursor->ptr, left); + memset(cursor->ptr, TRANSLOG_FILLER, left); cursor->ptr +=left; (*horizon)+= left; /* offset increasing */ if (!cursor->chaser) @@ -1438,14 +1464,19 @@ static void translog_finish_page(TRANSLOG_ADDRESS *horizon, (ulong) (cursor->ptr - cursor->buffer->buffer))); DBUG_EXECUTE("info", translog_check_cursor(cursor);); } - if (page[TRANSLOG_PAGE_FLAGS] & TRANSLOG_SECTOR_PROTECTION) + /* + When we are finishing the page other thread might not finish the page + header yet so we have to read log_descriptor.flags but not the flags + from the page + */ + if (log_descriptor.flags & TRANSLOG_SECTOR_PROTECTION) { translog_put_sector_protection(page, cursor); DBUG_PRINT("info", ("drop write_counter")); cursor->write_counter= 0; cursor->previous_offset= 0; } - if (page[TRANSLOG_PAGE_FLAGS] & TRANSLOG_PAGE_CRC) + if (log_descriptor.flags & TRANSLOG_PAGE_CRC) { uint32 crc= translog_crc(page + log_descriptor.page_overhead, TRANSLOG_PAGE_SIZE - @@ -1688,7 +1719,7 @@ static my_bool translog_buffer_next(TRANSLOG_ADDRESS *horizon, static void translog_set_sent_to_file(LSN lsn, TRANSLOG_ADDRESS in_buffers) { DBUG_ENTER("translog_set_sent_to_file"); - pthread_mutex_lock(&log_descriptor.sent_to_file_lock); + translog_mutex_lock(&log_descriptor.sent_to_file_lock); DBUG_PRINT("enter", ("lsn: (%lu,0x%lx) in_buffers: (%lu,0x%lx) " "in_buffers_only: (%lu,0x%lx)", LSN_IN_PARTS(lsn), @@ -1702,7 +1733,7 @@ static void translog_set_sent_to_file(LSN lsn, TRANSLOG_ADDRESS in_buffers) log_descriptor.in_buffers_only= in_buffers; DBUG_PRINT("info", ("set new in_buffers_only")); } - pthread_mutex_unlock(&log_descriptor.sent_to_file_lock); + translog_mutex_unlock(&log_descriptor.sent_to_file_lock); DBUG_VOID_RETURN; } @@ -1719,7 +1750,7 @@ static void translog_set_sent_to_file(LSN lsn, TRANSLOG_ADDRESS in_buffers) static void translog_set_only_in_buffers(TRANSLOG_ADDRESS in_buffers) { DBUG_ENTER("translog_set_only_in_buffers"); - pthread_mutex_lock(&log_descriptor.sent_to_file_lock); + translog_mutex_lock(&log_descriptor.sent_to_file_lock); DBUG_PRINT("enter", ("in_buffers: (%lu,0x%lx) " "in_buffers_only: (%lu,0x%lx)", LSN_IN_PARTS(in_buffers), @@ -1730,7 +1761,7 @@ static void translog_set_only_in_buffers(TRANSLOG_ADDRESS in_buffers) log_descriptor.in_buffers_only= in_buffers; DBUG_PRINT("info", ("set new in_buffers_only")); } - pthread_mutex_unlock(&log_descriptor.sent_to_file_lock); + translog_mutex_unlock(&log_descriptor.sent_to_file_lock); DBUG_VOID_RETURN; } @@ -1749,9 +1780,9 @@ static TRANSLOG_ADDRESS translog_only_in_buffers() { register TRANSLOG_ADDRESS addr; DBUG_ENTER("translog_only_in_buffers"); - pthread_mutex_lock(&log_descriptor.sent_to_file_lock); + translog_mutex_lock(&log_descriptor.sent_to_file_lock); addr= log_descriptor.in_buffers_only; - pthread_mutex_unlock(&log_descriptor.sent_to_file_lock); + translog_mutex_unlock(&log_descriptor.sent_to_file_lock); DBUG_RETURN(addr); } @@ -1770,9 +1801,9 @@ static LSN translog_get_sent_to_file() { register LSN lsn; DBUG_ENTER("translog_get_sent_to_file"); - pthread_mutex_lock(&log_descriptor.sent_to_file_lock); + translog_mutex_lock(&log_descriptor.sent_to_file_lock); lsn= log_descriptor.sent_to_file; - pthread_mutex_unlock(&log_descriptor.sent_to_file_lock); + translog_mutex_unlock(&log_descriptor.sent_to_file_lock); DBUG_RETURN(lsn); } @@ -2080,7 +2111,7 @@ static my_bool translog_recover_page_up_to_sector(uchar *page, uint16 offset) DBUG_PRINT("enter", ("offset: %u first chunk: %u", (uint) offset, (uint) chunk_offset)); - while (page[chunk_offset] != '\0' && chunk_offset < offset) + while (page[chunk_offset] != TRANSLOG_FILLER && chunk_offset < offset) { uint16 chunk_length; if ((chunk_length= @@ -2103,7 +2134,7 @@ static my_bool translog_recover_page_up_to_sector(uchar *page, uint16 offset) valid_chunk_end= chunk_offset; /* end of trusted area - sector parsing */ - while (page[chunk_offset] != '\0') + while (page[chunk_offset] != TRANSLOG_FILLER) { uint16 chunk_length; if ((chunk_length= @@ -2121,7 +2152,8 @@ static my_bool translog_recover_page_up_to_sector(uchar *page, uint16 offset) } DBUG_PRINT("info", ("valid chunk end offset: %u", (uint) valid_chunk_end)); - bzero(page + valid_chunk_end, TRANSLOG_PAGE_SIZE - valid_chunk_end); + memset(page + valid_chunk_end, TRANSLOG_FILLER, + TRANSLOG_PAGE_SIZE - valid_chunk_end); DBUG_RETURN(0); } @@ -2879,10 +2911,11 @@ my_bool translog_init(const char *directory, log_descriptor.horizon= last_valid_page; translog_start_buffer(log_descriptor.buffers, &log_descriptor.bc, 0); /* - Free space if filled with 0 and first uchar of - real chunk can't be 0 + Free space if filled with TRANSLOG_FILLER and first uchar of + real chunk can't be TRANSLOG_FILLER */ - while (chunk_offset < TRANSLOG_PAGE_SIZE && page[chunk_offset] != '\0') + while (chunk_offset < TRANSLOG_PAGE_SIZE && + page[chunk_offset] != TRANSLOG_FILLER) { uint16 chunk_length; if ((chunk_length= @@ -5340,7 +5373,7 @@ static my_bool translog_scanner_eop(TRANSLOG_SCANNER_DATA *scanner) { DBUG_ENTER("translog_scanner_eop"); DBUG_RETURN(scanner->page_offset >= TRANSLOG_PAGE_SIZE || - scanner->page[scanner->page_offset] == 0); + scanner->page[scanner->page_offset] == TRANSLOG_FILLER); } @@ -5401,7 +5434,7 @@ translog_get_next_chunk(TRANSLOG_SCANNER_DATA *scanner) if (translog_scanner_eol(scanner)) { - scanner->page= &end_of_log; + scanner->page= END_OF_LOG; scanner->page_offset= 0; DBUG_RETURN(0); } @@ -5434,11 +5467,11 @@ translog_get_next_chunk(TRANSLOG_SCANNER_DATA *scanner) scanner->page_offset= translog_get_first_chunk_offset(scanner->page); if (translog_scanner_eol(scanner)) { - scanner->page= &end_of_log; + scanner->page= END_OF_LOG; scanner->page_offset= 0; DBUG_RETURN(0); } - DBUG_ASSERT(scanner->page[scanner->page_offset]); + DBUG_ASSERT(scanner->page[scanner->page_offset] != TRANSLOG_FILLER); } DBUG_RETURN(0); } @@ -5456,6 +5489,7 @@ translog_get_next_chunk(TRANSLOG_SCANNER_DATA *scanner) @return Length of header or operation status @retval RECHEADER_READ_ERROR error + @retval RECHEADER_READ_EOF End of the log reached during the read @retval # number of bytes in TRANSLOG_HEADER_BUFFER::header where stored decoded part of the header @@ -5562,7 +5596,17 @@ translog_variable_length_header(uchar *page, translog_size_t page_offset, DBUG_RETURN(RECHEADER_READ_ERROR); } if (translog_get_next_chunk(scanner)) + { + if (scanner == &internal_scanner) + translog_destroy_scanner(scanner); DBUG_RETURN(RECHEADER_READ_ERROR); + } + if (scanner->page == END_OF_LOG) + { + if (scanner == &internal_scanner) + translog_destroy_scanner(scanner); + DBUG_RETURN(RECHEADER_READ_EOF); + } page= scanner->page; page_offset= scanner->page_offset; src= page + page_offset + header_to_skip; @@ -5634,7 +5678,7 @@ translog_variable_length_header(uchar *page, translog_size_t page_offset, @return Length of header or operation status @retval RECHEADER_READ_ERROR error @retval # number of bytes in - TRANSLOG_HEADER_BUFFER::header where + TRANSLOG_HEADER_BUFFER::header where stored decoded part of the header */ @@ -5804,14 +5848,26 @@ int translog_read_next_record_header(TRANSLOG_SCANNER_DATA *scanner, { if (translog_get_next_chunk(scanner)) DBUG_RETURN(RECHEADER_READ_ERROR); + if (scanner->page == END_OF_LOG) + { + DBUG_PRINT("info", ("End of file from the scanner")); + /* Last record was read */ + buff->lsn= LSN_IMPOSSIBLE; + DBUG_RETURN(RECHEADER_READ_EOF); + } chunk_type= scanner->page[scanner->page_offset] & TRANSLOG_CHUNK_TYPE; - DBUG_PRINT("info", ("type: %x byte: %x", (uint) chunk_type, + DBUG_PRINT("info", ("Page: (%lu,0x%lx) offset: %lu type: %x byte: %x", + LSN_IN_PARTS(scanner->page_addr), + (ulong) scanner->page_offset, + (uint) chunk_type, (uint) scanner->page[scanner->page_offset])); - } while (chunk_type != TRANSLOG_CHUNK_LSN && chunk_type != - TRANSLOG_CHUNK_FIXED && scanner->page[scanner->page_offset] != 0); + } while (chunk_type != TRANSLOG_CHUNK_LSN && + chunk_type != TRANSLOG_CHUNK_FIXED && + scanner->page[scanner->page_offset] != TRANSLOG_FILLER); - if (scanner->page[scanner->page_offset] == 0) + if (scanner->page[scanner->page_offset] == TRANSLOG_FILLER) { + DBUG_PRINT("info", ("End of file")); /* Last record was read */ buff->lsn= LSN_IMPOSSIBLE; /* Return 'end of log' marker */ @@ -5867,6 +5923,14 @@ static my_bool translog_record_read_next_chunk(struct st_translog_reader_data data->current_chunk++; if (translog_get_next_chunk(&data->scanner)) DBUG_RETURN(1); + if (data->scanner.page == END_OF_LOG) + { + /* + Actually it should not happened, but we wont quite nice in case of + cut log + */ + DBUG_RETURN(1); + } } type= data->scanner.page[data->scanner.page_offset] & TRANSLOG_CHUNK_TYPE; @@ -6128,7 +6192,7 @@ static void translog_force_current_buffer_to_finish() new_buff_beginning-= log_descriptor.bc.current_page_fill; current_page_fill= log_descriptor.bc.current_page_fill; - bzero(log_descriptor.bc.ptr, left); + memset(log_descriptor.bc.ptr, TRANSLOG_FILLER, left); log_descriptor.bc.buffer->size+= left; DBUG_PRINT("info", ("Finish Page buffer #%u: 0x%lx " "Size: %lu", @@ -6177,8 +6241,7 @@ static void translog_force_current_buffer_to_finish() */ translog_wait_for_writers(old_buffer); - - if (data[TRANSLOG_PAGE_FLAGS] & TRANSLOG_SECTOR_PROTECTION) + if (log_descriptor.flags & TRANSLOG_SECTOR_PROTECTION) { translog_put_sector_protection(data, &log_descriptor.bc); if (left) @@ -6194,7 +6257,7 @@ static void translog_force_current_buffer_to_finish() } } - if (data[TRANSLOG_PAGE_FLAGS] & TRANSLOG_PAGE_CRC) + if (log_descriptor.flags & TRANSLOG_PAGE_CRC) { uint32 crc= translog_crc(data + log_descriptor.page_overhead, TRANSLOG_PAGE_SIZE - @@ -6260,7 +6323,7 @@ my_bool translog_flush(LSN lsn) DBUG_PRINT("enter", ("Flush up to LSN: (%lu,0x%lx)", LSN_IN_PARTS(lsn))); DBUG_ASSERT(translog_inited == 1); - pthread_mutex_lock(&log_descriptor.log_flush_lock); + translog_mutex_lock(&log_descriptor.log_flush_lock); translog_lock(); old_flushed= log_descriptor.flushed; for (;;) @@ -6343,7 +6406,7 @@ my_bool translog_flush(LSN lsn) /** @todo LOG decide if syncing of directory is needed */ rc|= my_sync(log_descriptor.directory_fd, MYF(MY_WME | MY_IGNORE_BADFD)); out: - pthread_mutex_unlock(&log_descriptor.log_flush_lock); + translog_mutex_unlock(&log_descriptor.log_flush_lock); DBUG_RETURN(rc); } @@ -6374,7 +6437,7 @@ int translog_assign_id_to_share(MARIA_HA *tbl_info, TRN *trn) */ DBUG_ASSERT(share->data_file_type == BLOCK_RECORD); /* re-check under mutex to avoid having 2 ids for the same share */ - pthread_mutex_lock(&share->intern_lock); + translog_mutex_lock(&share->intern_lock); if (likely(share->id == 0)) { /* Inspired by set_short_trid() of trnman.c */ @@ -6421,7 +6484,7 @@ int translog_assign_id_to_share(MARIA_HA *tbl_info, TRN *trn) log_array, log_data, NULL))) return 1; } - pthread_mutex_unlock(&share->intern_lock); + translog_mutex_unlock(&share->intern_lock); return 0; } @@ -6498,14 +6561,14 @@ static uint32 translog_first_file(TRANSLOG_ADDRESS horizon, int is_protected) uint min_file= 1, max_file; DBUG_ENTER("translog_first_file"); if (!is_protected) - pthread_mutex_lock(&log_descriptor.purger_lock); + translog_mutex_lock(&log_descriptor.purger_lock); if (log_descriptor.min_file_number && translog_is_file(log_descriptor.min_file_number)) { DBUG_PRINT("info", ("cached %lu", (ulong) log_descriptor.min_file_number)); if (!is_protected) - pthread_mutex_unlock(&log_descriptor.purger_lock); + translog_mutex_unlock(&log_descriptor.purger_lock); DBUG_RETURN(log_descriptor.min_file_number); } @@ -6532,7 +6595,7 @@ static uint32 translog_first_file(TRANSLOG_ADDRESS horizon, int is_protected) } log_descriptor.min_file_number= max_file; if (!is_protected) - pthread_mutex_unlock(&log_descriptor.purger_lock); + translog_mutex_unlock(&log_descriptor.purger_lock); DBUG_RETURN(max_file); } @@ -6568,19 +6631,28 @@ LSN translog_next_LSN(TRANSLOG_ADDRESS addr, TRANSLOG_ADDRESS horizon) (uint) scanner.page[scanner.page_offset])); while (chunk_type != TRANSLOG_CHUNK_LSN && chunk_type != TRANSLOG_CHUNK_FIXED && - scanner.page[scanner.page_offset] != 0) + scanner.page[scanner.page_offset] != TRANSLOG_FILLER) { if (translog_get_next_chunk(&scanner)) - DBUG_RETURN(LSN_ERROR); + { + result= LSN_ERROR; + goto out; + } + if (scanner.page == END_OF_LOG) + { + result= LSN_IMPOSSIBLE; + goto out; + } chunk_type= scanner.page[scanner.page_offset] & TRANSLOG_CHUNK_TYPE; DBUG_PRINT("info", ("type: %x byte: %x", (uint) chunk_type, (uint) scanner.page[scanner.page_offset])); } - if (scanner.page[scanner.page_offset] == 0) + if (scanner.page[scanner.page_offset] == TRANSLOG_FILLER) result= LSN_IMPOSSIBLE; /* reached page filler */ else result= scanner.page_addr + scanner.page_offset; +out: translog_destroy_scanner(&scanner); DBUG_RETURN(result); } @@ -6678,7 +6750,7 @@ my_bool translog_purge(TRANSLOG_ADDRESS low) DBUG_PRINT("enter", ("low: (%lu,0x%lx)", LSN_IN_PARTS(low))); DBUG_ASSERT(translog_inited == 1); - pthread_mutex_lock(&log_descriptor.purger_lock); + translog_mutex_lock(&log_descriptor.purger_lock); if (LSN_FILE_NO(log_descriptor.last_lsn_checked) < last_need_file) { uint32 i; @@ -6706,6 +6778,6 @@ my_bool translog_purge(TRANSLOG_ADDRESS low) } } - pthread_mutex_unlock(&log_descriptor.purger_lock); + translog_mutex_unlock(&log_descriptor.purger_lock); DBUG_RETURN(rc); } diff --git a/storage/maria/ma_loghandler_lsn.h b/storage/maria/ma_loghandler_lsn.h index e019be16fd2..af4c6a42da1 100644 --- a/storage/maria/ma_loghandler_lsn.h +++ b/storage/maria/ma_loghandler_lsn.h @@ -83,7 +83,7 @@ typedef LSN LSN_WITH_FLAGS; #define FILENO_IMPOSSIBLE 0 /**< log file's numbering starts at 1 */ #define LOG_OFFSET_IMPOSSIBLE 0 /**< log always has a header */ -#define LSN_IMPOSSIBLE 0 +#define LSN_IMPOSSIBLE 0L /* following LSN also is impossible */ #define LSN_ERROR 1 |