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=
{LOGRECTYPE_VARIABLE_LENGTH, 0, 0, NULL, NULL, NULL, 0,
"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=
{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};
static LOG_DESC INIT_LOGREC_REDO_DELETE_ALL=
......@@ -4437,25 +4426,23 @@ static uchar *translog_relative_LSN_decode(LSN base_lsn,
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
translog_fixed_length_header()
page Pointer to the buffer with page where LSN chunk is
placed
page_offset Offset of the first chunk in the page
buff Buffer to be filled with header data
@param page Pointer to the buffer with page where LSN chunk is
placed
@param page_offset Offset of the first chunk in the page
@param buff Buffer to be filled with header data
RETURN
0 error
# number of bytes in TRANSLOG_HEADER_BUFFER::header where stored decoded
part of the header
@return Length of header or operation status
@retval # number of bytes in TRANSLOG_HEADER_BUFFER::header where
stored decoded part of the header
*/
translog_size_t translog_fixed_length_header(uchar *page,
translog_size_t page_offset,
TRANSLOG_HEADER_BUFFER *buff)
static int translog_fixed_length_header(uchar *page,
translog_size_t page_offset,
TRANSLOG_HEADER_BUFFER *buff)
{
struct st_log_record_type_descriptor *desc=
log_record_type_descriptor + buff->type;
......@@ -4609,6 +4596,7 @@ my_bool translog_init_scanner(LSN lsn,
1 End of the Log
0 OK
*/
static my_bool translog_scanner_eol(TRANSLOG_SCANNER_DATA *scanner)
{
DBUG_ENTER("translog_scanner_eol");
......@@ -4652,6 +4640,7 @@ static my_bool translog_scanner_eol(TRANSLOG_SCANNER_DATA *scanner)
1 End of the Page
0 OK
*/
static my_bool translog_scanner_eop(TRANSLOG_SCANNER_DATA *scanner)
{
DBUG_ENTER("translog_scanner_eop");
......@@ -4672,6 +4661,7 @@ static my_bool translog_scanner_eop(TRANSLOG_SCANNER_DATA *scanner)
1 End of the File
0 OK
*/
static my_bool translog_scanner_eof(TRANSLOG_SCANNER_DATA *scanner)
{
DBUG_ENTER("translog_scanner_eof");
......@@ -4763,29 +4753,25 @@ translog_get_next_chunk(TRANSLOG_SCANNER_DATA *scanner)
}
/*
Get header of variable length record and call hook for it processing
SYNOPSIS
translog_variable_length_header()
page Pointer to the buffer with page where LSN chunk is
placed
page_offset Offset of the first chunk in the page
buff Buffer to be filled with header data
scanner If present should be moved to the header page if
/**
@brief Get header of variable length record and call hook for it processing
@param page Pointer to the buffer with page where LSN chunk is
placed
@param page_offset Offset of the first chunk in the page
@param buff Buffer to be filled with header data
@param scanner If present should be moved to the header page if
it differ from LSN page
RETURN
0 error
# number of bytes in TRANSLOG_HEADER_BUFFER::header where stored decoded
part of the header
@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 translog_variable_length_header(uchar *page,
translog_size_t page_offset,
TRANSLOG_HEADER_BUFFER *buff,
TRANSLOG_SCANNER_DATA
*scanner)
int translog_variable_length_header(uchar *page, translog_size_t page_offset,
TRANSLOG_HEADER_BUFFER *buff,
TRANSLOG_SCANNER_DATA *scanner)
{
struct st_log_record_type_descriptor *desc= (log_record_type_descriptor +
buff->type);
......@@ -4827,7 +4813,7 @@ translog_size_t translog_variable_length_header(uchar *page,
if (!(buff->groups=
(TRANSLOG_GROUP*) my_malloc(sizeof(TRANSLOG_GROUP) * grp_no,
MYF(0))))
DBUG_RETURN(0);
DBUG_RETURN(RECHEADER_READ_ERROR);
DBUG_PRINT("info", ("Groups: %u", (uint) grp_no));
src+= (2 + 2);
page_rest= TRANSLOG_PAGE_SIZE - (src - page);
......@@ -4882,9 +4868,11 @@ translog_size_t translog_variable_length_header(uchar *page,
{
DBUG_PRINT("info", ("use internal scanner for header reading"));
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_offset= scanner->page_offset;
src= page + page_offset + header_to_skip;
......@@ -4938,24 +4926,27 @@ translog_size_t translog_variable_length_header(uchar *page,
}
/*
Read record header from the given buffer
SYNOPSIS
translog_read_record_header_from_buffer()
page page content buffer
page_offset offset of the chunk in the page
buff destination buffer
scanner If this is set the scanner will be moved to the
record header page (differ from LSN page in case of
multi-group records)
/**
@brief Read record header from the given buffer
@param page page content buffer
@param page_offset offset of the chunk in the page
@param buff destination buffer
@param scanner If this is set the scanner will be moved to the
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
translog_read_record_header_from_buffer(uchar *page,
uint16 page_offset,
TRANSLOG_HEADER_BUFFER *buff,
TRANSLOG_SCANNER_DATA *scanner)
int translog_read_record_header_from_buffer(uchar *page,
uint16 page_offset,
TRANSLOG_HEADER_BUFFER *buff,
TRANSLOG_SCANNER_DATA *scanner)
{
translog_size_t res;
DBUG_ENTER("translog_read_record_header_from_buffer");
......@@ -4981,36 +4972,32 @@ translog_read_record_header_from_buffer(uchar *page,
break;
default:
DBUG_ASSERT(0);
res= 0;
res= RECHEADER_READ_ERROR;
}
DBUG_RETURN(res);
}
/*
Read record header and some fixed part of a record (the part depend on
record type).
SYNOPSIS
translog_read_record_header()
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
- "Decoded" header stored in TRANSLOG_HEADER_BUFFER::header (relative
LSN can be translated to absolute one), some fields can be added
(like actual header length in the record if the header has variable
length)
RETURN
0 error
# number of bytes in TRANSLOG_HEADER_BUFFER::header where stored decoded
part of the header
/**
@brief Read record header and some fixed part of a record (the part depend
on record type).
@param lsn log record serial number (address of the record)
@param 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
LSN can be translated to absolute one), some fields can be added (like
actual header length in the record if the header has variable length)
@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 translog_read_record_header(LSN lsn,
TRANSLOG_HEADER_BUFFER *buff)
int translog_read_record_header(LSN lsn, TRANSLOG_HEADER_BUFFER *buff)
{
uchar buffer[TRANSLOG_PAGE_SIZE], *page;
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,
data.was_recovered= 0;
addr= lsn;
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);
DBUG_RETURN(res);
}
/*
Read record header and some fixed part of a record (the part depend on
record type).
SYNOPSIS
translog_read_record_header_scan()
scan scanner position to read
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
- "Decoded" header stored in TRANSLOG_HEADER_BUFFER::header (relative
LSN can be translated to absolute one), some fields can be added
(like actual header length in the record if the header has variable
length)
RETURN
0 error
# number of bytes in TRANSLOG_HEADER_BUFFER::header where stored decoded
part of the header
/**
@brief Read record header and some fixed part of a record (the part depend
on record type).
@param scan scanner position to read
@param buff log record header buffer
@param 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
LSN can be translated to absolute one), some fields can be added (like
actual header length in the record if the header has variable length)
@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
translog_read_record_header_scan(TRANSLOG_SCANNER_DATA
*scanner,
TRANSLOG_HEADER_BUFFER *buff,
my_bool move_scanner)
int translog_read_record_header_scan(TRANSLOG_SCANNER_DATA *scanner,
TRANSLOG_HEADER_BUFFER *buff,
my_bool move_scanner)
{
translog_size_t res;
DBUG_ENTER("translog_read_record_header_scan");
......@@ -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
depend on record type).
SYNOPSIS
translog_read_next_record_header()
scanner data for scanning if lsn is NULL scanner data
will be used for continue scanning.
The scanner can be NULL.
buff log record header buffer
NOTE
- it is like translog_read_record_header, but read next record, so see
its NOTES.
- in case of end of the log buff->lsn will be set to
(LSN_IMPOSSIBLE)
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
/**
@brief Read record header and some fixed part of the next record (the part
depend on record type).
@param scanner data for scanning if lsn is NULL scanner data
will be used for continue scanning.
The scanner can be NULL.
@param buff log record header buffer
@return Length of header or operation status
@retval RECHEADER_READ_ERROR error
@retval RECHEADER_READ_EOF EOF
@retval # 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
*scanner,
TRANSLOG_HEADER_BUFFER *buff)
int translog_read_next_record_header(TRANSLOG_SCANNER_DATA *scanner,
TRANSLOG_HEADER_BUFFER *buff)
{
uint8 chunk_type;
translog_size_t res;
......@@ -5136,7 +5109,7 @@ translog_size_t translog_read_next_record_header(TRANSLOG_SCANNER_DATA
do
{
if (translog_get_next_chunk(scanner))
DBUG_RETURN(0);
DBUG_RETURN(RECHEADER_READ_ERROR);
chunk_type= scanner->page[scanner->page_offset] & TRANSLOG_CHUNK_TYPE;
DBUG_PRINT("info", ("type: %x byte: %x", (uint) chunk_type,
(uint) scanner->page[scanner->page_offset]));
......@@ -5148,7 +5121,7 @@ translog_size_t translog_read_next_record_header(TRANSLOG_SCANNER_DATA
/* Last record was read */
buff->lsn= LSN_IMPOSSIBLE;
/* Return 'end of log' marker */
res= TRANSLOG_RECORD_HEADER_MAX_SIZE + 1;
res= RECHEADER_READ_EOF;
}
else
res= translog_read_record_header_scan(scanner, buff, 0);
......
......@@ -30,6 +30,9 @@
#define TRANSLOG_FLAGS_NUM ((TRANSLOG_PAGE_CRC | TRANSLOG_SECTOR_PROTECTION | \
TRANSLOG_RECORD_CRC) + 1)
#define RECHEADER_READ_ERROR -1
#define RECHEADER_READ_EOF -2
/*
Page size in transaction log
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,
extern void translog_destroy();
extern translog_size_t translog_read_record_header(LSN lsn,
TRANSLOG_HEADER_BUFFER
*buff);
extern int translog_read_record_header(LSN lsn, 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,
my_bool fixed_horizon,
struct st_translog_scanner_data *scanner);
extern translog_size_t translog_read_next_record_header(TRANSLOG_SCANNER_DATA
*scanner,
TRANSLOG_HEADER_BUFFER
*buff);
extern int translog_read_next_record_header(TRANSLOG_SCANNER_DATA *scanner,
TRANSLOG_HEADER_BUFFER *buff);
extern my_bool translog_lock();
extern my_bool translog_unlock();
extern void translog_lock_assert_owner();
......
......@@ -194,13 +194,13 @@ int maria_apply_log(LSN lsn, my_bool apply, FILE *trace_file)
struct st_translog_scanner_data scanner;
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 */
if (len == 0) /* means error, but apparently EOF too */
/** @todo EOF should be detected */
if (len == RECHEADER_READ_ERROR)
{
fprintf(tracef, "empty log\n");
goto end;
fprintf(tracef, "Cannot find a first record\n");
goto err;
}
if (translog_init_scanner(lsn, 1, &scanner))
......@@ -246,7 +246,7 @@ int maria_apply_log(LSN lsn, my_bool apply, FILE *trace_file)
TRANSLOG_HEADER_BUFFER rec2;
len=
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");
goto err;
......@@ -267,7 +267,7 @@ int maria_apply_log(LSN lsn, my_bool apply, FILE *trace_file)
goto err;
}
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");
goto err;
......@@ -294,9 +294,17 @@ int maria_apply_log(LSN lsn, my_bool apply, FILE *trace_file)
}
}
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;
}
}
......
......@@ -90,11 +90,12 @@ int main(int argc, char **argv)
fprintf(stdout, "TRACE of the last maria_read_log\n");
if (maria_apply_log(lsn, opt_display_and_apply, stdout))
goto err;
fprintf(stdout, "SUCCESS\n");
fprintf(stdout, "%s: SUCCESS\n", my_progname);
goto end;
err:
/* don't touch anything more, in case we hit a bug */
fprintf(stderr, "%s: FAILED\n", my_progname);
exit(1);
end:
maria_end();
......
......@@ -360,8 +360,8 @@ int main(int argc __attribute__((unused)), char *argv[])
rc= 1;
{
translog_size_t len= translog_read_record_header(first_lsn, &rec);
if (len == 0)
int len= translog_read_record_header(first_lsn, &rec);
if (len == RECHEADER_READ_ERROR)
{
fprintf(stderr, "translog_read_record_header failed (%d)\n", errno);
goto err;
......@@ -392,13 +392,13 @@ int main(int argc __attribute__((unused)), char *argv[])
for (i= 1;; i++)
{
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",
i, errno);
goto err;
}
if (rec.lsn == LSN_IMPOSSIBLE)
if (len == RECHEADER_READ_EOF)
{
if (i != ITERATIONS)
{
......@@ -471,13 +471,13 @@ int main(int argc __attribute__((unused)), char *argv[])
translog_free_record_header(&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) "
"failed (%d)\n", i, errno);
goto err;
}
if (rec.lsn == LSN_IMPOSSIBLE)
if (len == RECHEADER_READ_EOF)
{
fprintf(stderr, "EOL met at the middle of iteration (first var) %u "
"instead of beginning of %u\n", i, ITERATIONS);
......@@ -542,12 +542,12 @@ int main(int argc __attribute__((unused)), char *argv[])
{
fprintf(stderr, "Incorrect LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE "
"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), "
"lsn(%lu,0x%lx)\n",
i, (uint) rec.type, (uint) rec.short_trid,
(ulong) rec.record_length, (ulong) rec_len,
(uint) len,
len,
(ulong) LSN_FILE_NO(ref1), (ulong) LSN_OFFSET(ref1),
(ulong) LSN_FILE_NO(ref2), (ulong) LSN_OFFSET(ref2),
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn));
......@@ -566,13 +566,13 @@ int main(int argc __attribute__((unused)), char *argv[])
translog_free_record_header(&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",
i, errno);
goto err;
}
if (rec.lsn == LSN_IMPOSSIBLE)
if (len == RECHEADER_READ_EOF)
{
fprintf(stderr, "EOL met at the middle of iteration %u "
"instead of beginning of %u\n", i, ITERATIONS);
......@@ -604,15 +604,15 @@ int main(int argc __attribute__((unused)), char *argv[])
if (rec.type != LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE ||
rec.short_trid != (i % 0xFFFF) ||
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 "
"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",
i, (uint) rec.type, (uint) rec.short_trid,
(ulong) rec.record_length, (ulong) rec_len,
(uint) len,
len,
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn));
goto err;
}
......
......@@ -349,8 +349,8 @@ int main(int argc __attribute__((unused)), char *argv[])
rc= 1;
{
translog_size_t len= translog_read_record_header(first_lsn, &rec);
if (len == 0)
int len= translog_read_record_header(first_lsn, &rec);
if (len == RECHEADER_READ_ERROR)
{
fprintf(stderr, "translog_read_record_header failed (%d)\n", errno);
translog_free_record_header(&rec);
......@@ -383,14 +383,14 @@ int main(int argc __attribute__((unused)), char *argv[])
for (i= 1;; i++)
{
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",
i, errno);
translog_free_record_header(&rec);
goto err;
}
if (rec.lsn == LSN_IMPOSSIBLE)
if (len == RECHEADER_READ_EOF)
{
if (i != ITERATIONS)
{
......@@ -464,13 +464,13 @@ int main(int argc __attribute__((unused)), char *argv[])
translog_free_record_header(&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) "
"failed (%d)\n", i, errno);
goto err;
}
if (rec.lsn == LSN_IMPOSSIBLE)
if (len == RECHEADER_READ_EOF)
{
fprintf(stderr, "EOL met at the middle of iteration (first var) %u "
"instead of beginning of %u\n", i, ITERATIONS);
......@@ -490,7 +490,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "Incorrect LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE "
"data read(%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",
i, (uint) rec.type,
rec.type !=LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE,
......@@ -498,7 +498,7 @@ int main(int argc __attribute__((unused)), char *argv[])
rec.short_trid != (i % 0xFFFF),
(ulong) rec.record_length, (ulong) rec_len,
rec.record_length != rec_len + LSN_STORE_SIZE,
(uint) len,
len,
len != 12,
(ulong) LSN_FILE_NO(ref), (ulong) LSN_OFFSET(ref),
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn),
......@@ -535,12 +535,12 @@ int main(int argc __attribute__((unused)), char *argv[])
{
fprintf(stderr, "Incorrect LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE "
" 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), "
"lsn(%lu,0x%lx)\n",
i, (uint) rec.type, (uint) rec.short_trid,
(ulong) rec.record_length, (ulong) rec_len,
(uint) len,
len,
(ulong) LSN_FILE_NO(ref1), (ulong) LSN_OFFSET(ref1),
(ulong) LSN_FILE_NO(ref2), (ulong) LSN_OFFSET(ref2),
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn));
......@@ -561,14 +561,14 @@ int main(int argc __attribute__((unused)), char *argv[])
translog_free_record_header(&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",
i, errno);
translog_free_record_header(&rec);
goto err;
}
if (rec.lsn == LSN_IMPOSSIBLE)
if (len == RECHEADER_READ_EOF)
{
fprintf(stderr, "EOL met at the middle of iteration %u "
"instead of beginning of %u\n", i, ITERATIONS);
......@@ -606,11 +606,11 @@ int main(int argc __attribute__((unused)), char *argv[])
{
fprintf(stderr, "Incorrect LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE "
"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",
i, (uint) rec.type, (uint) rec.short_trid,
(ulong) rec.record_length, (ulong) rec_len,
(uint) len,
len,
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn));
translog_free_record_header(&rec);
goto err;
......
......@@ -363,7 +363,8 @@ int main(int argc __attribute__((unused)),
{
uint indeces[WRITERS];
uint index, len, stage;
uint index, stage;
int len;
bzero(indeces, sizeof(uint) * WRITERS);
bzero(indeces, sizeof(indeces));
......@@ -377,14 +378,14 @@ int main(int argc __attribute__((unused)),
{
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",
i, errno);
translog_free_record_header(&rec);
goto err;
}
if (rec.lsn == LSN_IMPOSSIBLE)
if (len == RECHEADER_READ_EOF)
{
if (i != WRITERS * ITERATIONS * 2)
{
......@@ -427,18 +428,18 @@ int main(int argc __attribute__((unused)),
len != 9 ||
rec.record_length != lens[rec.short_trid][index] ||
cmp_translog_addr(lsns2[rec.short_trid][index], rec.lsn) != 0 ||
check_content(rec.header, len))
check_content(rec.header, (uint)len))
{
fprintf(stderr,
"Incorrect LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE "
"data read(%d) "
"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",
i, (uint) rec.short_trid, index, stage,
(uint) rec.type, (rec.type !=
LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE),
(uint) len,
len,
(ulong) rec.record_length, lens[rec.short_trid][index],
(rec.record_length != lens[rec.short_trid][index]),
(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