Commit 2cccfcd8 authored by unknown's avatar unknown

Applying Sanja's patch which makes the log handler not issue

errors when reading a log record which has a 0-length header
(like LOGREC_REDO_DROP_TABLE).


storage/maria/ma_loghandler.c:
  Functions reading record's header now don't use 0 to indicate error,
  as some valid records have a 0-length header (like REDO_DROP_TABLE).
  Instead, negative values are used for EOF and error.
storage/maria/ma_loghandler.h:
  functions to read record's header now return an int
  (either the length of this header (>=0) or some negative values
  for EOF or error).
storage/maria/ma_recovery.c:
  update to the new log handler's behaviour. Note the @todo.
storage/maria/maria_read_log.c:
  inform when program failed
storage/maria/unittest/ma_test_loghandler-t.c:
  update to new log handler's API
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
  update to new log handler's API
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
  update to new log handler's API
parent 9554b40d
...@@ -373,19 +373,8 @@ static LOG_DESC INIT_LOGREC_REDO_RENAME_TABLE= ...@@ -373,19 +373,8 @@ static LOG_DESC INIT_LOGREC_REDO_RENAME_TABLE=
{LOGRECTYPE_VARIABLE_LENGTH, 0, 0, NULL, NULL, NULL, 0, {LOGRECTYPE_VARIABLE_LENGTH, 0, 0, NULL, NULL, NULL, 0,
"redo_rename_table", LOGREC_IS_GROUP_ITSELF, NULL, NULL}; "redo_rename_table", LOGREC_IS_GROUP_ITSELF, NULL, NULL};
/**
@todo LOG BUG
the "1" below is a hack to overcome a bug in the log handler where a 0-byte
header is considered a read failure:
translog_read_record() calls translog_init_reader_data() which calls
translog_read_record_header_scan() which calls
translog_read_record_header_from_buffer() which calls
translog_variable_length_header() which returns 0 (normal);
translog_init_reader_data() considers this 0 as a problem,
and thus translog_read_record() fails.
*/
static LOG_DESC INIT_LOGREC_REDO_DROP_TABLE= static LOG_DESC INIT_LOGREC_REDO_DROP_TABLE=
{LOGRECTYPE_VARIABLE_LENGTH, 0, 1, NULL, NULL, NULL, 0, {LOGRECTYPE_VARIABLE_LENGTH, 0, 0, NULL, NULL, NULL, 0,
"redo_drop_table", LOGREC_IS_GROUP_ITSELF, NULL, NULL}; "redo_drop_table", LOGREC_IS_GROUP_ITSELF, NULL, NULL};
static LOG_DESC INIT_LOGREC_REDO_DELETE_ALL= static LOG_DESC INIT_LOGREC_REDO_DELETE_ALL=
...@@ -4437,25 +4426,23 @@ static uchar *translog_relative_LSN_decode(LSN base_lsn, ...@@ -4437,25 +4426,23 @@ static uchar *translog_relative_LSN_decode(LSN base_lsn,
return src; return src;
} }
/* /**
Get header of fixed/pseudo length record and call hook for it processing @brief Get header of fixed/pseudo length record and call hook for
it processing
SYNOPSIS @param page Pointer to the buffer with page where LSN chunk is
translog_fixed_length_header() placed
page Pointer to the buffer with page where LSN chunk is @param page_offset Offset of the first chunk in the page
placed @param buff Buffer to be filled with header data
page_offset Offset of the first chunk in the page
buff Buffer to be filled with header data
RETURN @return Length of header or operation status
0 error @retval # number of bytes in TRANSLOG_HEADER_BUFFER::header where
# number of bytes in TRANSLOG_HEADER_BUFFER::header where stored decoded stored decoded part of the header
part of the header
*/ */
translog_size_t translog_fixed_length_header(uchar *page, static int translog_fixed_length_header(uchar *page,
translog_size_t page_offset, translog_size_t page_offset,
TRANSLOG_HEADER_BUFFER *buff) TRANSLOG_HEADER_BUFFER *buff)
{ {
struct st_log_record_type_descriptor *desc= struct st_log_record_type_descriptor *desc=
log_record_type_descriptor + buff->type; log_record_type_descriptor + buff->type;
...@@ -4609,6 +4596,7 @@ my_bool translog_init_scanner(LSN lsn, ...@@ -4609,6 +4596,7 @@ my_bool translog_init_scanner(LSN lsn,
1 End of the Log 1 End of the Log
0 OK 0 OK
*/ */
static my_bool translog_scanner_eol(TRANSLOG_SCANNER_DATA *scanner) static my_bool translog_scanner_eol(TRANSLOG_SCANNER_DATA *scanner)
{ {
DBUG_ENTER("translog_scanner_eol"); DBUG_ENTER("translog_scanner_eol");
...@@ -4652,6 +4640,7 @@ static my_bool translog_scanner_eol(TRANSLOG_SCANNER_DATA *scanner) ...@@ -4652,6 +4640,7 @@ static my_bool translog_scanner_eol(TRANSLOG_SCANNER_DATA *scanner)
1 End of the Page 1 End of the Page
0 OK 0 OK
*/ */
static my_bool translog_scanner_eop(TRANSLOG_SCANNER_DATA *scanner) static my_bool translog_scanner_eop(TRANSLOG_SCANNER_DATA *scanner)
{ {
DBUG_ENTER("translog_scanner_eop"); DBUG_ENTER("translog_scanner_eop");
...@@ -4672,6 +4661,7 @@ static my_bool translog_scanner_eop(TRANSLOG_SCANNER_DATA *scanner) ...@@ -4672,6 +4661,7 @@ static my_bool translog_scanner_eop(TRANSLOG_SCANNER_DATA *scanner)
1 End of the File 1 End of the File
0 OK 0 OK
*/ */
static my_bool translog_scanner_eof(TRANSLOG_SCANNER_DATA *scanner) static my_bool translog_scanner_eof(TRANSLOG_SCANNER_DATA *scanner)
{ {
DBUG_ENTER("translog_scanner_eof"); DBUG_ENTER("translog_scanner_eof");
...@@ -4763,29 +4753,25 @@ translog_get_next_chunk(TRANSLOG_SCANNER_DATA *scanner) ...@@ -4763,29 +4753,25 @@ translog_get_next_chunk(TRANSLOG_SCANNER_DATA *scanner)
} }
/* /**
Get header of variable length record and call hook for it processing @brief Get header of variable length record and call hook for it processing
SYNOPSIS @param page Pointer to the buffer with page where LSN chunk is
translog_variable_length_header() placed
page Pointer to the buffer with page where LSN chunk is @param page_offset Offset of the first chunk in the page
placed @param buff Buffer to be filled with header data
page_offset Offset of the first chunk in the page @param scanner If present should be moved to the header page if
buff Buffer to be filled with header data
scanner If present should be moved to the header page if
it differ from LSN page it differ from LSN page
@return Length of header or operation status
RETURN @retval RECHEADER_READ_ERROR error
0 error @retval # number of bytes in
# number of bytes in TRANSLOG_HEADER_BUFFER::header where stored decoded TRANSLOG_HEADER_BUFFER::header where
part of the header stored decoded part of the header
*/ */
translog_size_t translog_variable_length_header(uchar *page, int translog_variable_length_header(uchar *page, translog_size_t page_offset,
translog_size_t page_offset, TRANSLOG_HEADER_BUFFER *buff,
TRANSLOG_HEADER_BUFFER *buff, TRANSLOG_SCANNER_DATA *scanner)
TRANSLOG_SCANNER_DATA
*scanner)
{ {
struct st_log_record_type_descriptor *desc= (log_record_type_descriptor + struct st_log_record_type_descriptor *desc= (log_record_type_descriptor +
buff->type); buff->type);
...@@ -4827,7 +4813,7 @@ translog_size_t translog_variable_length_header(uchar *page, ...@@ -4827,7 +4813,7 @@ translog_size_t translog_variable_length_header(uchar *page,
if (!(buff->groups= if (!(buff->groups=
(TRANSLOG_GROUP*) my_malloc(sizeof(TRANSLOG_GROUP) * grp_no, (TRANSLOG_GROUP*) my_malloc(sizeof(TRANSLOG_GROUP) * grp_no,
MYF(0)))) MYF(0))))
DBUG_RETURN(0); DBUG_RETURN(RECHEADER_READ_ERROR);
DBUG_PRINT("info", ("Groups: %u", (uint) grp_no)); DBUG_PRINT("info", ("Groups: %u", (uint) grp_no));
src+= (2 + 2); src+= (2 + 2);
page_rest= TRANSLOG_PAGE_SIZE - (src - page); page_rest= TRANSLOG_PAGE_SIZE - (src - page);
...@@ -4882,9 +4868,11 @@ translog_size_t translog_variable_length_header(uchar *page, ...@@ -4882,9 +4868,11 @@ translog_size_t translog_variable_length_header(uchar *page,
{ {
DBUG_PRINT("info", ("use internal scanner for header reading")); DBUG_PRINT("info", ("use internal scanner for header reading"));
scanner= &internal_scanner; scanner= &internal_scanner;
translog_init_scanner(buff->lsn, 1, scanner); if (translog_init_scanner(buff->lsn, 1, scanner))
DBUG_RETURN(RECHEADER_READ_ERROR);
} }
translog_get_next_chunk(scanner); if (translog_get_next_chunk(scanner))
DBUG_RETURN(RECHEADER_READ_ERROR);
page= scanner->page; page= scanner->page;
page_offset= scanner->page_offset; page_offset= scanner->page_offset;
src= page + page_offset + header_to_skip; src= page + page_offset + header_to_skip;
...@@ -4938,24 +4926,27 @@ translog_size_t translog_variable_length_header(uchar *page, ...@@ -4938,24 +4926,27 @@ translog_size_t translog_variable_length_header(uchar *page,
} }
/* /**
Read record header from the given buffer @brief Read record header from the given buffer
SYNOPSIS @param page page content buffer
translog_read_record_header_from_buffer() @param page_offset offset of the chunk in the page
page page content buffer @param buff destination buffer
page_offset offset of the chunk in the page @param scanner If this is set the scanner will be moved to the
buff destination buffer record header page (differ from LSN page in case of
scanner If this is set the scanner will be moved to the multi-group records)
record header page (differ from LSN page in case of
multi-group records) @return Length of header or operation status
@retval RECHEADER_READ_ERROR error
@retval # number of bytes in
TRANSLOG_HEADER_BUFFER::header where
stored decoded part of the header
*/ */
translog_size_t int translog_read_record_header_from_buffer(uchar *page,
translog_read_record_header_from_buffer(uchar *page, uint16 page_offset,
uint16 page_offset, TRANSLOG_HEADER_BUFFER *buff,
TRANSLOG_HEADER_BUFFER *buff, TRANSLOG_SCANNER_DATA *scanner)
TRANSLOG_SCANNER_DATA *scanner)
{ {
translog_size_t res; translog_size_t res;
DBUG_ENTER("translog_read_record_header_from_buffer"); DBUG_ENTER("translog_read_record_header_from_buffer");
...@@ -4981,36 +4972,32 @@ translog_read_record_header_from_buffer(uchar *page, ...@@ -4981,36 +4972,32 @@ translog_read_record_header_from_buffer(uchar *page,
break; break;
default: default:
DBUG_ASSERT(0); DBUG_ASSERT(0);
res= 0; res= RECHEADER_READ_ERROR;
} }
DBUG_RETURN(res); DBUG_RETURN(res);
} }
/* /**
Read record header and some fixed part of a record (the part depend on @brief Read record header and some fixed part of a record (the part depend
record type). on record type).
SYNOPSIS @param lsn log record serial number (address of the record)
translog_read_record_header() @param buff log record header buffer
lsn log record serial number (address of the record)
buff log record header buffer @note Some type of record can be read completely by this call
@note "Decoded" header stored in TRANSLOG_HEADER_BUFFER::header (relative
NOTE LSN can be translated to absolute one), some fields can be added (like
- Some type of record can be read completely by this call actual header length in the record if the header has variable length)
- "Decoded" header stored in TRANSLOG_HEADER_BUFFER::header (relative
LSN can be translated to absolute one), some fields can be added @return Length of header or operation status
(like actual header length in the record if the header has variable @retval RECHEADER_READ_ERROR error
length) @retval # number of bytes in
TRANSLOG_HEADER_BUFFER::header where
RETURN stored decoded part of the header
0 error
# number of bytes in TRANSLOG_HEADER_BUFFER::header where stored decoded
part of the header
*/ */
translog_size_t translog_read_record_header(LSN lsn, int translog_read_record_header(LSN lsn, TRANSLOG_HEADER_BUFFER *buff)
TRANSLOG_HEADER_BUFFER *buff)
{ {
uchar buffer[TRANSLOG_PAGE_SIZE], *page; uchar buffer[TRANSLOG_PAGE_SIZE], *page;
translog_size_t res, page_offset= LSN_OFFSET(lsn) % TRANSLOG_PAGE_SIZE; translog_size_t res, page_offset= LSN_OFFSET(lsn) % TRANSLOG_PAGE_SIZE;
...@@ -5027,40 +5014,35 @@ translog_size_t translog_read_record_header(LSN lsn, ...@@ -5027,40 +5014,35 @@ translog_size_t translog_read_record_header(LSN lsn,
data.was_recovered= 0; data.was_recovered= 0;
addr= lsn; addr= lsn;
addr-= page_offset; /* offset decreasing */ addr-= page_offset; /* offset decreasing */
res= (!(page= translog_get_page(&data, buffer))) ? 0 : res= (!(page= translog_get_page(&data, buffer))) ? RECHEADER_READ_ERROR :
translog_read_record_header_from_buffer(page, page_offset, buff, 0); translog_read_record_header_from_buffer(page, page_offset, buff, 0);
DBUG_RETURN(res); DBUG_RETURN(res);
} }
/* /**
Read record header and some fixed part of a record (the part depend on @brief Read record header and some fixed part of a record (the part depend
record type). on record type).
SYNOPSIS @param scan scanner position to read
translog_read_record_header_scan() @param buff log record header buffer
scan scanner position to read @param move_scanner request to move scanner to the header position
buff log record header buffer
move_scanner request to move scanner to the header position @note Some type of record can be read completely by this call
@note "Decoded" header stored in TRANSLOG_HEADER_BUFFER::header (relative
NOTE LSN can be translated to absolute one), some fields can be added (like
- Some type of record can be read completely by this call actual header length in the record if the header has variable length)
- "Decoded" header stored in TRANSLOG_HEADER_BUFFER::header (relative
LSN can be translated to absolute one), some fields can be added @return Length of header or operation status
(like actual header length in the record if the header has variable @retval RECHEADER_READ_ERROR error
length) @retval # number of bytes in
TRANSLOG_HEADER_BUFFER::header where stored
RETURN decoded part of the header
0 error
# number of bytes in TRANSLOG_HEADER_BUFFER::header where stored decoded
part of the header
*/ */
translog_size_t int translog_read_record_header_scan(TRANSLOG_SCANNER_DATA *scanner,
translog_read_record_header_scan(TRANSLOG_SCANNER_DATA TRANSLOG_HEADER_BUFFER *buff,
*scanner, my_bool move_scanner)
TRANSLOG_HEADER_BUFFER *buff,
my_bool move_scanner)
{ {
translog_size_t res; translog_size_t res;
DBUG_ENTER("translog_read_record_header_scan"); DBUG_ENTER("translog_read_record_header_scan");
...@@ -5086,35 +5068,26 @@ translog_read_record_header_scan(TRANSLOG_SCANNER_DATA ...@@ -5086,35 +5068,26 @@ translog_read_record_header_scan(TRANSLOG_SCANNER_DATA
} }
/* /**
Read record header and some fixed part of the next record (the part @brief Read record header and some fixed part of the next record (the part
depend on record type). depend on record type).
SYNOPSIS @param scanner data for scanning if lsn is NULL scanner data
translog_read_next_record_header() will be used for continue scanning.
scanner data for scanning if lsn is NULL scanner data The scanner can be NULL.
will be used for continue scanning.
The scanner can be NULL. @param buff log record header buffer
buff log record header buffer
@return Length of header or operation status
NOTE @retval RECHEADER_READ_ERROR error
- it is like translog_read_record_header, but read next record, so see @retval RECHEADER_READ_EOF EOF
its NOTES. @retval # number of bytes in
- in case of end of the log buff->lsn will be set to TRANSLOG_HEADER_BUFFER::header where
(LSN_IMPOSSIBLE) stored decoded part of the header
RETURN
0 error
TRANSLOG_RECORD_HEADER_MAX_SIZE + 1 End of the log
# number of bytes in
TRANSLOG_HEADER_BUFFER::header
where stored decoded
part of the header
*/ */
translog_size_t translog_read_next_record_header(TRANSLOG_SCANNER_DATA int translog_read_next_record_header(TRANSLOG_SCANNER_DATA *scanner,
*scanner, TRANSLOG_HEADER_BUFFER *buff)
TRANSLOG_HEADER_BUFFER *buff)
{ {
uint8 chunk_type; uint8 chunk_type;
translog_size_t res; translog_size_t res;
...@@ -5136,7 +5109,7 @@ translog_size_t translog_read_next_record_header(TRANSLOG_SCANNER_DATA ...@@ -5136,7 +5109,7 @@ translog_size_t translog_read_next_record_header(TRANSLOG_SCANNER_DATA
do do
{ {
if (translog_get_next_chunk(scanner)) if (translog_get_next_chunk(scanner))
DBUG_RETURN(0); DBUG_RETURN(RECHEADER_READ_ERROR);
chunk_type= scanner->page[scanner->page_offset] & TRANSLOG_CHUNK_TYPE; chunk_type= scanner->page[scanner->page_offset] & TRANSLOG_CHUNK_TYPE;
DBUG_PRINT("info", ("type: %x byte: %x", (uint) chunk_type, DBUG_PRINT("info", ("type: %x byte: %x", (uint) chunk_type,
(uint) scanner->page[scanner->page_offset])); (uint) scanner->page[scanner->page_offset]));
...@@ -5148,7 +5121,7 @@ translog_size_t translog_read_next_record_header(TRANSLOG_SCANNER_DATA ...@@ -5148,7 +5121,7 @@ translog_size_t translog_read_next_record_header(TRANSLOG_SCANNER_DATA
/* Last record was read */ /* Last record was read */
buff->lsn= LSN_IMPOSSIBLE; buff->lsn= LSN_IMPOSSIBLE;
/* Return 'end of log' marker */ /* Return 'end of log' marker */
res= TRANSLOG_RECORD_HEADER_MAX_SIZE + 1; res= RECHEADER_READ_EOF;
} }
else else
res= translog_read_record_header_scan(scanner, buff, 0); res= translog_read_record_header_scan(scanner, buff, 0);
......
...@@ -30,6 +30,9 @@ ...@@ -30,6 +30,9 @@
#define TRANSLOG_FLAGS_NUM ((TRANSLOG_PAGE_CRC | TRANSLOG_SECTOR_PROTECTION | \ #define TRANSLOG_FLAGS_NUM ((TRANSLOG_PAGE_CRC | TRANSLOG_SECTOR_PROTECTION | \
TRANSLOG_RECORD_CRC) + 1) TRANSLOG_RECORD_CRC) + 1)
#define RECHEADER_READ_ERROR -1
#define RECHEADER_READ_EOF -2
/* /*
Page size in transaction log Page size in transaction log
It should be Power of 2 and multiple of DISK_DRIVE_SECTOR_SIZE It should be Power of 2 and multiple of DISK_DRIVE_SECTOR_SIZE
...@@ -228,9 +231,7 @@ translog_write_record(LSN *lsn, enum translog_record_type type, ...@@ -228,9 +231,7 @@ translog_write_record(LSN *lsn, enum translog_record_type type,
extern void translog_destroy(); extern void translog_destroy();
extern translog_size_t translog_read_record_header(LSN lsn, extern int translog_read_record_header(LSN lsn, TRANSLOG_HEADER_BUFFER *buff);
TRANSLOG_HEADER_BUFFER
*buff);
extern void translog_free_record_header(TRANSLOG_HEADER_BUFFER *buff); extern void translog_free_record_header(TRANSLOG_HEADER_BUFFER *buff);
...@@ -247,10 +248,8 @@ extern my_bool translog_init_scanner(LSN lsn, ...@@ -247,10 +248,8 @@ extern my_bool translog_init_scanner(LSN lsn,
my_bool fixed_horizon, my_bool fixed_horizon,
struct st_translog_scanner_data *scanner); struct st_translog_scanner_data *scanner);
extern translog_size_t translog_read_next_record_header(TRANSLOG_SCANNER_DATA extern int translog_read_next_record_header(TRANSLOG_SCANNER_DATA *scanner,
*scanner, TRANSLOG_HEADER_BUFFER *buff);
TRANSLOG_HEADER_BUFFER
*buff);
extern my_bool translog_lock(); extern my_bool translog_lock();
extern my_bool translog_unlock(); extern my_bool translog_unlock();
extern void translog_lock_assert_owner(); extern void translog_lock_assert_owner();
......
...@@ -194,13 +194,13 @@ int maria_apply_log(LSN lsn, my_bool apply, FILE *trace_file) ...@@ -194,13 +194,13 @@ int maria_apply_log(LSN lsn, my_bool apply, FILE *trace_file)
struct st_translog_scanner_data scanner; struct st_translog_scanner_data scanner;
uint i= 1; uint i= 1;
translog_size_t len= translog_read_record_header(lsn, &rec); int len= translog_read_record_header(lsn, &rec);
/** @todo translog_read_record_header() should be fixed for 0-byte headers */ /** @todo EOF should be detected */
if (len == 0) /* means error, but apparently EOF too */ if (len == RECHEADER_READ_ERROR)
{ {
fprintf(tracef, "empty log\n"); fprintf(tracef, "Cannot find a first record\n");
goto end; goto err;
} }
if (translog_init_scanner(lsn, 1, &scanner)) if (translog_init_scanner(lsn, 1, &scanner))
...@@ -246,7 +246,7 @@ int maria_apply_log(LSN lsn, my_bool apply, FILE *trace_file) ...@@ -246,7 +246,7 @@ int maria_apply_log(LSN lsn, my_bool apply, FILE *trace_file)
TRANSLOG_HEADER_BUFFER rec2; TRANSLOG_HEADER_BUFFER rec2;
len= len=
translog_read_record_header(all_active_trans[sid].group_start_lsn, &rec2); translog_read_record_header(all_active_trans[sid].group_start_lsn, &rec2);
if (len == (TRANSLOG_RECORD_HEADER_MAX_SIZE + 1)) if (len < 0) /* EOF or error */
{ {
fprintf(tracef, "Cannot find record where it should be\n"); fprintf(tracef, "Cannot find record where it should be\n");
goto err; goto err;
...@@ -267,7 +267,7 @@ int maria_apply_log(LSN lsn, my_bool apply, FILE *trace_file) ...@@ -267,7 +267,7 @@ int maria_apply_log(LSN lsn, my_bool apply, FILE *trace_file)
goto err; goto err;
} }
len= translog_read_next_record_header(&scanner2, &rec2); len= translog_read_next_record_header(&scanner2, &rec2);
if (len == (TRANSLOG_RECORD_HEADER_MAX_SIZE + 1)) if (len < 0) /* EOF or error */
{ {
fprintf(tracef, "Cannot find record where it should be\n"); fprintf(tracef, "Cannot find record where it should be\n");
goto err; goto err;
...@@ -294,9 +294,17 @@ int maria_apply_log(LSN lsn, my_bool apply, FILE *trace_file) ...@@ -294,9 +294,17 @@ int maria_apply_log(LSN lsn, my_bool apply, FILE *trace_file)
} }
} }
len= translog_read_next_record_header(&scanner, &rec); len= translog_read_next_record_header(&scanner, &rec);
if (len == (TRANSLOG_RECORD_HEADER_MAX_SIZE + 1)) if (len < 0)
{ {
fprintf(tracef, "EOF on the log\n"); switch (len)
{
case RECHEADER_READ_EOF:
fprintf(tracef, "EOF on the log\n");
break;
case RECHEADER_READ_ERROR:
fprintf(stderr, "Error reading log\n");
goto err;
}
break; break;
} }
} }
......
...@@ -90,11 +90,12 @@ int main(int argc, char **argv) ...@@ -90,11 +90,12 @@ int main(int argc, char **argv)
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))
goto err; goto err;
fprintf(stdout, "SUCCESS\n"); fprintf(stdout, "%s: SUCCESS\n", my_progname);
goto end; goto end;
err: err:
/* don't touch anything more, in case we hit a bug */ /* don't touch anything more, in case we hit a bug */
fprintf(stderr, "%s: FAILED\n", my_progname);
exit(1); exit(1);
end: end:
maria_end(); maria_end();
......
...@@ -360,8 +360,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -360,8 +360,8 @@ int main(int argc __attribute__((unused)), char *argv[])
rc= 1; rc= 1;
{ {
translog_size_t len= translog_read_record_header(first_lsn, &rec); int len= translog_read_record_header(first_lsn, &rec);
if (len == 0) if (len == RECHEADER_READ_ERROR)
{ {
fprintf(stderr, "translog_read_record_header failed (%d)\n", errno); fprintf(stderr, "translog_read_record_header failed (%d)\n", errno);
goto err; goto err;
...@@ -392,13 +392,13 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -392,13 +392,13 @@ int main(int argc __attribute__((unused)), char *argv[])
for (i= 1;; i++) for (i= 1;; i++)
{ {
len= translog_read_next_record_header(&scanner, &rec); len= translog_read_next_record_header(&scanner, &rec);
if (len == 0) if (len == RECHEADER_READ_ERROR)
{ {
fprintf(stderr, "1-%d translog_read_next_record_header failed (%d)\n", fprintf(stderr, "1-%d translog_read_next_record_header failed (%d)\n",
i, errno); i, errno);
goto err; goto err;
} }
if (rec.lsn == LSN_IMPOSSIBLE) if (len == RECHEADER_READ_EOF)
{ {
if (i != ITERATIONS) if (i != ITERATIONS)
{ {
...@@ -471,13 +471,13 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -471,13 +471,13 @@ int main(int argc __attribute__((unused)), char *argv[])
translog_free_record_header(&rec); translog_free_record_header(&rec);
len= translog_read_next_record_header(&scanner, &rec); len= translog_read_next_record_header(&scanner, &rec);
if (len == 0) if (len == RECHEADER_READ_ERROR)
{ {
fprintf(stderr, "1-%d translog_read_next_record_header (var) " fprintf(stderr, "1-%d translog_read_next_record_header (var) "
"failed (%d)\n", i, errno); "failed (%d)\n", i, errno);
goto err; goto err;
} }
if (rec.lsn == LSN_IMPOSSIBLE) if (len == RECHEADER_READ_EOF)
{ {
fprintf(stderr, "EOL met at the middle of iteration (first var) %u " fprintf(stderr, "EOL met at the middle of iteration (first var) %u "
"instead of beginning of %u\n", i, ITERATIONS); "instead of beginning of %u\n", i, ITERATIONS);
...@@ -542,12 +542,12 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -542,12 +542,12 @@ int main(int argc __attribute__((unused)), char *argv[])
{ {
fprintf(stderr, "Incorrect LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE " fprintf(stderr, "Incorrect LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE "
"data read(%d) " "data read(%d) "
"type %u, strid %u, len %lu != %lu + 14, hdr len: %u, " "type %u, strid %u, len %lu != %lu + 14, hdr len: %d, "
"ref1(%lu,0x%lx), ref2(%lu,0x%lx), " "ref1(%lu,0x%lx), ref2(%lu,0x%lx), "
"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,
(uint) len, len,
(ulong) LSN_FILE_NO(ref1), (ulong) LSN_OFFSET(ref1), (ulong) LSN_FILE_NO(ref1), (ulong) LSN_OFFSET(ref1),
(ulong) LSN_FILE_NO(ref2), (ulong) LSN_OFFSET(ref2), (ulong) LSN_FILE_NO(ref2), (ulong) LSN_OFFSET(ref2),
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn)); (ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn));
...@@ -566,13 +566,13 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -566,13 +566,13 @@ int main(int argc __attribute__((unused)), char *argv[])
translog_free_record_header(&rec); translog_free_record_header(&rec);
len= translog_read_next_record_header(&scanner, &rec); len= translog_read_next_record_header(&scanner, &rec);
if (len == 0) if (len == RECHEADER_READ_ERROR)
{ {
fprintf(stderr, "1-%d translog_read_next_record_header failed (%d)\n", fprintf(stderr, "1-%d translog_read_next_record_header failed (%d)\n",
i, errno); i, errno);
goto err; goto err;
} }
if (rec.lsn == LSN_IMPOSSIBLE) if (len == RECHEADER_READ_EOF)
{ {
fprintf(stderr, "EOL met at the middle of iteration %u " fprintf(stderr, "EOL met at the middle of iteration %u "
"instead of beginning of %u\n", i, ITERATIONS); "instead of beginning of %u\n", i, ITERATIONS);
...@@ -604,15 +604,15 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -604,15 +604,15 @@ int main(int argc __attribute__((unused)), char *argv[])
if (rec.type != LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE || if (rec.type != LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE ||
rec.short_trid != (i % 0xFFFF) || rec.short_trid != (i % 0xFFFF) ||
rec.record_length != rec_len || rec.record_length != rec_len ||
len != 9 || check_content(rec.header, len)) len != 9 || check_content(rec.header, (uint)len))
{ {
fprintf(stderr, "Incorrect LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE " fprintf(stderr, "Incorrect LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE "
"data read(%d) " "data read(%d) "
"type %u, strid %u, len %lu != %lu, hdr len: %u, " "type %u, strid %u, len %lu != %lu, hdr len: %d, "
"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,
(uint) len, len,
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn)); (ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn));
goto err; goto err;
} }
......
...@@ -349,8 +349,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -349,8 +349,8 @@ int main(int argc __attribute__((unused)), char *argv[])
rc= 1; rc= 1;
{ {
translog_size_t len= translog_read_record_header(first_lsn, &rec); int len= translog_read_record_header(first_lsn, &rec);
if (len == 0) if (len == RECHEADER_READ_ERROR)
{ {
fprintf(stderr, "translog_read_record_header failed (%d)\n", errno); fprintf(stderr, "translog_read_record_header failed (%d)\n", errno);
translog_free_record_header(&rec); translog_free_record_header(&rec);
...@@ -383,14 +383,14 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -383,14 +383,14 @@ int main(int argc __attribute__((unused)), char *argv[])
for (i= 1;; i++) for (i= 1;; i++)
{ {
len= translog_read_next_record_header(&scanner, &rec); len= translog_read_next_record_header(&scanner, &rec);
if (len == 0) if (len == RECHEADER_READ_ERROR)
{ {
fprintf(stderr, "1-%d translog_read_next_record_header failed (%d)\n", fprintf(stderr, "1-%d translog_read_next_record_header failed (%d)\n",
i, errno); i, errno);
translog_free_record_header(&rec); translog_free_record_header(&rec);
goto err; goto err;
} }
if (rec.lsn == LSN_IMPOSSIBLE) if (len == RECHEADER_READ_EOF)
{ {
if (i != ITERATIONS) if (i != ITERATIONS)
{ {
...@@ -464,13 +464,13 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -464,13 +464,13 @@ int main(int argc __attribute__((unused)), char *argv[])
translog_free_record_header(&rec); translog_free_record_header(&rec);
len= translog_read_next_record_header(&scanner, &rec); len= translog_read_next_record_header(&scanner, &rec);
if (len == 0) if (len == RECHEADER_READ_ERROR)
{ {
fprintf(stderr, "1-%d translog_read_next_record_header (var) " fprintf(stderr, "1-%d translog_read_next_record_header (var) "
"failed (%d)\n", i, errno); "failed (%d)\n", i, errno);
goto err; goto err;
} }
if (rec.lsn == LSN_IMPOSSIBLE) if (len == RECHEADER_READ_EOF)
{ {
fprintf(stderr, "EOL met at the middle of iteration (first var) %u " fprintf(stderr, "EOL met at the middle of iteration (first var) %u "
"instead of beginning of %u\n", i, ITERATIONS); "instead of beginning of %u\n", i, ITERATIONS);
...@@ -490,7 +490,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -490,7 +490,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "Incorrect LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE " fprintf(stderr, "Incorrect LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE "
"data read(%d)" "data read(%d)"
"type %u (%d), strid %u (%d), len %lu, %lu + 7 (%d), " "type %u (%d), strid %u (%d), len %lu, %lu + 7 (%d), "
"hdr len: %u (%d), " "hdr len: %d (%d), "
"ref(%lu,0x%lx), lsn(%lu,0x%lx) (%d), content: %d\n", "ref(%lu,0x%lx), lsn(%lu,0x%lx) (%d), content: %d\n",
i, (uint) rec.type, i, (uint) rec.type,
rec.type !=LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE, rec.type !=LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE,
...@@ -498,7 +498,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -498,7 +498,7 @@ int main(int argc __attribute__((unused)), char *argv[])
rec.short_trid != (i % 0xFFFF), rec.short_trid != (i % 0xFFFF),
(ulong) rec.record_length, (ulong) rec_len, (ulong) rec.record_length, (ulong) rec_len,
rec.record_length != rec_len + LSN_STORE_SIZE, rec.record_length != rec_len + LSN_STORE_SIZE,
(uint) len, len,
len != 12, len != 12,
(ulong) LSN_FILE_NO(ref), (ulong) LSN_OFFSET(ref), (ulong) LSN_FILE_NO(ref), (ulong) LSN_OFFSET(ref),
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn), (ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn),
...@@ -535,12 +535,12 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -535,12 +535,12 @@ int main(int argc __attribute__((unused)), char *argv[])
{ {
fprintf(stderr, "Incorrect LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE " fprintf(stderr, "Incorrect LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE "
" data read(%d) " " data read(%d) "
"type %u, strid %u, len %lu != %lu + 14, hdr len: %u, " "type %u, strid %u, len %lu != %lu + 14, hdr len: %d, "
"ref1(%lu,0x%lx), ref2(%lu,0x%lx), " "ref1(%lu,0x%lx), ref2(%lu,0x%lx), "
"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,
(uint) len, len,
(ulong) LSN_FILE_NO(ref1), (ulong) LSN_OFFSET(ref1), (ulong) LSN_FILE_NO(ref1), (ulong) LSN_OFFSET(ref1),
(ulong) LSN_FILE_NO(ref2), (ulong) LSN_OFFSET(ref2), (ulong) LSN_FILE_NO(ref2), (ulong) LSN_OFFSET(ref2),
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn)); (ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn));
...@@ -561,14 +561,14 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -561,14 +561,14 @@ int main(int argc __attribute__((unused)), char *argv[])
translog_free_record_header(&rec); translog_free_record_header(&rec);
len= translog_read_next_record_header(&scanner, &rec); len= translog_read_next_record_header(&scanner, &rec);
if (len == 0) if (len == RECHEADER_READ_ERROR)
{ {
fprintf(stderr, "1-%d translog_read_next_record_header failed (%d)\n", fprintf(stderr, "1-%d translog_read_next_record_header failed (%d)\n",
i, errno); i, errno);
translog_free_record_header(&rec); translog_free_record_header(&rec);
goto err; goto err;
} }
if (rec.lsn == LSN_IMPOSSIBLE) if (len == RECHEADER_READ_EOF)
{ {
fprintf(stderr, "EOL met at the middle of iteration %u " fprintf(stderr, "EOL met at the middle of iteration %u "
"instead of beginning of %u\n", i, ITERATIONS); "instead of beginning of %u\n", i, ITERATIONS);
...@@ -606,11 +606,11 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -606,11 +606,11 @@ int main(int argc __attribute__((unused)), char *argv[])
{ {
fprintf(stderr, "Incorrect LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE " fprintf(stderr, "Incorrect LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE "
"data read(%d) " "data read(%d) "
"type %u, strid %u, len %lu != %lu, hdr len: %u, " "type %u, strid %u, len %lu != %lu, hdr len: %d, "
"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,
(uint) len, len,
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(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;
......
...@@ -363,7 +363,8 @@ int main(int argc __attribute__((unused)), ...@@ -363,7 +363,8 @@ int main(int argc __attribute__((unused)),
{ {
uint indeces[WRITERS]; uint indeces[WRITERS];
uint index, len, stage; uint index, stage;
int len;
bzero(indeces, sizeof(uint) * WRITERS); bzero(indeces, sizeof(uint) * WRITERS);
bzero(indeces, sizeof(indeces)); bzero(indeces, sizeof(indeces));
...@@ -377,14 +378,14 @@ int main(int argc __attribute__((unused)), ...@@ -377,14 +378,14 @@ int main(int argc __attribute__((unused)),
{ {
len= translog_read_next_record_header(&scanner, &rec); len= translog_read_next_record_header(&scanner, &rec);
if (len == 0) if (len == RECHEADER_READ_ERROR)
{ {
fprintf(stderr, "1-%d translog_read_next_record_header failed (%d)\n", fprintf(stderr, "1-%d translog_read_next_record_header failed (%d)\n",
i, errno); i, errno);
translog_free_record_header(&rec); translog_free_record_header(&rec);
goto err; goto err;
} }
if (rec.lsn == LSN_IMPOSSIBLE) if (len == RECHEADER_READ_EOF)
{ {
if (i != WRITERS * ITERATIONS * 2) if (i != WRITERS * ITERATIONS * 2)
{ {
...@@ -427,18 +428,18 @@ int main(int argc __attribute__((unused)), ...@@ -427,18 +428,18 @@ int main(int argc __attribute__((unused)),
len != 9 || len != 9 ||
rec.record_length != lens[rec.short_trid][index] || rec.record_length != lens[rec.short_trid][index] ||
cmp_translog_addr(lsns2[rec.short_trid][index], rec.lsn) != 0 || cmp_translog_addr(lsns2[rec.short_trid][index], rec.lsn) != 0 ||
check_content(rec.header, len)) check_content(rec.header, (uint)len))
{ {
fprintf(stderr, fprintf(stderr,
"Incorrect LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE " "Incorrect LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE "
"data read(%d) " "data read(%d) "
"thread: %d, iteration %d, stage %d\n" "thread: %d, iteration %d, stage %d\n"
"type %u (%d), len %u, length %lu %lu (%d) " "type %u (%d), len %d, length %lu %lu (%d) "
"lsn(%lu,0x%lx) (%lu,0x%lx)\n", "lsn(%lu,0x%lx) (%lu,0x%lx)\n",
i, (uint) rec.short_trid, index, stage, i, (uint) rec.short_trid, index, stage,
(uint) rec.type, (rec.type != (uint) rec.type, (rec.type !=
LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE), LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE),
(uint) 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), (ulong) LSN_FILE_NO(rec.lsn),
......
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