Commit a303f5b2 authored by unknown's avatar unknown

Fixes of the empty log problem.


storage/maria/ma_checkpoint.c:
  The new macro for easier printing LSN added.
storage/maria/ma_loghandler.c:
  The assertion returned.
  The new macro for easier printing LSN added.
storage/maria/ma_loghandler_lsn.h:
  The new macro for easier printing LSN added.
storage/maria/ma_pagecache.c:
  The new macro for easier printing LSN added.
storage/maria/ma_recovery.c:
  Recovery checks empty log state.
  RECHEADER_READ_ERROR means some real error.
storage/maria/maria_read_log.c:
  Read log starts from real beggining of the log and precess
  error and empty log states.
  The new macro for easier printing LSN added.
storage/maria/unittest/ma_test_loghandler-t.c:
  The new macro for easier printing LSN added.
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
  The new macro for easier printing LSN added.
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
  The new macro for easier printing LSN added.
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
  The new macro for easier printing LSN added.
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
  The new macro for easier printing LSN added.
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
  The new macro for easier printing LSN added.
parent 9b266392
...@@ -191,9 +191,8 @@ static int really_execute_checkpoint() ...@@ -191,9 +191,8 @@ static int really_execute_checkpoint()
this horizon. this horizon.
*/ */
checkpoint_start_log_horizon= translog_get_horizon(); checkpoint_start_log_horizon= translog_get_horizon();
#define LSN_IN_HEX(L) (ulong)LSN_FILE_NO(L),(ulong)LSN_OFFSET(L)
DBUG_PRINT("info",("checkpoint_start_log_horizon (%lu,0x%lx)", DBUG_PRINT("info",("checkpoint_start_log_horizon (%lu,0x%lx)",
LSN_IN_HEX(checkpoint_start_log_horizon))); LSN_IN_PARTS(checkpoint_start_log_horizon)));
lsn_store(checkpoint_start_log_horizon_char, checkpoint_start_log_horizon); lsn_store(checkpoint_start_log_horizon_char, checkpoint_start_log_horizon);
......
...@@ -765,7 +765,7 @@ static my_bool translog_max_lsn_to_header(File file, LSN lsn) ...@@ -765,7 +765,7 @@ static my_bool translog_max_lsn_to_header(File file, LSN lsn)
DBUG_PRINT("enter", ("File descriptor: %ld " DBUG_PRINT("enter", ("File descriptor: %ld "
"lsn: (%lu,0x%lx)", "lsn: (%lu,0x%lx)",
(long) file, (long) file,
(ulong) LSN_FILE_NO(lsn),(ulong) LSN_OFFSET(lsn))); LSN_IN_PARTS(lsn)));
lsn_store(lsn_buff, lsn); lsn_store(lsn_buff, lsn);
...@@ -860,7 +860,7 @@ static my_bool translog_set_lsn_for_files(uint32 from_file, uint32 to_file, ...@@ -860,7 +860,7 @@ static my_bool translog_set_lsn_for_files(uint32 from_file, uint32 to_file,
DBUG_ENTER("translog_set_lsn_for_files"); DBUG_ENTER("translog_set_lsn_for_files");
DBUG_PRINT("enter", ("From: %lu to: %lu lsn: (%lu,0x%lx) locked: %d", DBUG_PRINT("enter", ("From: %lu to: %lu lsn: (%lu,0x%lx) locked: %d",
(ulong) from_file, (ulong) to_file, (ulong) from_file, (ulong) to_file,
(ulong) LSN_FILE_NO(lsn), (ulong) LSN_OFFSET(lsn), LSN_IN_PARTS(lsn),
is_locked)); is_locked));
DBUG_ASSERT(from_file <= to_file); DBUG_ASSERT(from_file <= to_file);
DBUG_ASSERT(from_file > 0); /* we have not file 0 */ DBUG_ASSERT(from_file > 0); /* we have not file 0 */
...@@ -1067,8 +1067,7 @@ LSN translog_get_file_max_lsn_stored(uint32 file) ...@@ -1067,8 +1067,7 @@ LSN translog_get_file_max_lsn_stored(uint32 file)
DBUG_RETURN(LSN_ERROR); DBUG_RETURN(LSN_ERROR);
} }
DBUG_PRINT("error", ("Max lsn: (%lu,0x%lx)", DBUG_PRINT("error", ("Max lsn: (%lu,0x%lx)",
(ulong) LSN_FILE_NO(info.max_lsn), LSN_IN_PARTS(info.max_lsn)));
(ulong) LSN_OFFSET(info.max_lsn)));
DBUG_RETURN(info.max_lsn); DBUG_RETURN(info.max_lsn);
} }
} }
...@@ -1280,8 +1279,7 @@ static void translog_new_page_header(TRANSLOG_ADDRESS *horizon, ...@@ -1280,8 +1279,7 @@ static void translog_new_page_header(TRANSLOG_ADDRESS *horizon,
{ {
#ifndef DBUG_OFF #ifndef DBUG_OFF
DBUG_PRINT("info", ("write 0x11223344 CRC to (%lu,0x%lx)", DBUG_PRINT("info", ("write 0x11223344 CRC to (%lu,0x%lx)",
(ulong) LSN_FILE_NO(*horizon), LSN_IN_PARTS(*horizon)));
(ulong) LSN_OFFSET(*horizon)));
/* This will be overwritten by real CRC; This is just for debugging */ /* This will be overwritten by real CRC; This is just for debugging */
int4store(ptr, 0x11223344); int4store(ptr, 0x11223344);
#endif #endif
...@@ -1414,8 +1412,7 @@ static void translog_finish_page(TRANSLOG_ADDRESS *horizon, ...@@ -1414,8 +1412,7 @@ static void translog_finish_page(TRANSLOG_ADDRESS *horizon,
"Page addr: (%lu,0x%lx) " "Page addr: (%lu,0x%lx) "
"size:%lu (%lu) Pg:%u left:%u", "size:%lu (%lu) Pg:%u left:%u",
(uint) cursor->buffer_no, (ulong) cursor->buffer, (uint) cursor->buffer_no, (ulong) cursor->buffer,
(ulong) LSN_FILE_NO(cursor->buffer->offset), LSN_IN_PARTS(cursor->buffer->offset),
(ulong) LSN_OFFSET(cursor->buffer->offset),
(ulong) LSN_FILE_NO(*horizon), (ulong) LSN_FILE_NO(*horizon),
(ulong) (LSN_OFFSET(*horizon) - (ulong) (LSN_OFFSET(*horizon) -
cursor->current_page_fill), cursor->current_page_fill),
...@@ -1647,8 +1644,7 @@ static my_bool translog_buffer_next(TRANSLOG_ADDRESS *horizon, ...@@ -1647,8 +1644,7 @@ static my_bool translog_buffer_next(TRANSLOG_ADDRESS *horizon,
DBUG_ENTER("translog_buffer_next"); DBUG_ENTER("translog_buffer_next");
DBUG_PRINT("info", ("horizon: (%lu,0x%lx) chasing: %d", DBUG_PRINT("info", ("horizon: (%lu,0x%lx) chasing: %d",
(ulong) LSN_FILE_NO(log_descriptor.horizon), LSN_IN_PARTS(log_descriptor.horizon), chasing));
(ulong) LSN_OFFSET(log_descriptor.horizon), chasing));
DBUG_ASSERT(cmp_translog_addr(log_descriptor.horizon, *horizon) >= 0); DBUG_ASSERT(cmp_translog_addr(log_descriptor.horizon, *horizon) >= 0);
...@@ -1703,12 +1699,9 @@ static void translog_set_sent_to_file(LSN lsn, TRANSLOG_ADDRESS in_buffers) ...@@ -1703,12 +1699,9 @@ static void translog_set_sent_to_file(LSN lsn, TRANSLOG_ADDRESS in_buffers)
pthread_mutex_lock(&log_descriptor.sent_to_file_lock); pthread_mutex_lock(&log_descriptor.sent_to_file_lock);
DBUG_PRINT("enter", ("lsn: (%lu,0x%lx) in_buffers: (%lu,0x%lx) " DBUG_PRINT("enter", ("lsn: (%lu,0x%lx) in_buffers: (%lu,0x%lx) "
"in_buffers_only: (%lu,0x%lx)", "in_buffers_only: (%lu,0x%lx)",
(ulong) LSN_FILE_NO(lsn), LSN_IN_PARTS(lsn),
(ulong) LSN_OFFSET(lsn), LSN_IN_PARTS(in_buffers),
(ulong) LSN_FILE_NO(in_buffers), LSN_IN_PARTS(log_descriptor.in_buffers_only)));
(ulong) LSN_OFFSET(in_buffers),
(ulong) LSN_FILE_NO(log_descriptor.in_buffers_only),
(ulong) LSN_OFFSET(log_descriptor.in_buffers_only)));
DBUG_ASSERT(cmp_translog_addr(lsn, log_descriptor.sent_to_file) >= 0); DBUG_ASSERT(cmp_translog_addr(lsn, log_descriptor.sent_to_file) >= 0);
log_descriptor.sent_to_file= lsn; log_descriptor.sent_to_file= lsn;
/* LSN_IMPOSSIBLE == 0 => it will work for very first time */ /* LSN_IMPOSSIBLE == 0 => it will work for very first time */
...@@ -1737,10 +1730,8 @@ static void translog_set_only_in_buffers(TRANSLOG_ADDRESS in_buffers) ...@@ -1737,10 +1730,8 @@ static void translog_set_only_in_buffers(TRANSLOG_ADDRESS in_buffers)
pthread_mutex_lock(&log_descriptor.sent_to_file_lock); pthread_mutex_lock(&log_descriptor.sent_to_file_lock);
DBUG_PRINT("enter", ("in_buffers: (%lu,0x%lx) " DBUG_PRINT("enter", ("in_buffers: (%lu,0x%lx) "
"in_buffers_only: (%lu,0x%lx)", "in_buffers_only: (%lu,0x%lx)",
(ulong) LSN_FILE_NO(in_buffers), LSN_IN_PARTS(in_buffers),
(ulong) LSN_OFFSET(in_buffers), LSN_IN_PARTS(log_descriptor.in_buffers_only)));
(ulong) LSN_FILE_NO(log_descriptor.in_buffers_only),
(ulong) LSN_OFFSET(log_descriptor.in_buffers_only)));
/* LSN_IMPOSSIBLE == 0 => it will work for very first time */ /* LSN_IMPOSSIBLE == 0 => it will work for very first time */
if (cmp_translog_addr(in_buffers, log_descriptor.in_buffers_only) > 0) if (cmp_translog_addr(in_buffers, log_descriptor.in_buffers_only) > 0)
{ {
...@@ -2010,8 +2001,7 @@ static my_bool translog_buffer_flush(struct st_translog_buffer *buffer) ...@@ -2010,8 +2001,7 @@ static my_bool translog_buffer_flush(struct st_translog_buffer *buffer)
"file: %d offset: (%lu,0x%lx) size: %lu", "file: %d offset: (%lu,0x%lx) size: %lu",
(uint) buffer->buffer_no, (ulong) buffer, (uint) buffer->buffer_no, (ulong) buffer,
buffer->file, buffer->file,
(ulong) LSN_FILE_NO(buffer->offset), LSN_IN_PARTS(buffer->offset),
(ulong) LSN_OFFSET(buffer->offset),
(ulong) buffer->size)); (ulong) buffer->size));
DBUG_ASSERT(buffer->file != -1); DBUG_ASSERT(buffer->file != -1);
...@@ -2174,7 +2164,7 @@ static my_bool translog_page_validator(uchar *page_addr, uchar* data_ptr) ...@@ -2174,7 +2164,7 @@ static my_bool translog_page_validator(uchar *page_addr, uchar* data_ptr)
UNRECOVERABLE_ERROR(("Page (%lu,0x%lx): " UNRECOVERABLE_ERROR(("Page (%lu,0x%lx): "
"page address written in the page is incorrect: " "page address written in the page is incorrect: "
"File %lu instead of %lu or page %lu instead of %lu", "File %lu instead of %lu or page %lu instead of %lu",
(ulong) LSN_FILE_NO(addr), (ulong) LSN_OFFSET(addr), LSN_IN_PARTS(addr),
(ulong) uint3korr(page + 3), (ulong) LSN_FILE_NO(addr), (ulong) uint3korr(page + 3), (ulong) LSN_FILE_NO(addr),
(ulong) uint3korr(page), (ulong) uint3korr(page),
(ulong) LSN_OFFSET(addr) / TRANSLOG_PAGE_SIZE)); (ulong) LSN_OFFSET(addr) / TRANSLOG_PAGE_SIZE));
...@@ -2187,8 +2177,7 @@ static my_bool translog_page_validator(uchar *page_addr, uchar* data_ptr) ...@@ -2187,8 +2177,7 @@ static my_bool translog_page_validator(uchar *page_addr, uchar* data_ptr)
{ {
UNRECOVERABLE_ERROR(("Page (%lu,0x%lx): " UNRECOVERABLE_ERROR(("Page (%lu,0x%lx): "
"Garbage in the page flags field detected : %x", "Garbage in the page flags field detected : %x",
(ulong) LSN_FILE_NO(addr), (ulong) LSN_OFFSET(addr), LSN_IN_PARTS(addr), (uint) flags));
(uint) flags));
DBUG_RETURN(1); DBUG_RETURN(1);
} }
page_pos= page + (3 + 3 + 1); page_pos= page + (3 + 3 + 1);
...@@ -2201,7 +2190,7 @@ static my_bool translog_page_validator(uchar *page_addr, uchar* data_ptr) ...@@ -2201,7 +2190,7 @@ static my_bool translog_page_validator(uchar *page_addr, uchar* data_ptr)
{ {
UNRECOVERABLE_ERROR(("Page (%lu,0x%lx): " UNRECOVERABLE_ERROR(("Page (%lu,0x%lx): "
"CRC mismatch: calculated: %lx on the page %lx", "CRC mismatch: calculated: %lx on the page %lx",
(ulong) LSN_FILE_NO(addr), (ulong) LSN_OFFSET(addr), LSN_IN_PARTS(addr),
(ulong) crc, (ulong) uint4korr(page_pos))); (ulong) crc, (ulong) uint4korr(page_pos)));
DBUG_RETURN(1); DBUG_RETURN(1);
} }
...@@ -2335,8 +2324,7 @@ static uchar *translog_get_page(TRANSLOG_VALIDATOR_DATA *data, uchar *buffer) ...@@ -2335,8 +2324,7 @@ static uchar *translog_get_page(TRANSLOG_VALIDATOR_DATA *data, uchar *buffer)
in_buffers= translog_only_in_buffers(); in_buffers= translog_only_in_buffers();
DBUG_PRINT("info", ("in_buffers: (%lu,0x%lx)", DBUG_PRINT("info", ("in_buffers: (%lu,0x%lx)",
(ulong) LSN_FILE_NO(in_buffers), LSN_IN_PARTS(in_buffers)));
(ulong) LSN_OFFSET(in_buffers)));
if (in_buffers != LSN_IMPOSSIBLE && if (in_buffers != LSN_IMPOSSIBLE &&
cmp_translog_addr(addr, in_buffers) >= 0) cmp_translog_addr(addr, in_buffers) >= 0)
{ {
...@@ -2983,8 +2971,7 @@ static void translog_buffer_destroy(struct st_translog_buffer *buffer) ...@@ -2983,8 +2971,7 @@ static void translog_buffer_destroy(struct st_translog_buffer *buffer)
("Buffer #%u: 0x%lx file: %d offset: (%lu,0x%lx) size: %lu", ("Buffer #%u: 0x%lx file: %d offset: (%lu,0x%lx) size: %lu",
(uint) buffer->buffer_no, (ulong) buffer, (uint) buffer->buffer_no, (ulong) buffer,
buffer->file, buffer->file,
(ulong) LSN_FILE_NO(buffer->offset), LSN_IN_PARTS(buffer->offset),
(ulong) LSN_OFFSET(buffer->offset),
(ulong) buffer->size)); (ulong) buffer->size));
DBUG_ASSERT(buffer->waiting_filling_buffer.last_thread == 0); DBUG_ASSERT(buffer->waiting_filling_buffer.last_thread == 0);
if (buffer->file != -1) if (buffer->file != -1)
...@@ -3240,8 +3227,7 @@ static my_bool translog_write_parts_on_page(TRANSLOG_ADDRESS *horizon, ...@@ -3240,8 +3227,7 @@ static my_bool translog_write_parts_on_page(TRANSLOG_ADDRESS *horizon,
} while (left); } while (left);
DBUG_PRINT("info", ("Horizon: (%lu,0x%lx) Length %lu(0x%lx)", DBUG_PRINT("info", ("Horizon: (%lu,0x%lx) Length %lu(0x%lx)",
(ulong) LSN_FILE_NO(*horizon), LSN_IN_PARTS(*horizon),
(ulong) LSN_OFFSET(*horizon),
(ulong) length, (ulong) length)); (ulong) length, (ulong) length));
parts->current= cur; parts->current= cur;
(*horizon)+= length; /* offset increasing */ (*horizon)+= length; /* offset increasing */
...@@ -3254,8 +3240,7 @@ static my_bool translog_write_parts_on_page(TRANSLOG_ADDRESS *horizon, ...@@ -3254,8 +3240,7 @@ static my_bool translog_write_parts_on_page(TRANSLOG_ADDRESS *horizon,
(uint) cursor->buffer->buffer_no, (ulong) cursor->buffer, (uint) cursor->buffer->buffer_no, (ulong) cursor->buffer,
cursor->chaser, (ulong) cursor->buffer->size, cursor->chaser, (ulong) cursor->buffer->size,
(ulong) (cursor->ptr - cursor->buffer->buffer), (ulong) (cursor->ptr - cursor->buffer->buffer),
(ulong) LSN_FILE_NO(*horizon), LSN_IN_PARTS(*horizon),
(ulong) LSN_OFFSET(*horizon),
(ulong) (LSN_OFFSET(cursor->buffer->offset) + (ulong) (LSN_OFFSET(cursor->buffer->offset) +
cursor->buffer->size))); cursor->buffer->size)));
DBUG_EXECUTE("info", translog_check_cursor(cursor);); DBUG_EXECUTE("info", translog_check_cursor(cursor););
...@@ -3473,8 +3458,7 @@ static my_bool translog_advance_pointer(uint pages, uint16 last_page_data) ...@@ -3473,8 +3458,7 @@ static my_bool translog_advance_pointer(uint pages, uint16 last_page_data)
translog_size_t buffer_end_offset, file_end_offset, min_offset; translog_size_t buffer_end_offset, file_end_offset, min_offset;
DBUG_ENTER("translog_advance_pointer"); DBUG_ENTER("translog_advance_pointer");
DBUG_PRINT("enter", ("Pointer: (%lu, 0x%lx) + %u + %u pages + %u + %u", DBUG_PRINT("enter", ("Pointer: (%lu, 0x%lx) + %u + %u pages + %u + %u",
(ulong) LSN_FILE_NO(log_descriptor.horizon), LSN_IN_PARTS(log_descriptor.horizon),
(ulong) LSN_OFFSET(log_descriptor.horizon),
(uint) (TRANSLOG_PAGE_SIZE - (uint) (TRANSLOG_PAGE_SIZE -
log_descriptor.bc.current_page_fill), log_descriptor.bc.current_page_fill),
pages, (uint) log_descriptor.page_overhead, pages, (uint) log_descriptor.page_overhead,
...@@ -3576,8 +3560,7 @@ static my_bool translog_advance_pointer(uint pages, uint16 last_page_data) ...@@ -3576,8 +3560,7 @@ static my_bool translog_advance_pointer(uint pages, uint16 last_page_data)
(uint) last_page_offset)); (uint) last_page_offset));
DBUG_PRINT("info", DBUG_PRINT("info",
("pointer moved to: (%lu, 0x%lx)", ("pointer moved to: (%lu, 0x%lx)",
(ulong) LSN_FILE_NO(log_descriptor.horizon), LSN_IN_PARTS(log_descriptor.horizon)));
(ulong) LSN_OFFSET(log_descriptor.horizon)));
DBUG_EXECUTE("info", translog_check_cursor(&log_descriptor.bc);); DBUG_EXECUTE("info", translog_check_cursor(&log_descriptor.bc););
log_descriptor.bc.protected= 0; log_descriptor.bc.protected= 0;
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -3755,10 +3738,8 @@ translog_write_variable_record_1group(LSN *lsn, ...@@ -3755,10 +3738,8 @@ translog_write_variable_record_1group(LSN *lsn,
DBUG_PRINT("info", ("absolute horizon: (%lu,0x%lx) local: (%lu,0x%lx)", DBUG_PRINT("info", ("absolute horizon: (%lu,0x%lx) local: (%lu,0x%lx)",
(ulong) LSN_FILE_NO(log_descriptor.horizon), LSN_IN_PARTS(log_descriptor.horizon),
(ulong) LSN_OFFSET(log_descriptor.horizon), LSN_IN_PARTS(horizon)));
(ulong) LSN_FILE_NO(horizon),
(ulong) LSN_OFFSET(horizon)));
for (i= 0; i < full_pages; i++) for (i= 0; i < full_pages; i++)
{ {
...@@ -3766,10 +3747,8 @@ translog_write_variable_record_1group(LSN *lsn, ...@@ -3766,10 +3747,8 @@ translog_write_variable_record_1group(LSN *lsn,
DBUG_RETURN(1); DBUG_RETURN(1);
DBUG_PRINT("info", ("absolute horizon: (%lu,0x%lx) local: (%lu,0x%lx)", DBUG_PRINT("info", ("absolute horizon: (%lu,0x%lx) local: (%lu,0x%lx)",
(ulong) LSN_FILE_NO(log_descriptor.horizon), LSN_IN_PARTS(log_descriptor.horizon),
(ulong) LSN_OFFSET(log_descriptor.horizon), LSN_IN_PARTS(horizon)));
(ulong) LSN_FILE_NO(horizon),
(ulong) LSN_OFFSET(horizon)));
} }
if (additional_chunk3_page) if (additional_chunk3_page)
...@@ -3780,10 +3759,8 @@ translog_write_variable_record_1group(LSN *lsn, ...@@ -3780,10 +3759,8 @@ translog_write_variable_record_1group(LSN *lsn,
&horizon, &cursor)) &horizon, &cursor))
DBUG_RETURN(1); DBUG_RETURN(1);
DBUG_PRINT("info", ("absolute horizon: (%lu,0x%lx) local: (%lu,0x%lx)", DBUG_PRINT("info", ("absolute horizon: (%lu,0x%lx) local: (%lu,0x%lx)",
(ulong) LSN_FILE_NO(log_descriptor.horizon), LSN_IN_PARTS(log_descriptor.horizon),
(ulong) LSN_OFFSET(log_descriptor.horizon), LSN_IN_PARTS(horizon)));
(ulong) LSN_FILE_NO(horizon),
(ulong) LSN_OFFSET(horizon)));
DBUG_ASSERT(cursor.current_page_fill == TRANSLOG_PAGE_SIZE); DBUG_ASSERT(cursor.current_page_fill == TRANSLOG_PAGE_SIZE);
} }
...@@ -3909,10 +3886,8 @@ static uchar *translog_put_LSN_diff(LSN base_lsn, LSN lsn, uchar *dst) ...@@ -3909,10 +3886,8 @@ static uchar *translog_put_LSN_diff(LSN base_lsn, LSN lsn, uchar *dst)
{ {
DBUG_ENTER("translog_put_LSN_diff"); DBUG_ENTER("translog_put_LSN_diff");
DBUG_PRINT("enter", ("Base: (0x%lu,0x%lx) val: (0x%lu,0x%lx) dst: 0x%lx", DBUG_PRINT("enter", ("Base: (0x%lu,0x%lx) val: (0x%lu,0x%lx) dst: 0x%lx",
(ulong) LSN_FILE_NO(base_lsn), LSN_IN_PARTS(base_lsn), LSN_IN_PARTS(lsn),
(ulong) LSN_OFFSET(base_lsn), (ulong) dst));
(ulong) LSN_FILE_NO(lsn),
(ulong) LSN_OFFSET(lsn), (ulong) dst));
if (LSN_FILE_NO(base_lsn) == LSN_FILE_NO(lsn)) if (LSN_FILE_NO(base_lsn) == LSN_FILE_NO(lsn))
{ {
uint32 diff; uint32 diff;
...@@ -4022,9 +3997,7 @@ static uchar *translog_get_LSN_from_diff(LSN base_lsn, uchar *src, uchar *dst) ...@@ -4022,9 +3997,7 @@ static uchar *translog_get_LSN_from_diff(LSN base_lsn, uchar *src, uchar *dst)
uint8 code; uint8 code;
DBUG_ENTER("translog_get_LSN_from_diff"); DBUG_ENTER("translog_get_LSN_from_diff");
DBUG_PRINT("enter", ("Base: (0x%lx,0x%lx) src: 0x%lx dst 0x%lx", DBUG_PRINT("enter", ("Base: (0x%lx,0x%lx) src: 0x%lx dst 0x%lx",
(ulong) LSN_FILE_NO(base_lsn), LSN_IN_PARTS(base_lsn), (ulong) src, (ulong) dst));
(ulong) LSN_OFFSET(base_lsn),
(ulong) src, (ulong) dst));
first_byte= *((uint8*) src); first_byte= *((uint8*) src);
code= first_byte >> 6; /* Length is in 2 most significant bits */ code= first_byte >> 6; /* Length is in 2 most significant bits */
first_byte&= 0x3F; first_byte&= 0x3F;
...@@ -4312,10 +4285,8 @@ translog_write_variable_record_mgroup(LSN *lsn, ...@@ -4312,10 +4285,8 @@ translog_write_variable_record_mgroup(LSN *lsn,
translog_write_parts_on_page(&horizon, &cursor, first_page - 1, parts); translog_write_parts_on_page(&horizon, &cursor, first_page - 1, parts);
DBUG_PRINT("info", ("absolute horizon: (%lu,0x%lx) local: (%lu,0x%lx) " DBUG_PRINT("info", ("absolute horizon: (%lu,0x%lx) local: (%lu,0x%lx) "
"Left %lu", "Left %lu",
(ulong) LSN_FILE_NO(log_descriptor.horizon), LSN_IN_PARTS(log_descriptor.horizon),
(ulong) LSN_OFFSET(log_descriptor.horizon), LSN_IN_PARTS(horizon),
(ulong) LSN_FILE_NO(horizon),
(ulong) LSN_OFFSET(horizon),
(ulong) (parts->record_length - (first_page - 1) - (ulong) (parts->record_length - (first_page - 1) -
done))); done)));
...@@ -4327,10 +4298,8 @@ translog_write_variable_record_mgroup(LSN *lsn, ...@@ -4327,10 +4298,8 @@ translog_write_variable_record_mgroup(LSN *lsn,
DBUG_PRINT("info", ("absolute horizon: (%lu,0x%lx) " DBUG_PRINT("info", ("absolute horizon: (%lu,0x%lx) "
"local: (%lu,0x%lx) " "local: (%lu,0x%lx) "
"Left: %lu", "Left: %lu",
(ulong) LSN_FILE_NO(log_descriptor.horizon), LSN_IN_PARTS(log_descriptor.horizon),
(ulong) LSN_OFFSET(log_descriptor.horizon), LSN_IN_PARTS(horizon),
(ulong) LSN_FILE_NO(horizon),
(ulong) LSN_OFFSET(horizon),
(ulong) (parts->record_length - (first_page - 1) - (ulong) (parts->record_length - (first_page - 1) -
i * log_descriptor.page_capacity_chunk_2 - i * log_descriptor.page_capacity_chunk_2 -
done))); done)));
...@@ -4456,10 +4425,8 @@ translog_write_variable_record_mgroup(LSN *lsn, ...@@ -4456,10 +4425,8 @@ translog_write_variable_record_mgroup(LSN *lsn,
translog_write_parts_on_page(&horizon, &cursor, first_page - 1, parts); translog_write_parts_on_page(&horizon, &cursor, first_page - 1, parts);
DBUG_PRINT("info", ("absolute horizon: (%lu,0x%lx) local: (%lu,0x%lx) " DBUG_PRINT("info", ("absolute horizon: (%lu,0x%lx) local: (%lu,0x%lx) "
"Left: %lu", "Left: %lu",
(ulong) LSN_FILE_NO(log_descriptor.horizon), LSN_IN_PARTS(log_descriptor.horizon),
(ulong) LSN_OFFSET(log_descriptor.horizon), LSN_IN_PARTS(horizon),
(ulong) LSN_FILE_NO(horizon),
(ulong) LSN_OFFSET(horizon),
(ulong) (parts->record_length - (first_page - 1) - (ulong) (parts->record_length - (first_page - 1) -
done))); done)));
} }
...@@ -4475,10 +4442,8 @@ translog_write_variable_record_mgroup(LSN *lsn, ...@@ -4475,10 +4442,8 @@ translog_write_variable_record_mgroup(LSN *lsn,
translog_write_parts_on_page(&horizon, &cursor, chunk3_size, parts); translog_write_parts_on_page(&horizon, &cursor, chunk3_size, parts);
DBUG_PRINT("info", ("absolute horizon: (%lu,0x%lx) local: (%lu,0x%lx) " DBUG_PRINT("info", ("absolute horizon: (%lu,0x%lx) local: (%lu,0x%lx) "
"Left: %lu", "Left: %lu",
(ulong) LSN_FILE_NO(log_descriptor.horizon), LSN_IN_PARTS(log_descriptor.horizon),
(ulong) LSN_OFFSET(log_descriptor.horizon), LSN_IN_PARTS(horizon),
(ulong) LSN_FILE_NO(horizon),
(ulong) LSN_OFFSET(horizon),
(ulong) (parts->record_length - chunk3_size - done))); (ulong) (parts->record_length - chunk3_size - done)));
} }
else else
...@@ -4495,10 +4460,8 @@ translog_write_variable_record_mgroup(LSN *lsn, ...@@ -4495,10 +4460,8 @@ translog_write_variable_record_mgroup(LSN *lsn,
DBUG_PRINT("info", ("absolute horizon: (%lu,0x%lx) local: (%lu,0x%lx) " DBUG_PRINT("info", ("absolute horizon: (%lu,0x%lx) local: (%lu,0x%lx) "
"Left: %lu", "Left: %lu",
(ulong) LSN_FILE_NO(log_descriptor.horizon), LSN_IN_PARTS(log_descriptor.horizon),
(ulong) LSN_OFFSET(log_descriptor.horizon), LSN_IN_PARTS(horizon),
(ulong) LSN_FILE_NO(horizon),
(ulong) LSN_OFFSET(horizon),
(ulong) (parts->record_length - (first_page - 1) - (ulong) (parts->record_length - (first_page - 1) -
i * log_descriptor.page_capacity_chunk_2 - i * log_descriptor.page_capacity_chunk_2 -
done))); done)));
...@@ -4510,11 +4473,8 @@ translog_write_variable_record_mgroup(LSN *lsn, ...@@ -4510,11 +4473,8 @@ translog_write_variable_record_mgroup(LSN *lsn,
&horizon, &cursor)) &horizon, &cursor))
goto err; goto err;
DBUG_PRINT("info", ("absolute horizon: (%lu,0x%lx) local: (%lu,0x%lx)", DBUG_PRINT("info", ("absolute horizon: (%lu,0x%lx) local: (%lu,0x%lx)",
(ulong) LSN_FILE_NO(log_descriptor.horizon), LSN_IN_PARTS(log_descriptor.horizon),
(ulong) LSN_OFFSET(log_descriptor.horizon), LSN_IN_PARTS(horizon)));
(ulong) LSN_FILE_NO(horizon),
(ulong) LSN_OFFSET(horizon)));
*chunk0_header= (uchar) (type |TRANSLOG_CHUNK_LSN); *chunk0_header= (uchar) (type |TRANSLOG_CHUNK_LSN);
int2store(chunk0_header + 1, short_trid); int2store(chunk0_header + 1, short_trid);
...@@ -4660,8 +4620,7 @@ static my_bool translog_write_variable_record(LSN *lsn, ...@@ -4660,8 +4620,7 @@ static my_bool translog_write_variable_record(LSN *lsn,
translog_lock(); translog_lock();
DBUG_PRINT("info", ("horizon: (%lu,0x%lx)", DBUG_PRINT("info", ("horizon: (%lu,0x%lx)",
(ulong) LSN_FILE_NO(log_descriptor.horizon), LSN_IN_PARTS(log_descriptor.horizon)));
(ulong) LSN_OFFSET(log_descriptor.horizon)));
page_rest= TRANSLOG_PAGE_SIZE - log_descriptor.bc.current_page_fill; page_rest= TRANSLOG_PAGE_SIZE - log_descriptor.bc.current_page_fill;
DBUG_PRINT("info", ("header length: %u page_rest: %u", DBUG_PRINT("info", ("header length: %u page_rest: %u",
header_length1, page_rest)); header_length1, page_rest));
...@@ -4791,8 +4750,7 @@ static my_bool translog_write_fixed_record(LSN *lsn, ...@@ -4791,8 +4750,7 @@ static my_bool translog_write_fixed_record(LSN *lsn,
translog_lock(); translog_lock();
DBUG_PRINT("info", ("horizon: (%lu,0x%lx)", DBUG_PRINT("info", ("horizon: (%lu,0x%lx)",
(ulong) LSN_FILE_NO(log_descriptor.horizon), LSN_IN_PARTS(log_descriptor.horizon)));
(ulong) LSN_OFFSET(log_descriptor.horizon)));
DBUG_ASSERT(log_descriptor.bc.current_page_fill <= TRANSLOG_PAGE_SIZE); DBUG_ASSERT(log_descriptor.bc.current_page_fill <= TRANSLOG_PAGE_SIZE);
DBUG_PRINT("info", DBUG_PRINT("info",
...@@ -5035,8 +4993,7 @@ my_bool translog_write_record(LSN *lsn, ...@@ -5035,8 +4993,7 @@ my_bool translog_write_record(LSN *lsn,
} }
} }
DBUG_PRINT("info", ("LSN: (%lu,0x%lx)", (ulong) LSN_FILE_NO(*lsn), DBUG_PRINT("info", ("LSN: (%lu,0x%lx)", LSN_IN_PARTS(*lsn)));
(ulong) LSN_OFFSET(*lsn)));
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
...@@ -5207,9 +5164,7 @@ my_bool translog_init_scanner(LSN lsn, ...@@ -5207,9 +5164,7 @@ my_bool translog_init_scanner(LSN lsn,
{ {
TRANSLOG_VALIDATOR_DATA data; TRANSLOG_VALIDATOR_DATA data;
DBUG_ENTER("translog_init_scanner"); DBUG_ENTER("translog_init_scanner");
DBUG_PRINT("enter", ("LSN: (0x%lu,0x%lx)", DBUG_PRINT("enter", ("LSN: (0x%lu,0x%lx)", LSN_IN_PARTS(lsn));
(ulong) LSN_FILE_NO(lsn),
(ulong) LSN_OFFSET(lsn));
DBUG_ASSERT(LSN_OFFSET(lsn) % TRANSLOG_PAGE_SIZE != 0); DBUG_ASSERT(LSN_OFFSET(lsn) % TRANSLOG_PAGE_SIZE != 0);
data.addr= &scanner->page_addr; data.addr= &scanner->page_addr;
...@@ -5221,8 +5176,7 @@ my_bool translog_init_scanner(LSN lsn, ...@@ -5221,8 +5176,7 @@ my_bool translog_init_scanner(LSN lsn,
scanner->horizon= translog_get_horizon(); scanner->horizon= translog_get_horizon();
DBUG_PRINT("info", ("horizon: (0x%lu,0x%lx)", DBUG_PRINT("info", ("horizon: (0x%lu,0x%lx)",
(ulong) LSN_FILE_NO(scanner->horizon), LSN_IN_PARTS(scanner->horizon)));
(ulong) LSN_OFFSET(scanner->horizon)));
/* lsn < horizon */ /* lsn < horizon */
DBUG_ASSERT(lsn < scanner->horizon)); DBUG_ASSERT(lsn < scanner->horizon));
...@@ -5256,10 +5210,8 @@ static my_bool translog_scanner_eol(TRANSLOG_SCANNER_DATA *scanner) ...@@ -5256,10 +5210,8 @@ static my_bool translog_scanner_eol(TRANSLOG_SCANNER_DATA *scanner)
DBUG_ENTER("translog_scanner_eol"); DBUG_ENTER("translog_scanner_eol");
DBUG_PRINT("enter", DBUG_PRINT("enter",
("Horizon: (%lu, 0x%lx) Current: (%lu, 0x%lx+0x%x=0x%lx)", ("Horizon: (%lu, 0x%lx) Current: (%lu, 0x%lx+0x%x=0x%lx)",
(ulong) LSN_FILE_NO(scanner->horizon), LSN_IN_PARTS(scanner->horizon),
(ulong) LSN_OFFSET(scanner->horizon), LSN_IN_PARTS(scanner->page_addr),
(ulong) LSN_FILE_NO(scanner->page_addr),
(ulong) LSN_OFFSET(scanner->page_addr),
(uint) scanner->page_offset, (uint) scanner->page_offset,
(ulong) (LSN_OFFSET(scanner->page_addr) + scanner->page_offset))); (ulong) (LSN_OFFSET(scanner->page_addr) + scanner->page_offset)));
if (scanner->horizon > (scanner->page_addr + if (scanner->horizon > (scanner->page_addr +
...@@ -5371,10 +5323,8 @@ translog_get_next_chunk(TRANSLOG_SCANNER_DATA *scanner) ...@@ -5371,10 +5323,8 @@ translog_get_next_chunk(TRANSLOG_SCANNER_DATA *scanner)
if (translog_scanner_eof(scanner)) if (translog_scanner_eof(scanner))
{ {
DBUG_PRINT("info", ("horizon: (%lu,0x%lx) pageaddr: (%lu,0x%lx)", DBUG_PRINT("info", ("horizon: (%lu,0x%lx) pageaddr: (%lu,0x%lx)",
(ulong) LSN_FILE_NO(scanner->horizon), LSN_IN_PARTS(scanner->horizon),
(ulong) LSN_OFFSET(scanner->horizon), LSN_IN_PARTS(scanner->page_addr)));
(ulong) LSN_FILE_NO(scanner->page_addr),
(ulong) LSN_OFFSET(scanner->page_addr)));
/* if it is log end it have to be caught before */ /* if it is log end it have to be caught before */
DBUG_ASSERT(LSN_FILE_NO(scanner->horizon) > DBUG_ASSERT(LSN_FILE_NO(scanner->horizon) >
LSN_FILE_NO(scanner->page_addr)); LSN_FILE_NO(scanner->page_addr));
...@@ -5492,8 +5442,7 @@ int translog_variable_length_header(uchar *page, translog_size_t page_offset, ...@@ -5492,8 +5442,7 @@ int translog_variable_length_header(uchar *page, translog_size_t page_offset,
buff->groups[curr].num= src[i * (7 + 1) + 7]; buff->groups[curr].num= src[i * (7 + 1) + 7];
DBUG_PRINT("info", ("group #%u (%lu,0x%lx) chunks: %u", DBUG_PRINT("info", ("group #%u (%lu,0x%lx) chunks: %u",
curr, curr,
(ulong) LSN_FILE_NO(buff->groups[curr].addr), LSN_IN_PARTS(buff->groups[curr].addr),
(ulong) LSN_OFFSET(buff->groups[curr].addr),
(uint) buff->groups[curr].num)); (uint) buff->groups[curr].num));
} }
grp_no-= read; grp_no-= read;
...@@ -5513,8 +5462,7 @@ int translog_variable_length_header(uchar *page, translog_size_t page_offset, ...@@ -5513,8 +5462,7 @@ int translog_variable_length_header(uchar *page, translog_size_t page_offset,
} }
buff->chunk0_data_len= chunk_len - 2 - read * (7 + 1); buff->chunk0_data_len= chunk_len - 2 - read * (7 + 1);
DBUG_PRINT("info", ("Data address: (%lu,0x%lx) len: %u", DBUG_PRINT("info", ("Data address: (%lu,0x%lx) len: %u",
(ulong) LSN_FILE_NO(buff->chunk0_data_addr), LSN_IN_PARTS(buff->chunk0_data_addr),
(ulong) LSN_OFFSET(buff->chunk0_data_addr),
buff->chunk0_data_len)); buff->chunk0_data_len));
break; break;
} }
...@@ -5612,8 +5560,7 @@ int translog_read_record_header_from_buffer(uchar *page, ...@@ -5612,8 +5560,7 @@ int translog_read_record_header_from_buffer(uchar *page,
buff->short_trid= uint2korr(page + page_offset + 1); buff->short_trid= uint2korr(page + page_offset + 1);
DBUG_PRINT("info", ("Type %u, Short TrID %u, LSN (%lu,0x%lx)", DBUG_PRINT("info", ("Type %u, Short TrID %u, LSN (%lu,0x%lx)",
(uint) buff->type, (uint)buff->short_trid, (uint) buff->type, (uint)buff->short_trid,
(ulong) LSN_FILE_NO(buff->lsn), LSN_IN_PARTS(buff->lsn)));
(ulong) LSN_OFFSET(buff->lsn)));
/* Read required bytes from the header and call hook */ /* Read required bytes from the header and call hook */
switch (log_record_type_descriptor[buff->type].class) { switch (log_record_type_descriptor[buff->type].class) {
case LOGRECTYPE_VARIABLE_LENGTH: case LOGRECTYPE_VARIABLE_LENGTH:
...@@ -5625,9 +5572,7 @@ int translog_read_record_header_from_buffer(uchar *page, ...@@ -5625,9 +5572,7 @@ int translog_read_record_header_from_buffer(uchar *page,
res= translog_fixed_length_header(page, page_offset, buff); res= translog_fixed_length_header(page, page_offset, buff);
break; break;
default: default:
#ifdef ASK_SANJA DBUG_ASSERT(0); /* we read some junk (got no LSN) */
DBUG_ASSERT(0); /* fails on empty log (Sanja knows) */
#endif
res= RECHEADER_READ_ERROR; res= RECHEADER_READ_ERROR;
} }
DBUG_RETURN(res); DBUG_RETURN(res);
...@@ -5660,8 +5605,7 @@ int translog_read_record_header(LSN lsn, TRANSLOG_HEADER_BUFFER *buff) ...@@ -5660,8 +5605,7 @@ int translog_read_record_header(LSN lsn, TRANSLOG_HEADER_BUFFER *buff)
TRANSLOG_ADDRESS addr; TRANSLOG_ADDRESS addr;
TRANSLOG_VALIDATOR_DATA data; TRANSLOG_VALIDATOR_DATA data;
DBUG_ENTER("translog_read_record_header"); DBUG_ENTER("translog_read_record_header");
DBUG_PRINT("enter", ("LSN: (0x%lu,0x%lx)", DBUG_PRINT("enter", ("LSN: (0x%lu,0x%lx)", LSN_IN_PARTS(lsn)));
(ulong) LSN_FILE_NO(lsn), (ulong) LSN_OFFSET(lsn)));
DBUG_ASSERT(LSN_OFFSET(lsn) % TRANSLOG_PAGE_SIZE != 0); DBUG_ASSERT(LSN_OFFSET(lsn) % TRANSLOG_PAGE_SIZE != 0);
buff->lsn= lsn; buff->lsn= lsn;
...@@ -5704,12 +5648,9 @@ int translog_read_record_header_scan(TRANSLOG_SCANNER_DATA *scanner, ...@@ -5704,12 +5648,9 @@ int translog_read_record_header_scan(TRANSLOG_SCANNER_DATA *scanner,
DBUG_ENTER("translog_read_record_header_scan"); DBUG_ENTER("translog_read_record_header_scan");
DBUG_PRINT("enter", ("Scanner: Cur: (%lu,0x%lx) Hrz: (%lu,0x%lx) " DBUG_PRINT("enter", ("Scanner: Cur: (%lu,0x%lx) Hrz: (%lu,0x%lx) "
"Lst: (%lu,0x%lx) Offset: %u(%x) fixed %d", "Lst: (%lu,0x%lx) Offset: %u(%x) fixed %d",
(ulong) LSN_FILE_NO(scanner->page_addr), LSN_IN_PARTS(scanner->page_addr),
(ulong) LSN_OFFSET(scanner->page_addr), LSN_IN_PARTS(scanner->horizon),
(ulong) LSN_FILE_NO(scanner->horizon), LSN_IN_PARTS(scanner->last_file_page),
(ulong) LSN_OFFSET(scanner->horizon),
(ulong) LSN_FILE_NO(scanner->last_file_page),
(ulong) LSN_OFFSET(scanner->last_file_page),
(uint) scanner->page_offset, (uint) scanner->page_offset,
(uint) scanner->page_offset, scanner->fixed_horizon)); (uint) scanner->page_offset, scanner->fixed_horizon));
buff->groups_no= 0; buff->groups_no= 0;
...@@ -5753,12 +5694,9 @@ int translog_read_next_record_header(TRANSLOG_SCANNER_DATA *scanner, ...@@ -5753,12 +5694,9 @@ int translog_read_next_record_header(TRANSLOG_SCANNER_DATA *scanner,
DBUG_PRINT("enter", ("scanner: 0x%lx", (ulong) scanner)); DBUG_PRINT("enter", ("scanner: 0x%lx", (ulong) scanner));
DBUG_PRINT("info", ("Scanner: Cur: (%lu,0x%lx) Hrz: (%lu,0x%lx) " DBUG_PRINT("info", ("Scanner: Cur: (%lu,0x%lx) Hrz: (%lu,0x%lx) "
"Lst: (%lu,0x%lx) Offset: %u(%x) fixed: %d", "Lst: (%lu,0x%lx) Offset: %u(%x) fixed: %d",
(ulong) LSN_FILE_NO(scanner->page_addr), LSN_IN_PARTS(scanner->page_addr),
(ulong) LSN_OFFSET(scanner->page_addr), LSN_IN_PARTS(scanner->horizon),
(ulong) LSN_FILE_NO(scanner->horizon), LSN_IN_PARTS(scanner->last_file_page),
(ulong) LSN_OFFSET(scanner->horizon),
(ulong) LSN_FILE_NO(scanner->last_file_page),
(ulong) LSN_OFFSET(scanner->last_file_page),
(uint) scanner->page_offset, (uint) scanner->page_offset,
(uint) scanner->page_offset, scanner->fixed_horizon)); (uint) scanner->page_offset, scanner->fixed_horizon));
...@@ -5954,12 +5892,9 @@ translog_size_t translog_read_record(LSN lsn, ...@@ -5954,12 +5892,9 @@ translog_size_t translog_read_record(LSN lsn,
"Scanner: Cur: (%lu,0x%lx) Hrz: (%lu,0x%lx) " "Scanner: Cur: (%lu,0x%lx) Hrz: (%lu,0x%lx) "
"Lst: (%lu,0x%lx) Offset: %u(%x) fixed: %d", "Lst: (%lu,0x%lx) Offset: %u(%x) fixed: %d",
(ulong) offset, (ulong) length, (ulong) offset, (ulong) length,
(ulong) LSN_FILE_NO(data->scanner.page_addr), LSN_IN_PARTS(data->scanner.page_addr),
(ulong) LSN_OFFSET(data->scanner.page_addr), LSN_IN_PARTS(data->scanner.horizon),
(ulong) LSN_FILE_NO(data->scanner.horizon), LSN_IN_PARTS(data->scanner.last_file_page),
(ulong) LSN_OFFSET(data->scanner.horizon),
(ulong) LSN_FILE_NO(data->scanner.last_file_page),
(ulong) LSN_OFFSET(data->scanner.last_file_page),
(uint) data->scanner.page_offset, (uint) data->scanner.page_offset,
(uint) data->scanner.page_offset, (uint) data->scanner.page_offset,
data->scanner.fixed_horizon)); data->scanner.fixed_horizon));
...@@ -6039,8 +5974,7 @@ static void translog_force_current_buffer_to_finish() ...@@ -6039,8 +5974,7 @@ static void translog_force_current_buffer_to_finish()
"size: %lu (%lu) Pg: %u left: %u", "size: %lu (%lu) Pg: %u left: %u",
(uint) log_descriptor.bc.buffer_no, (uint) log_descriptor.bc.buffer_no,
(ulong) log_descriptor.bc.buffer, (ulong) log_descriptor.bc.buffer,
(ulong) LSN_FILE_NO(log_descriptor.bc.buffer->offset), LSN_IN_PARTS(log_descriptor.bc.buffer->offset),
(ulong) LSN_OFFSET(log_descriptor.bc.buffer->offset),
(ulong) LSN_FILE_NO(log_descriptor.horizon), (ulong) LSN_FILE_NO(log_descriptor.horizon),
(ulong) (LSN_OFFSET(log_descriptor.horizon) - (ulong) (LSN_OFFSET(log_descriptor.horizon) -
log_descriptor.bc.current_page_fill), log_descriptor.bc.current_page_fill),
...@@ -6171,9 +6105,7 @@ my_bool translog_flush(LSN lsn) ...@@ -6171,9 +6105,7 @@ my_bool translog_flush(LSN lsn)
uint i; uint i;
my_bool full_circle= 0; my_bool full_circle= 0;
DBUG_ENTER("translog_flush"); DBUG_ENTER("translog_flush");
DBUG_PRINT("enter", ("Flush up to LSN: (%lu,0x%lx)", DBUG_PRINT("enter", ("Flush up to LSN: (%lu,0x%lx)", LSN_IN_PARTS(lsn)));
(ulong) LSN_FILE_NO(lsn),
(ulong) LSN_OFFSET(lsn)));
translog_lock(); translog_lock();
old_flushed= log_descriptor.flushed; old_flushed= log_descriptor.flushed;
...@@ -6188,8 +6120,7 @@ my_bool translog_flush(LSN lsn) ...@@ -6188,8 +6120,7 @@ my_bool translog_flush(LSN lsn)
if (cmp_translog_addr(log_descriptor.flushed, lsn) >= 0) if (cmp_translog_addr(log_descriptor.flushed, lsn) >= 0)
{ {
DBUG_PRINT("info", ("already flushed: (%lu,0x%lx)", DBUG_PRINT("info", ("already flushed: (%lu,0x%lx)",
(ulong) LSN_FILE_NO(log_descriptor.flushed), LSN_IN_PARTS(log_descriptor.flushed)));
(ulong) LSN_OFFSET(log_descriptor.flushed)));
translog_unlock(); translog_unlock();
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -6653,7 +6584,7 @@ static uint32 translog_first_file(TRANSLOG_ADDRESS horizon, int is_protected) ...@@ -6653,7 +6584,7 @@ static uint32 translog_first_file(TRANSLOG_ADDRESS horizon, int is_protected)
@brief returns the LSN of the first record starting in this log @brief returns the LSN of the first record starting in this log
@retval LSN_ERROR Error @retval LSN_ERROR Error
@retval LSN_IMPOSSIBLE no log @retval LSN_IMPOSSIBLE no log or the log is empty
@retval # LSN of the first record @retval # LSN of the first record
*/ */
...@@ -6667,8 +6598,7 @@ LSN translog_first_lsn_in_log() ...@@ -6667,8 +6598,7 @@ LSN translog_first_lsn_in_log()
uchar *page; uchar *page;
TRANSLOG_SCANNER_DATA scanner; TRANSLOG_SCANNER_DATA scanner;
DBUG_ENTER("translog_first_lsn_in_log"); DBUG_ENTER("translog_first_lsn_in_log");
DBUG_PRINT("info", ("Horizon: (%lu,0x%lx)", DBUG_PRINT("info", ("Horizon: (%lu,0x%lx)", LSN_IN_PARTS(addr)));
(ulong) LSN_FILE_NO(addr), (ulong) LSN_OFFSET(addr)));
if (!(file= translog_first_file(horizon, 0))) if (!(file= translog_first_file(horizon, 0)))
{ {
...@@ -6719,8 +6649,7 @@ LSN translog_first_theoretical_lsn() ...@@ -6719,8 +6649,7 @@ LSN translog_first_theoretical_lsn()
uchar buffer[TRANSLOG_PAGE_SIZE], *page; uchar buffer[TRANSLOG_PAGE_SIZE], *page;
TRANSLOG_VALIDATOR_DATA data; TRANSLOG_VALIDATOR_DATA data;
DBUG_ENTER("translog_first_theoretical_lsn"); DBUG_ENTER("translog_first_theoretical_lsn");
DBUG_PRINT("info", ("Horizon: (%lu,0x%lx)", DBUG_PRINT("info", ("Horizon: (%lu,0x%lx)", LSN_IN_PARTS(addr)));
(ulong) LSN_FILE_NO(addr), (ulong) LSN_OFFSET(addr)));
if (!translog_is_file(1)) if (!translog_is_file(1))
DBUG_RETURN(LSN_IMPOSSIBLE); DBUG_RETURN(LSN_IMPOSSIBLE);
...@@ -6756,9 +6685,7 @@ my_bool translog_purge(TRANSLOG_ADDRESS low) ...@@ -6756,9 +6685,7 @@ my_bool translog_purge(TRANSLOG_ADDRESS low)
TRANSLOG_ADDRESS horizon= translog_get_horizon(); TRANSLOG_ADDRESS horizon= translog_get_horizon();
int rc= 0; int rc= 0;
DBUG_ENTER("translog_purge"); DBUG_ENTER("translog_purge");
DBUG_PRINT("enter", ("low: (%lu,0x%lx)", DBUG_PRINT("enter", ("low: (%lu,0x%lx)", LSN_IN_PARTS(low)));
(ulong)LSN_FILE_NO(low),
(ulong)LSN_OFFSET(low)));
pthread_mutex_lock(&log_descriptor.purger_lock); pthread_mutex_lock(&log_descriptor.purger_lock);
if (LSN_FILE_NO(log_descriptor.last_lsn_checked) < last_need_file) if (LSN_FILE_NO(log_descriptor.last_lsn_checked) < last_need_file)
......
...@@ -41,6 +41,9 @@ typedef TRANSLOG_ADDRESS LSN; ...@@ -41,6 +41,9 @@ typedef TRANSLOG_ADDRESS LSN;
/* Gets raw file number part of a LSN/log address */ /* Gets raw file number part of a LSN/log address */
#define LSN_FILE_NO_PART(L) ((L) & ((int64)0xFFFFFF00000000LL)) #define LSN_FILE_NO_PART(L) ((L) & ((int64)0xFFFFFF00000000LL))
/* Parts of LSN for printing */
#define LSN_IN_PARTS(L) (ulong)LSN_FILE_NO(L),(ulong)LSN_OFFSET(L)
/* Gets record offset of a LSN/log address */ /* Gets record offset of a LSN/log address */
#define LSN_OFFSET(L) ((L) & 0xFFFFFFFFL) #define LSN_OFFSET(L) ((L) & 0xFFFFFFFFL)
......
...@@ -2469,8 +2469,7 @@ static void check_and_set_lsn(PAGECACHE *pagecache, ...@@ -2469,8 +2469,7 @@ static void check_and_set_lsn(PAGECACHE *pagecache,
DBUG_ASSERT(block->type == PAGECACHE_LSN_PAGE); DBUG_ASSERT(block->type == PAGECACHE_LSN_PAGE);
old= lsn_korr(block->buffer + PAGE_LSN_OFFSET); old= lsn_korr(block->buffer + PAGE_LSN_OFFSET);
DBUG_PRINT("info", ("old lsn: (%lu, 0x%lx) new lsn: (%lu, 0x%lx)", DBUG_PRINT("info", ("old lsn: (%lu, 0x%lx) new lsn: (%lu, 0x%lx)",
(ulong)LSN_FILE_NO(old), (ulong)LSN_OFFSET(old), LSN_IN_PARTS(old), LSN_IN_PARTS(lsn)));
(ulong)LSN_FILE_NO(lsn), (ulong)LSN_OFFSET(lsn)));
if (cmp_translog_addr(lsn, old) > 0) if (cmp_translog_addr(lsn, old) > 0)
{ {
......
...@@ -119,7 +119,6 @@ static void enlarge_buffer(const TRANSLOG_HEADER_BUFFER *rec) ...@@ -119,7 +119,6 @@ static void enlarge_buffer(const TRANSLOG_HEADER_BUFFER *rec)
} }
#define ALERT_USER() DBUG_ASSERT(0) #define ALERT_USER() DBUG_ASSERT(0)
#define LSN_IN_HEX(L) (ulong)LSN_FILE_NO(L),(ulong)LSN_OFFSET(L)
/** /**
...@@ -270,7 +269,7 @@ static void display_record_position(const LOG_DESC *log_desc, ...@@ -270,7 +269,7 @@ static void display_record_position(const LOG_DESC *log_desc,
form a group, so we indent below the group's end record form a group, so we indent below the group's end record
*/ */
fprintf(tracef, "%sRec#%u LSN (%lu,0x%lx) short_trid %u %s(num_type:%u) len %lu\n", fprintf(tracef, "%sRec#%u LSN (%lu,0x%lx) short_trid %u %s(num_type:%u) len %lu\n",
number ? "" : " ", number, LSN_IN_HEX(rec->lsn), number ? "" : " ", number, LSN_IN_PARTS(rec->lsn),
rec->short_trid, log_desc->name, rec->type, rec->short_trid, log_desc->name, rec->type,
(ulong)rec->record_length); (ulong)rec->record_length);
} }
...@@ -301,7 +300,7 @@ prototype_redo_exec_hook(LONG_TRANSACTION_ID) ...@@ -301,7 +300,7 @@ prototype_redo_exec_hook(LONG_TRANSACTION_ID)
if (gslsn != LSN_IMPOSSIBLE) if (gslsn != LSN_IMPOSSIBLE)
{ {
fprintf(tracef, "Group at LSN (%lu,0x%lx) short_trid %u aborted\n", fprintf(tracef, "Group at LSN (%lu,0x%lx) short_trid %u aborted\n",
LSN_IN_HEX(gslsn), sid); LSN_IN_PARTS(gslsn), sid);
all_active_trans[sid].group_start_lsn= LSN_IMPOSSIBLE; all_active_trans[sid].group_start_lsn= LSN_IMPOSSIBLE;
} }
if (long_trid != 0) if (long_trid != 0)
...@@ -314,7 +313,7 @@ prototype_redo_exec_hook(LONG_TRANSACTION_ID) ...@@ -314,7 +313,7 @@ prototype_redo_exec_hook(LONG_TRANSACTION_ID)
fprintf(tracef, "Found an old transaction long_trid %s short_trid %u" fprintf(tracef, "Found an old transaction long_trid %s short_trid %u"
" with same short id as this new transaction, and has neither" " with same short id as this new transaction, and has neither"
" committed nor rollback (undo_lsn: (%lu,0x%lx))\n", llbuf, " committed nor rollback (undo_lsn: (%lu,0x%lx))\n", llbuf,
sid, LSN_IN_HEX(ulsn)); sid, LSN_IN_PARTS(ulsn));
goto err; goto err;
} }
} }
...@@ -394,7 +393,7 @@ prototype_redo_exec_hook(REDO_CREATE_TABLE) ...@@ -394,7 +393,7 @@ prototype_redo_exec_hook(REDO_CREATE_TABLE)
{ {
fprintf(tracef, ", has create_rename_lsn (%lu,0x%lx) more recent than" fprintf(tracef, ", has create_rename_lsn (%lu,0x%lx) more recent than"
" record, ignoring creation", " record, ignoring creation",
LSN_IN_HEX(share->state.create_rename_lsn)); LSN_IN_PARTS(share->state.create_rename_lsn));
error= 0; error= 0;
goto end; goto end;
} }
...@@ -515,7 +514,7 @@ prototype_redo_exec_hook(REDO_RENAME_TABLE) ...@@ -515,7 +514,7 @@ prototype_redo_exec_hook(REDO_RENAME_TABLE)
{ {
fprintf(tracef, ", has create_rename_lsn (%lu,0x%lx) more recent than" fprintf(tracef, ", has create_rename_lsn (%lu,0x%lx) more recent than"
" record, ignoring renaming", " record, ignoring renaming",
LSN_IN_HEX(share->state.create_rename_lsn)); LSN_IN_PARTS(share->state.create_rename_lsn));
error= 0; error= 0;
goto end; goto end;
} }
...@@ -634,7 +633,7 @@ prototype_redo_exec_hook(REDO_DROP_TABLE) ...@@ -634,7 +633,7 @@ prototype_redo_exec_hook(REDO_DROP_TABLE)
{ {
fprintf(tracef, ", has create_rename_lsn (%lu,0x%lx) more recent than" fprintf(tracef, ", has create_rename_lsn (%lu,0x%lx) more recent than"
" record, ignoring removal", " record, ignoring removal",
LSN_IN_HEX(share->state.create_rename_lsn)); LSN_IN_PARTS(share->state.create_rename_lsn));
error= 0; error= 0;
goto end; goto end;
} }
...@@ -760,8 +759,8 @@ static int new_table(uint16 sid, const char *name, ...@@ -760,8 +759,8 @@ static int new_table(uint16 sid, const char *name,
{ {
fprintf(tracef, ", has create_rename_lsn (%lu,0x%lx) more recent than" fprintf(tracef, ", has create_rename_lsn (%lu,0x%lx) more recent than"
" LOGREC_FILE_ID's LSN (%lu,0x%lx), ignoring open request", " LOGREC_FILE_ID's LSN (%lu,0x%lx), ignoring open request",
LSN_IN_HEX(share->state.create_rename_lsn), LSN_IN_PARTS(share->state.create_rename_lsn),
LSN_IN_HEX(lsn_of_file_id)); LSN_IN_PARTS(lsn_of_file_id));
error= -1; error= -1;
goto end; goto end;
} }
...@@ -1063,7 +1062,7 @@ prototype_redo_exec_hook(COMMIT) ...@@ -1063,7 +1062,7 @@ prototype_redo_exec_hook(COMMIT)
table, so an unfinished group staid in the log. table, so an unfinished group staid in the log.
*/ */
fprintf(tracef, ", with group at LSN (%lu,0x%lx) short_trid %u aborted\n", fprintf(tracef, ", with group at LSN (%lu,0x%lx) short_trid %u aborted\n",
(ulong) LSN_FILE_NO(gslsn), (ulong) LSN_OFFSET(gslsn), sid); LSN_IN_PARTS(gslsn), sid);
all_active_trans[sid].group_start_lsn= LSN_IMPOSSIBLE; all_active_trans[sid].group_start_lsn= LSN_IMPOSSIBLE;
} }
else else
...@@ -1093,7 +1092,7 @@ prototype_redo_exec_hook(CLR_END) ...@@ -1093,7 +1092,7 @@ prototype_redo_exec_hook(CLR_END)
set_undo_lsn_for_active_trans(rec->short_trid, previous_undo_lsn); set_undo_lsn_for_active_trans(rec->short_trid, previous_undo_lsn);
fprintf(tracef, " CLR_END was about %s, undo_lsn now LSN (%lu,0x%lx)\n", fprintf(tracef, " CLR_END was about %s, undo_lsn now LSN (%lu,0x%lx)\n",
log_desc->name, LSN_IN_HEX(previous_undo_lsn)); log_desc->name, LSN_IN_PARTS(previous_undo_lsn));
if (cmp_translog_addr(rec->lsn, info->s->state.is_of_horizon) > 0) if (cmp_translog_addr(rec->lsn, info->s->state.is_of_horizon) > 0)
{ {
fprintf(tracef, " state older than record, updating rows' count\n"); fprintf(tracef, " state older than record, updating rows' count\n");
...@@ -1144,7 +1143,7 @@ prototype_undo_exec_hook(UNDO_ROW_INSERT) ...@@ -1144,7 +1143,7 @@ prototype_undo_exec_hook(UNDO_ROW_INSERT)
/* trn->undo_lsn is updated in an inwrite_hook when writing the CLR_END */ /* trn->undo_lsn is updated in an inwrite_hook when writing the CLR_END */
fprintf(tracef, " rows' count %lu\n", (ulong)info->s->state.state.records); fprintf(tracef, " rows' count %lu\n", (ulong)info->s->state.state.records);
fprintf(tracef, " undo_lsn now LSN (%lu,0x%lx)\n", fprintf(tracef, " undo_lsn now LSN (%lu,0x%lx)\n",
LSN_IN_HEX(previous_undo_lsn)); LSN_IN_PARTS(previous_undo_lsn));
return error; return error;
} }
...@@ -1186,7 +1185,7 @@ prototype_undo_exec_hook(UNDO_ROW_DELETE) ...@@ -1186,7 +1185,7 @@ prototype_undo_exec_hook(UNDO_ROW_DELETE)
info->trn= 0; info->trn= 0;
fprintf(tracef, " rows' count %lu\n", (ulong)info->s->state.state.records); fprintf(tracef, " rows' count %lu\n", (ulong)info->s->state.state.records);
fprintf(tracef, " undo_lsn now LSN (%lu,0x%lx)\n", fprintf(tracef, " undo_lsn now LSN (%lu,0x%lx)\n",
LSN_IN_HEX(previous_undo_lsn)); LSN_IN_PARTS(previous_undo_lsn));
return error; return error;
} }
...@@ -1221,7 +1220,7 @@ prototype_undo_exec_hook(UNDO_ROW_UPDATE) ...@@ -1221,7 +1220,7 @@ prototype_undo_exec_hook(UNDO_ROW_UPDATE)
(LSN_STORE_SIZE + FILEID_STORE_SIZE)); (LSN_STORE_SIZE + FILEID_STORE_SIZE));
info->trn= 0; info->trn= 0;
fprintf(tracef, " undo_lsn now LSN (%lu,0x%lx)\n", fprintf(tracef, " undo_lsn now LSN (%lu,0x%lx)\n",
LSN_IN_HEX(previous_undo_lsn)); LSN_IN_PARTS(previous_undo_lsn));
return error; return error;
} }
...@@ -1261,13 +1260,19 @@ static int run_redo_phase(LSN lsn, my_bool apply) ...@@ -1261,13 +1260,19 @@ static int run_redo_phase(LSN lsn, my_bool apply)
TRANSLOG_HEADER_BUFFER rec; TRANSLOG_HEADER_BUFFER rec;
if (unlikely(lsn == translog_get_horizon()))
{
fprintf(tracef, "Cannot find a first record, empty log, nothing to do.\n");
return 0;
}
int len= translog_read_record_header(lsn, &rec); int len= translog_read_record_header(lsn, &rec);
/** @todo EOF should be detected */ /** @todo EOF should be detected */
if (len == RECHEADER_READ_ERROR) if (len == RECHEADER_READ_ERROR)
{ {
fprintf(tracef, "Cannot find a first record, empty log, nothing to do\n"); fprintf(tracef, "Failed to read header of the first record.\n");
return 0; return 1;
} }
struct st_translog_scanner_data scanner; struct st_translog_scanner_data scanner;
if (translog_init_scanner(lsn, 1, &scanner)) if (translog_init_scanner(lsn, 1, &scanner))
...@@ -1416,7 +1421,7 @@ static uint end_of_redo_phase(my_bool prepare_for_undo_phase) ...@@ -1416,7 +1421,7 @@ static uint end_of_redo_phase(my_bool prepare_for_undo_phase)
if (gslsn != LSN_IMPOSSIBLE) if (gslsn != LSN_IMPOSSIBLE)
{ {
fprintf(tracef, "Group at LSN (%lu,0x%lx) short_trid %u aborted\n", fprintf(tracef, "Group at LSN (%lu,0x%lx) short_trid %u aborted\n",
(ulong) LSN_FILE_NO(gslsn), (ulong) LSN_OFFSET(gslsn), sid); LSN_IN_PARTS(gslsn), sid);
ALERT_USER(); ALERT_USER();
} }
if (all_active_trans[sid].undo_lsn != LSN_IMPOSSIBLE) if (all_active_trans[sid].undo_lsn != LSN_IMPOSSIBLE)
...@@ -1590,7 +1595,7 @@ static MARIA_HA *get_MARIA_HA_from_REDO_record(const ...@@ -1590,7 +1595,7 @@ static MARIA_HA *get_MARIA_HA_from_REDO_record(const
DBUG_ASSERT(cmp_translog_addr(rec->lsn, checkpoint_start) < 0); DBUG_ASSERT(cmp_translog_addr(rec->lsn, checkpoint_start) < 0);
fprintf(tracef, ", table's LOGREC_FILE_ID has LSN (%lu,0x%lx) more recent" fprintf(tracef, ", table's LOGREC_FILE_ID has LSN (%lu,0x%lx) more recent"
" than record, skipping record", " than record, skipping record",
LSN_IN_HEX(info->s->lsn_of_file_id)); LSN_IN_PARTS(info->s->lsn_of_file_id));
return NULL; return NULL;
} }
/* detect if an open instance of a dropped table (internal bug) */ /* detect if an open instance of a dropped table (internal bug) */
...@@ -1643,7 +1648,7 @@ static MARIA_HA *get_MARIA_HA_from_UNDO_record(const ...@@ -1643,7 +1648,7 @@ static MARIA_HA *get_MARIA_HA_from_UNDO_record(const
{ {
fprintf(tracef, ", table's LOGREC_FILE_ID has LSN (%lu,0x%lx) more recent" fprintf(tracef, ", table's LOGREC_FILE_ID has LSN (%lu,0x%lx) more recent"
" than record, skipping record", " than record, skipping record",
LSN_IN_HEX(info->s->lsn_of_file_id)); LSN_IN_PARTS(info->s->lsn_of_file_id));
return NULL; return NULL;
} }
DBUG_ASSERT(info->s->last_version != 0); DBUG_ASSERT(info->s->last_version != 0);
...@@ -1670,7 +1675,7 @@ static LSN parse_checkpoint_record(LSN lsn) ...@@ -1670,7 +1675,7 @@ static LSN parse_checkpoint_record(LSN lsn)
TRANSLOG_HEADER_BUFFER rec; TRANSLOG_HEADER_BUFFER rec;
fprintf(tracef, "Loading data from checkpoint record at LSN (%lu,0x%lx)\n", fprintf(tracef, "Loading data from checkpoint record at LSN (%lu,0x%lx)\n",
LSN_IN_HEX(lsn)); LSN_IN_PARTS(lsn));
int len= translog_read_record_header(lsn, &rec); int len= translog_read_record_header(lsn, &rec);
if (len == RECHEADER_READ_ERROR) if (len == RECHEADER_READ_ERROR)
......
...@@ -86,11 +86,18 @@ int main(int argc, char **argv) ...@@ -86,11 +86,18 @@ int main(int argc, char **argv)
printf("You are using --only-display, NOTHING will be written to disk\n"); printf("You are using --only-display, NOTHING will be written to disk\n");
/* LSN could be also --start-from-lsn=# */ /* LSN could be also --start-from-lsn=# */
lsn= translog_first_theoretical_lsn(); lsn= translog_first_lsn_in_log();
/* if (lsn == LSN_ERROR)
@todo process LSN_IMPOSSIBLE and LSN_ERROR values of {
translog_first_theoretical_lsn() fprintf(stderr, "Opening transaction log failed\n");
*/ goto end;
}
if (lsn == LSN_IMPOSSIBLE)
{
fprintf(stdout, "The transaction log is empty\n");
}
fprintf(stdout, "The transaction log starts from lsn (%lu,0x%lx)\n",
LSN_IN_PARTS(lsn));
fprintf(stdout, "TRACE of the last maria_read_log\n"); fprintf(stdout, "TRACE of the last maria_read_log\n");
if (maria_apply_log(lsn, opt_display_and_apply, stdout, if (maria_apply_log(lsn, opt_display_and_apply, stdout,
......
...@@ -88,8 +88,7 @@ void read_ok(TRANSLOG_HEADER_BUFFER *rec) ...@@ -88,8 +88,7 @@ void read_ok(TRANSLOG_HEADER_BUFFER *rec)
{ {
char buff[80]; char buff[80];
snprintf(buff, sizeof(buff), "read record type: %u LSN: (%lu,0x%lx)", snprintf(buff, sizeof(buff), "read record type: %u LSN: (%lu,0x%lx)",
rec->type, (ulong) LSN_FILE_NO(rec->lsn), rec->type, LSN_IN_PARTS(rec->lsn));
(ulong) LSN_OFFSET(rec->lsn));
ok(1, buff); ok(1, buff);
} }
...@@ -358,7 +357,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -358,7 +357,7 @@ int main(int argc __attribute__((unused)), char *argv[])
(uint) rec.type, (uint) rec.short_trid, (uint) rec.record_length, (uint) rec.type, (uint) rec.short_trid, (uint) rec.record_length,
(uint) uint4korr(rec.header), (uint) rec.header[4], (uint) uint4korr(rec.header), (uint) rec.header[4],
(uint) rec.header[5], (uint) rec.header[5],
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn)); LSN_IN_PARTS(rec.lsn));
goto err; goto err;
} }
read_ok(&rec); read_ok(&rec);
...@@ -403,9 +402,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -403,9 +402,8 @@ int main(int argc __attribute__((unused)), char *argv[])
"lsn(%lu,0x%lx)\n", "lsn(%lu,0x%lx)\n",
i, (uint) rec.type, (uint) rec.short_trid, i, (uint) rec.type, (uint) rec.short_trid,
(uint) rec.record_length, (uint) rec.record_length,
(ulong) LSN_FILE_NO(ref), (ulong) LSN_OFFSET(ref), LSN_IN_PARTS(ref), LSN_IN_PARTS(lsn),
(ulong) LSN_FILE_NO(lsn), (ulong) LSN_OFFSET(lsn), LSN_IN_PARTS(rec.lsn));
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn));
goto err; goto err;
} }
} }
...@@ -436,14 +434,13 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -436,14 +434,13 @@ int main(int argc __attribute__((unused)), char *argv[])
"lsn(%lu,0x%lx)\n", "lsn(%lu,0x%lx)\n",
i, (uint) rec.type, (uint) rec.short_trid, i, (uint) rec.type, (uint) rec.short_trid,
(uint) rec.record_length, (uint) rec.record_length,
(ulong) LSN_FILE_NO(ref1), (ulong) LSN_OFFSET(ref1), LSN_IN_PARTS(ref1), LSN_IN_PARTS(ref2),
(ulong) LSN_FILE_NO(ref2), (ulong) LSN_OFFSET(ref2),
(uint) rec.header[14], (uint) rec.header[15], (uint) rec.header[14], (uint) rec.header[15],
(uint) rec.header[16], (uint) rec.header[17], (uint) rec.header[16], (uint) rec.header[17],
(uint) rec.header[18], (uint) rec.header[19], (uint) rec.header[18], (uint) rec.header[19],
(uint) rec.header[20], (uint) rec.header[21], (uint) rec.header[20], (uint) rec.header[21],
(uint) rec.header[22], (uint) rec.header[22],
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn)); LSN_IN_PARTS(rec.lsn));
goto err; goto err;
} }
} }
...@@ -488,8 +485,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -488,8 +485,7 @@ int main(int argc __attribute__((unused)), char *argv[])
rec.record_length != rec_len + LSN_STORE_SIZE, rec.record_length != rec_len + LSN_STORE_SIZE,
(uint) len, (uint) len,
len != 12, len != 12,
(ulong) LSN_FILE_NO(ref), (ulong) LSN_OFFSET(ref), LSN_IN_PARTS(ref), LSN_IN_PARTS(rec.lsn),
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn),
(len != 12 || ref != lsn), (len != 12 || ref != lsn),
check_content(rec.header + LSN_STORE_SIZE, check_content(rec.header + LSN_STORE_SIZE,
len - LSN_STORE_SIZE)); len - LSN_STORE_SIZE));
...@@ -500,7 +496,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -500,7 +496,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, fprintf(stderr,
"Incorrect LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE " "Incorrect LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE "
"in whole rec read lsn(%lu,0x%lx)\n", "in whole rec read lsn(%lu,0x%lx)\n",
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn)); LSN_IN_PARTS(rec.lsn));
goto err; goto err;
} }
} }
...@@ -527,10 +523,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -527,10 +523,8 @@ int main(int argc __attribute__((unused)), char *argv[])
"lsn(%lu,0x%lx)\n", "lsn(%lu,0x%lx)\n",
i, (uint) rec.type, (uint) rec.short_trid, i, (uint) rec.type, (uint) rec.short_trid,
(ulong) rec.record_length, (ulong) rec_len, (ulong) rec.record_length, (ulong) rec_len,
len, len, LSN_IN_PARTS(ref1), LSN_IN_PARTS(ref2),
(ulong) LSN_FILE_NO(ref1), (ulong) LSN_OFFSET(ref1), LSN_IN_PARTS(rec.lsn));
(ulong) LSN_FILE_NO(ref2), (ulong) LSN_OFFSET(ref2),
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn));
goto err; goto err;
} }
if (read_and_check_content(&rec, long_buffer, LSN_STORE_SIZE * 2)) if (read_and_check_content(&rec, long_buffer, LSN_STORE_SIZE * 2))
...@@ -538,7 +532,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -538,7 +532,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, fprintf(stderr,
"Incorrect LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE " "Incorrect LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE "
"in whole rec read lsn(%lu,0x%lx)\n", "in whole rec read lsn(%lu,0x%lx)\n",
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn)); LSN_IN_PARTS(rec.lsn));
goto err; goto err;
} }
} }
...@@ -571,7 +565,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -571,7 +565,7 @@ int main(int argc __attribute__((unused)), char *argv[])
(uint) rec.record_length, (uint) rec.record_length,
(uint) uint4korr(rec.header), (uint) rec.header[4], (uint) uint4korr(rec.header), (uint) rec.header[4],
(uint) rec.header[5], (uint) rec.header[5],
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn)); LSN_IN_PARTS(rec.lsn));
goto err; goto err;
} }
lsn= rec.lsn; lsn= rec.lsn;
...@@ -592,8 +586,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -592,8 +586,7 @@ int main(int argc __attribute__((unused)), char *argv[])
"lsn(%lu,0x%lx)\n", "lsn(%lu,0x%lx)\n",
i, (uint) rec.type, (uint) rec.short_trid, i, (uint) rec.type, (uint) rec.short_trid,
(ulong) rec.record_length, (ulong) rec_len, (ulong) rec.record_length, (ulong) rec_len,
len, len, LSN_IN_PARTS(rec.lsn));
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn));
goto err; goto err;
} }
if (read_and_check_content(&rec, long_buffer, 0)) if (read_and_check_content(&rec, long_buffer, 0))
...@@ -601,7 +594,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -601,7 +594,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, fprintf(stderr,
"Incorrect LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE " "Incorrect LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE "
"in whole rec read lsn(%lu,0x%lx)\n", "in whole rec read lsn(%lu,0x%lx)\n",
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn)); LSN_IN_PARTS(rec.lsn));
goto err; goto err;
} }
read_ok(&rec); read_ok(&rec);
......
...@@ -92,8 +92,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -92,8 +92,7 @@ int main(int argc __attribute__((unused)), char *argv[])
if (first_lsn != LSN_IMPOSSIBLE) if (first_lsn != LSN_IMPOSSIBLE)
{ {
fprintf(stderr, "Incorrect first lsn response (%lu,0x%lx).", fprintf(stderr, "Incorrect first lsn response (%lu,0x%lx).",
(ulong) LSN_FILE_NO(first_lsn), LSN_IN_PARTS(first_lsn));
(ulong) LSN_OFFSET(first_lsn));
translog_destroy(); translog_destroy();
exit(1); exit(1);
} }
...@@ -132,10 +131,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -132,10 +131,7 @@ int main(int argc __attribute__((unused)), char *argv[])
{ {
fprintf(stderr, "Incorrect first lsn: (%lu,0x%lx) " fprintf(stderr, "Incorrect first lsn: (%lu,0x%lx) "
" theoretical first: (%lu,0x%lx)\n", " theoretical first: (%lu,0x%lx)\n",
(ulong) LSN_FILE_NO(first_lsn), LSN_IN_PARTS(first_lsn), LSN_IN_PARTS(theor_lsn));
(ulong) LSN_OFFSET(first_lsn),
(ulong) LSN_FILE_NO(theor_lsn),
(ulong) LSN_OFFSET(theor_lsn));
translog_destroy(); translog_destroy();
exit(1); exit(1);
} }
......
...@@ -79,8 +79,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -79,8 +79,7 @@ int main(int argc __attribute__((unused)), char *argv[])
if (max_lsn != LSN_IMPOSSIBLE) if (max_lsn != LSN_IMPOSSIBLE)
{ {
fprintf(stderr, "Incorrect first lsn response (%lu,0x%lx).", fprintf(stderr, "Incorrect first lsn response (%lu,0x%lx).",
(ulong) LSN_FILE_NO(max_lsn), LSN_IN_PARTS(max_lsn));
(ulong) LSN_OFFSET(max_lsn));
translog_destroy(); translog_destroy();
exit(1); exit(1);
} }
...@@ -125,10 +124,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -125,10 +124,7 @@ int main(int argc __attribute__((unused)), char *argv[])
{ {
fprintf(stderr, "Incorrect max lsn: (%lu,0x%lx) " fprintf(stderr, "Incorrect max lsn: (%lu,0x%lx) "
" last lsn on first file: (%lu,0x%lx)\n", " last lsn on first file: (%lu,0x%lx)\n",
(ulong) LSN_FILE_NO(max_lsn), LSN_IN_PARTS(max_lsn), LSN_IN_PARTS(last_lsn));
(ulong) LSN_OFFSET(max_lsn),
(ulong) LSN_FILE_NO(last_lsn),
(ulong) LSN_OFFSET(last_lsn));
translog_destroy(); translog_destroy();
exit(1); exit(1);
} }
......
...@@ -371,7 +371,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -371,7 +371,7 @@ int main(int argc __attribute__((unused)), char *argv[])
(uint) rec.type, (uint) rec.short_trid, (uint) rec.record_length, (uint) rec.type, (uint) rec.short_trid, (uint) rec.record_length,
(uint)uint4korr(rec.header), (uint) rec.header[4], (uint)uint4korr(rec.header), (uint) rec.header[4],
(uint) rec.header[5], (uint) rec.header[5],
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn)); LSN_IN_PARTS(rec.lsn));
translog_free_record_header(&rec); translog_free_record_header(&rec);
goto err; goto err;
} }
...@@ -418,8 +418,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -418,8 +418,7 @@ int main(int argc __attribute__((unused)), char *argv[])
"type %u, strid %u, len %u, ref(%lu,0x%lx), lsn(%lu,0x%lx)\n", "type %u, strid %u, len %u, ref(%lu,0x%lx), lsn(%lu,0x%lx)\n",
i, (uint) rec.type, (uint) rec.short_trid, i, (uint) rec.type, (uint) rec.short_trid,
(uint) rec.record_length, (uint) rec.record_length,
(ulong) LSN_FILE_NO(ref), (ulong) LSN_OFFSET(ref), LSN_IN_PARTS(ref), LSN_IN_PARTS(rec.lsn));
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn));
translog_free_record_header(&rec); translog_free_record_header(&rec);
goto err; goto err;
} }
...@@ -451,14 +450,13 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -451,14 +450,13 @@ int main(int argc __attribute__((unused)), char *argv[])
"lsn(%lu,0x%lx)\n", "lsn(%lu,0x%lx)\n",
i, (uint) rec.type, (uint) rec.short_trid, i, (uint) rec.type, (uint) rec.short_trid,
(uint) rec.record_length, (uint) rec.record_length,
(ulong) LSN_FILE_NO(ref1), (ulong) LSN_OFFSET(ref1), LSN_IN_PARTS(ref1), LSN_IN_PARTS(ref2),
(ulong) LSN_FILE_NO(ref2), (ulong) LSN_OFFSET(ref2),
(uint) rec.header[14], (uint) rec.header[15], (uint) rec.header[14], (uint) rec.header[15],
(uint) rec.header[16], (uint) rec.header[17], (uint) rec.header[16], (uint) rec.header[17],
(uint) rec.header[18], (uint) rec.header[19], (uint) rec.header[18], (uint) rec.header[19],
(uint) rec.header[20], (uint) rec.header[21], (uint) rec.header[20], (uint) rec.header[21],
(uint) rec.header[22], (uint) rec.header[22],
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn)); LSN_IN_PARTS(rec.lsn));
translog_free_record_header(&rec); translog_free_record_header(&rec);
goto err; goto err;
} }
...@@ -503,8 +501,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -503,8 +501,7 @@ int main(int argc __attribute__((unused)), char *argv[])
rec.record_length != rec_len + LSN_STORE_SIZE, rec.record_length != rec_len + LSN_STORE_SIZE,
len, len,
len != 12, len != 12,
(ulong) LSN_FILE_NO(ref), (ulong) LSN_OFFSET(ref), LSN_IN_PARTS(ref), LSN_IN_PARTS(rec.lsn),
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn),
(ref != lsn), (ref != lsn),
check_content(rec.header + LSN_STORE_SIZE, check_content(rec.header + LSN_STORE_SIZE,
len - LSN_STORE_SIZE)); len - LSN_STORE_SIZE));
...@@ -516,7 +513,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -516,7 +513,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, fprintf(stderr,
"Incorrect LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE " "Incorrect LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE "
"in whole rec read lsn(%lu,0x%lx)\n", "in whole rec read lsn(%lu,0x%lx)\n",
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn)); LSN_IN_PARTS(rec.lsn));
translog_free_record_header(&rec); translog_free_record_header(&rec);
goto err; goto err;
} }
...@@ -544,9 +541,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -544,9 +541,8 @@ int main(int argc __attribute__((unused)), char *argv[])
i, (uint) rec.type, (uint) rec.short_trid, i, (uint) rec.type, (uint) rec.short_trid,
(ulong) rec.record_length, (ulong) rec_len, (ulong) rec.record_length, (ulong) rec_len,
len, len,
(ulong) LSN_FILE_NO(ref1), (ulong) LSN_OFFSET(ref1), LSN_IN_PARTS(ref1), LSN_IN_PARTS(ref2),
(ulong) LSN_FILE_NO(ref2), (ulong) LSN_OFFSET(ref2), LSN_IN_PARTS(rec.lsn));
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn));
translog_free_record_header(&rec); translog_free_record_header(&rec);
goto err; goto err;
} }
...@@ -555,7 +551,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -555,7 +551,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, fprintf(stderr,
"Incorrect LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE " "Incorrect LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE "
"in whole rec read lsn(%lu,0x%lx)\n", "in whole rec read lsn(%lu,0x%lx)\n",
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn)); LSN_IN_PARTS(rec.lsn));
translog_free_record_header(&rec); translog_free_record_header(&rec);
goto err; goto err;
} }
...@@ -591,7 +587,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -591,7 +587,7 @@ int main(int argc __attribute__((unused)), char *argv[])
(uint) rec.record_length, (uint) rec.record_length,
(uint)uint4korr(rec.header), (uint) rec.header[4], (uint)uint4korr(rec.header), (uint) rec.header[4],
(uint) rec.header[5], (uint) rec.header[5],
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn)); LSN_IN_PARTS(rec.lsn));
translog_free_record_header(&rec); translog_free_record_header(&rec);
goto err; goto err;
} }
...@@ -613,8 +609,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -613,8 +609,7 @@ int main(int argc __attribute__((unused)), char *argv[])
"lsn(%lu,0x%lx)\n", "lsn(%lu,0x%lx)\n",
i, (uint) rec.type, (uint) rec.short_trid, i, (uint) rec.type, (uint) rec.short_trid,
(ulong) rec.record_length, (ulong) rec_len, (ulong) rec.record_length, (ulong) rec_len,
len, len, LSN_IN_PARTS(rec.lsn));
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn));
translog_free_record_header(&rec); translog_free_record_header(&rec);
goto err; goto err;
} }
...@@ -623,7 +618,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -623,7 +618,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, fprintf(stderr,
"Incorrect LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE " "Incorrect LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE "
"in whole rec read lsn(%lu,0x%lx)\n", "in whole rec read lsn(%lu,0x%lx)\n",
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn)); LSN_IN_PARTS(rec.lsn));
translog_free_record_header(&rec); translog_free_record_header(&rec);
goto err; goto err;
} }
......
...@@ -418,10 +418,8 @@ int main(int argc __attribute__((unused)), ...@@ -418,10 +418,8 @@ int main(int argc __attribute__((unused)),
(uint) rec.short_trid, (uint) uint2korr(rec.header), (uint) rec.short_trid, (uint) uint2korr(rec.header),
(uint) rec.record_length, (uint) rec.record_length,
(uint) index, (uint) uint4korr(rec.header + 2), (uint) index, (uint) uint4korr(rec.header + 2),
(ulong) LSN_FILE_NO(rec.lsn), LSN_IN_PARTS(rec.lsn),
(ulong) LSN_OFFSET(rec.lsn), LSN_IN_PARTS(lsns1[rec.short_trid][index]));
(ulong) LSN_FILE_NO(lsns1[rec.short_trid][index]),
(ulong) LSN_OFFSET(lsns1[rec.short_trid][index]));
translog_free_record_header(&rec); translog_free_record_header(&rec);
goto err; goto err;
} }
...@@ -446,10 +444,8 @@ int main(int argc __attribute__((unused)), ...@@ -446,10 +444,8 @@ int main(int argc __attribute__((unused)),
len, len,
(ulong) rec.record_length, lens[rec.short_trid][index], (ulong) rec.record_length, lens[rec.short_trid][index],
(rec.record_length != lens[rec.short_trid][index]), (rec.record_length != lens[rec.short_trid][index]),
(ulong) LSN_FILE_NO(rec.lsn), LSN_IN_PARTS(rec.lsn),
(ulong) LSN_OFFSET(rec.lsn), LSN_IN_PARTS(lsns2[rec.short_trid][index]));
(ulong) LSN_FILE_NO(lsns2[rec.short_trid][index]),
(ulong) LSN_OFFSET(lsns2[rec.short_trid][index]));
translog_free_record_header(&rec); translog_free_record_header(&rec);
goto err; goto err;
} }
...@@ -458,8 +454,7 @@ int main(int argc __attribute__((unused)), ...@@ -458,8 +454,7 @@ int main(int argc __attribute__((unused)),
fprintf(stderr, fprintf(stderr,
"Incorrect LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE " "Incorrect LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE "
"in whole rec read lsn(%lu,0x%lx)\n", "in whole rec read lsn(%lu,0x%lx)\n",
(ulong) LSN_FILE_NO(rec.lsn), LSN_IN_PARTS(rec.lsn));
(ulong) LSN_OFFSET(rec.lsn));
translog_free_record_header(&rec); translog_free_record_header(&rec);
goto err; goto err;
} }
......
...@@ -114,8 +114,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -114,8 +114,7 @@ int main(int argc __attribute__((unused)), char *argv[])
(uint) uint4korr(rec.header), (uint4korr(rec.header) != 0), (uint) uint4korr(rec.header), (uint4korr(rec.header) != 0),
(uint) rec.header[4], (((uchar)rec.header[4]) != 0), (uint) rec.header[4], (((uchar)rec.header[4]) != 0),
(uint) rec.header[5], (((uchar)rec.header[5]) != 0xFF), (uint) rec.header[5], (((uchar)rec.header[5]) != 0xFF),
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn), LSN_IN_PARTS(rec.lsn), (first_lsn != rec.lsn));
(first_lsn != rec.lsn));
goto err; goto err;
} }
......
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