diff options
-rw-r--r-- | storage/maria/ma_loghandler.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index c82b716d858..b0654cb70a0 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -20,9 +20,6 @@ /** @file @brief Module which writes and reads to a transaction log - - @todo LOG: in functions where the log's lock is required, a - translog_assert_owner() could be added. */ #define TRANSLOG_FILLER 0xFF @@ -1219,7 +1216,7 @@ static my_bool translog_buffer_lock(struct st_translog_buffer *buffer) (uint) buffer->buffer_no, (ulong) buffer, (ulong) &buffer->mutex)); res= (translog_mutex_lock(&buffer->mutex) != 0); - DBUG_RETURN(res); + DBUG_RETURN(test(res)); } #else #define translog_buffer_lock(B) \ @@ -1698,7 +1695,10 @@ static my_bool translog_buffer_next(TRANSLOG_ADDRESS *horizon, if (chasing) translog_cursor_init(cursor, new_buffer, new_buffer_no); else + { + translog_lock_assert_owner(); translog_start_buffer(new_buffer, cursor, new_buffer_no); + } log_descriptor.buffers[old_buffer_no].next_buffer_offset= new_buffer->offset; translog_new_page_header(horizon, cursor); DBUG_RETURN(0); @@ -2026,6 +2026,7 @@ static my_bool translog_buffer_flush(struct st_translog_buffer *buffer) buffer->file, LSN_IN_PARTS(buffer->offset), (ulong) buffer->size)); + translog_buffer_lock_assert_owner(buffer); DBUG_ASSERT(buffer->file != -1); @@ -2505,6 +2506,7 @@ static uchar *translog_get_page(TRANSLOG_VALIDATOR_DATA *data, uchar *buffer, DBUG_RETURN(buffer); } + /** @brief free direct log page link @@ -2524,6 +2526,7 @@ static void translog_free_link(PAGECACHE_BLOCK_LINK *direct_link) DBUG_VOID_RETURN; } + /* Finds last page of the given log file @@ -3041,7 +3044,9 @@ static void translog_buffer_destroy(struct st_translog_buffer *buffer) We ignore errors here, because we can't do something about it (it is shutting down) */ + translog_buffer_lock(buffer); translog_buffer_flush(buffer); + translog_buffer_unlock(buffer); } DBUG_PRINT("info", ("Destroy mutex: 0x%lx", (ulong) &buffer->mutex)); pthread_mutex_destroy(&buffer->mutex); @@ -5427,8 +5432,10 @@ translog_get_next_chunk(TRANSLOG_SCANNER_DATA *scanner) uint16 len; DBUG_ENTER("translog_get_next_chunk"); - if ((len= translog_get_total_chunk_length(scanner->page, - scanner->page_offset)) == 0) + if (translog_scanner_eop(scanner)) + len= TRANSLOG_PAGE_SIZE - scanner->page_offset; + else if ((len= translog_get_total_chunk_length(scanner->page, + scanner->page_offset)) == 0) DBUG_RETURN(1); scanner->page_offset+= len; @@ -6625,6 +6632,20 @@ LSN translog_next_LSN(TRANSLOG_ADDRESS addr, TRANSLOG_ADDRESS horizon) DBUG_RETURN(LSN_IMPOSSIBLE); translog_init_scanner(addr, 0, &scanner, 1); + /* addr can point not to a chunk beginning but to a page end */ + if (translog_scanner_eop(&scanner)) + { + if (translog_get_next_chunk(&scanner)) + { + 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, @@ -6657,6 +6678,7 @@ out: DBUG_RETURN(result); } + /** @brief returns the LSN of the first record starting in this log |