Commit 73b073ff authored by unknown's avatar unknown

Check of transaction log descriptor table consistance added.

Small fixes made.


storage/maria/ma_loghandler.c:
  Check of transaction log descriptor table consistance added.\
  Incorrect record description fixed.
  Compiler warning fixed.
storage/maria/ma_loghandler.h:
  fixed ident.
storage/maria/unittest/ma_test_loghandler-t.c:
  Suppressing of automatic record writing
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
  Suppressing of automatic record writing
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
  Suppressing of automatic record writing
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
  Suppressing of automatic record writing
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
  Suppressing of automatic record writing
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
  Suppressing of automatic record writing
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
  Suppressing of automatic record writing
storage/maria/unittest/ma_test_loghandler_purge-t.c:
  Suppressing of automatic record writing
parent b4b0bf47
...@@ -224,6 +224,84 @@ static my_bool translog_page_validator(uchar *page_addr, uchar* data_ptr); ...@@ -224,6 +224,84 @@ static my_bool translog_page_validator(uchar *page_addr, uchar* data_ptr);
LOG_DESC log_record_type_descriptor[LOGREC_NUMBER_OF_TYPES]; LOG_DESC log_record_type_descriptor[LOGREC_NUMBER_OF_TYPES];
#ifndef DBUG_OFF
/**
@brief check the description table validity
@param num how many records should be filled
*/
static void check_translog_description_table(int num)
{
int i;
DBUG_ENTER("check_translog_description_table");
DBUG_PRINT("enter", ("last record: %d", num));
DBUG_ASSERT(num > 0);
/* last is reserved for extending the table */
DBUG_ASSERT(num < LOGREC_NUMBER_OF_TYPES - 1);
DBUG_PRINT("info", ("records number: OK"));
DBUG_PRINT("info",
("record type: %d class: %d fixed: %u header: %u LSNs: %u "
"name: %s",
0,
log_record_type_descriptor[0].class,
(uint)log_record_type_descriptor[0].fixed_length,
(uint)log_record_type_descriptor[0].read_header_len,
(uint)log_record_type_descriptor[0].compressed_LSN,
log_record_type_descriptor[0].name));
DBUG_ASSERT(log_record_type_descriptor[0].class == LOGRECTYPE_NOT_ALLOWED);
DBUG_PRINT("info", ("record type 0: OK"));
for (i= 1; i <= num; i++)
{
DBUG_PRINT("info",
("record type: %d class: %d fixed: %u header: %u LSNs: %u "
"name: %s",
i, log_record_type_descriptor[i].class,
(uint)log_record_type_descriptor[i].fixed_length,
(uint)log_record_type_descriptor[i].read_header_len,
(uint)log_record_type_descriptor[i].compressed_LSN,
log_record_type_descriptor[i].name));
switch (log_record_type_descriptor[i].class) {
case LOGRECTYPE_NOT_ALLOWED:
DBUG_ASSERT(0);
break;
case LOGRECTYPE_VARIABLE_LENGTH:
DBUG_ASSERT(log_record_type_descriptor[i].fixed_length == 0);
DBUG_ASSERT((log_record_type_descriptor[i].compressed_LSN == 0) ||
((log_record_type_descriptor[i].compressed_LSN == 1) &&
(log_record_type_descriptor[i].read_header_len >=
LSN_STORE_SIZE)) ||
((log_record_type_descriptor[i].compressed_LSN == 2) &&
(log_record_type_descriptor[i].read_header_len >=
LSN_STORE_SIZE * 2)));
break;
case LOGRECTYPE_PSEUDOFIXEDLENGTH:
DBUG_ASSERT(log_record_type_descriptor[i].fixed_length ==
log_record_type_descriptor[i].read_header_len);
DBUG_ASSERT(log_record_type_descriptor[i].compressed_LSN > 0);
DBUG_ASSERT(log_record_type_descriptor[i].compressed_LSN <= 2);
break;
case LOGRECTYPE_FIXEDLENGTH:
DBUG_ASSERT(log_record_type_descriptor[i].fixed_length ==
log_record_type_descriptor[i].read_header_len);
DBUG_ASSERT(log_record_type_descriptor[i].compressed_LSN == 0);
break;
default:
DBUG_ASSERT(0);
}
DBUG_PRINT("info", ("record type %d: OK", i));
}
DBUG_PRINT("info", ("All filled records are OK"));
for (i= num + 1; i < LOGREC_NUMBER_OF_TYPES; i++)
{
DBUG_ASSERT(log_record_type_descriptor[i].class == LOGRECTYPE_NOT_ALLOWED);
DBUG_PRINT("info", ("record type %d: OK", i));
}
DBUG_VOID_RETURN;
}
#endif
static LOG_DESC INIT_LOGREC_FIXED_RECORD_0LSN_EXAMPLE= static LOG_DESC INIT_LOGREC_FIXED_RECORD_0LSN_EXAMPLE=
{LOGRECTYPE_FIXEDLENGTH, 6, 6, NULL, NULL, NULL, 0, {LOGRECTYPE_FIXEDLENGTH, 6, 6, NULL, NULL, NULL, 0,
"fixed0example", LOGREC_NOT_LAST_IN_GROUP, NULL, NULL}; "fixed0example", LOGREC_NOT_LAST_IN_GROUP, NULL, NULL};
...@@ -251,6 +329,7 @@ static LOG_DESC INIT_LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE= ...@@ -251,6 +329,7 @@ static LOG_DESC INIT_LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE=
void example_loghandler_init() void example_loghandler_init()
{ {
int i;
log_record_type_descriptor[LOGREC_FIXED_RECORD_0LSN_EXAMPLE]= log_record_type_descriptor[LOGREC_FIXED_RECORD_0LSN_EXAMPLE]=
INIT_LOGREC_FIXED_RECORD_0LSN_EXAMPLE; INIT_LOGREC_FIXED_RECORD_0LSN_EXAMPLE;
log_record_type_descriptor[LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE]= log_record_type_descriptor[LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE]=
...@@ -263,6 +342,12 @@ void example_loghandler_init() ...@@ -263,6 +342,12 @@ void example_loghandler_init()
INIT_LOGREC_FIXED_RECORD_2LSN_EXAMPLE; INIT_LOGREC_FIXED_RECORD_2LSN_EXAMPLE;
log_record_type_descriptor[LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE]= log_record_type_descriptor[LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE]=
INIT_LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE; INIT_LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE;
for (i= LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE + 1;
i < LOGREC_NUMBER_OF_TYPES;
i++)
log_record_type_descriptor[i].class= LOGRECTYPE_NOT_ALLOWED;
DBUG_EXECUTE("info",
check_translog_description_table(LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE););
} }
...@@ -374,7 +459,7 @@ static LOG_DESC INIT_LOGREC_PREPARE= ...@@ -374,7 +459,7 @@ static LOG_DESC INIT_LOGREC_PREPARE=
"prepare", LOGREC_IS_GROUP_ITSELF, NULL, NULL}; "prepare", LOGREC_IS_GROUP_ITSELF, NULL, NULL};
static LOG_DESC INIT_LOGREC_PREPARE_WITH_UNDO_PURGE= static LOG_DESC INIT_LOGREC_PREPARE_WITH_UNDO_PURGE=
{LOGRECTYPE_VARIABLE_LENGTH, 0, 5, NULL, NULL, NULL, 1, {LOGRECTYPE_VARIABLE_LENGTH, 0, LSN_STORE_SIZE, NULL, NULL, NULL, 1,
"prepare_with_undo_purge", LOGREC_IS_GROUP_ITSELF, NULL, NULL}; "prepare_with_undo_purge", LOGREC_IS_GROUP_ITSELF, NULL, NULL};
static LOG_DESC INIT_LOGREC_COMMIT= static LOG_DESC INIT_LOGREC_COMMIT=
...@@ -424,6 +509,7 @@ const myf log_write_flags= MY_WME | MY_NABP | MY_WAIT_IF_FULL; ...@@ -424,6 +509,7 @@ const myf log_write_flags= MY_WME | MY_NABP | MY_WAIT_IF_FULL;
static void loghandler_init() static void loghandler_init()
{ {
int i;
log_record_type_descriptor[LOGREC_RESERVED_FOR_CHUNKS23]= log_record_type_descriptor[LOGREC_RESERVED_FOR_CHUNKS23]=
INIT_LOGREC_RESERVED_FOR_CHUNKS23; INIT_LOGREC_RESERVED_FOR_CHUNKS23;
log_record_type_descriptor[LOGREC_REDO_INSERT_ROW_HEAD]= log_record_type_descriptor[LOGREC_REDO_INSERT_ROW_HEAD]=
...@@ -488,6 +574,12 @@ static void loghandler_init() ...@@ -488,6 +574,12 @@ static void loghandler_init()
INIT_LOGREC_FILE_ID; INIT_LOGREC_FILE_ID;
log_record_type_descriptor[LOGREC_LONG_TRANSACTION_ID]= log_record_type_descriptor[LOGREC_LONG_TRANSACTION_ID]=
INIT_LOGREC_LONG_TRANSACTION_ID; INIT_LOGREC_LONG_TRANSACTION_ID;
for (i= LOGREC_LONG_TRANSACTION_ID + 1;
i < LOGREC_NUMBER_OF_TYPES;
i++)
log_record_type_descriptor[i].class= LOGRECTYPE_NOT_ALLOWED;
DBUG_EXECUTE("info",
check_translog_description_table(LOGREC_LONG_TRANSACTION_ID););
}; };
...@@ -2257,7 +2349,7 @@ static uchar *translog_get_page(TRANSLOG_VALIDATOR_DATA *data, uchar *buffer) ...@@ -2257,7 +2349,7 @@ static uchar *translog_get_page(TRANSLOG_VALIDATOR_DATA *data, uchar *buffer)
{ {
int is_last_unfinished_page; int is_last_unfinished_page;
uint last_protected_sector= 0; uint last_protected_sector= 0;
uchar *from, *table; uchar *from, *table= NULL;
translog_wait_for_writers(curr_buffer); translog_wait_for_writers(curr_buffer);
DBUG_ASSERT(LSN_FILE_NO(addr) == LSN_FILE_NO(curr_buffer->offset)); DBUG_ASSERT(LSN_FILE_NO(addr) == LSN_FILE_NO(curr_buffer->offset));
from= curr_buffer->buffer + (addr - curr_buffer->offset); from= curr_buffer->buffer + (addr - curr_buffer->offset);
......
...@@ -159,7 +159,7 @@ typedef struct st_translog_header_buffer ...@@ -159,7 +159,7 @@ typedef struct st_translog_header_buffer
/* in multi-group number of chunk0 pages (valid only if groups_no > 0) */ /* in multi-group number of chunk0 pages (valid only if groups_no > 0) */
uint chunk0_pages; uint chunk0_pages;
/* type of the read record */ /* type of the read record */
enum translog_record_type type; enum translog_record_type type;
/* chunk 0 data address (valid only if groups_no > 0) */ /* chunk 0 data address (valid only if groups_no > 0) */
TRANSLOG_ADDRESS chunk0_data_addr; TRANSLOG_ADDRESS chunk0_data_addr;
/* /*
......
...@@ -183,6 +183,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -183,6 +183,8 @@ int main(int argc __attribute__((unused)), char *argv[])
exit(1); exit(1);
} }
example_loghandler_init(); example_loghandler_init();
/* Suppressing of automatic record writing */
trn->first_undo_lsn|= TRANSACTION_LOGGED_LONG_ID;
plan(((ITERATIONS - 1) * 4 + 1)*2 + ITERATIONS - 1); plan(((ITERATIONS - 1) * 4 + 1)*2 + ITERATIONS - 1);
......
...@@ -72,6 +72,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -72,6 +72,8 @@ int main(int argc __attribute__((unused)), char *argv[])
exit(1); exit(1);
} }
example_loghandler_init(); example_loghandler_init();
/* Suppressing of automatic record writing */
dummy_transaction_object.first_undo_lsn|= TRANSACTION_LOGGED_LONG_ID;
theor_lsn= translog_first_theoretical_lsn(); theor_lsn= translog_first_theoretical_lsn();
if (theor_lsn == 1) if (theor_lsn == 1)
......
...@@ -66,6 +66,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -66,6 +66,8 @@ int main(int argc __attribute__((unused)), char *argv[])
exit(1); exit(1);
} }
example_loghandler_init(); example_loghandler_init();
/* Suppressing of automatic record writing */
dummy_transaction_object.first_undo_lsn|= TRANSACTION_LOGGED_LONG_ID;
max_lsn= translog_get_file_max_lsn_stored(1); max_lsn= translog_get_file_max_lsn_stored(1);
if (max_lsn == 1) if (max_lsn == 1)
......
...@@ -179,6 +179,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -179,6 +179,8 @@ int main(int argc __attribute__((unused)), char *argv[])
exit(1); exit(1);
} }
example_loghandler_init(); example_loghandler_init();
/* Suppressing of automatic record writing */
trn->first_undo_lsn|= TRANSACTION_LOGGED_LONG_ID;
plan(((ITERATIONS - 1) * 4 + 1) * 2); plan(((ITERATIONS - 1) * 4 + 1) * 2);
......
...@@ -289,6 +289,8 @@ int main(int argc __attribute__((unused)), ...@@ -289,6 +289,8 @@ int main(int argc __attribute__((unused)),
exit(1); exit(1);
} }
example_loghandler_init(); example_loghandler_init();
/* Suppressing of automatic record writing */
dummy_transaction_object.first_undo_lsn|= TRANSACTION_LOGGED_LONG_ID;
srandom(122334817L); srandom(122334817L);
{ {
......
...@@ -74,7 +74,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -74,7 +74,8 @@ int main(int argc __attribute__((unused)), char *argv[])
exit(1); exit(1);
} }
example_loghandler_init(); example_loghandler_init();
/* Suppressing of automatic record writing */
dummy_transaction_object.first_undo_lsn|= TRANSACTION_LOGGED_LONG_ID;
int4store(long_tr_id, 0); int4store(long_tr_id, 0);
long_tr_id[5]= 0xff; long_tr_id[5]= 0xff;
......
...@@ -74,6 +74,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -74,6 +74,8 @@ int main(int argc __attribute__((unused)), char *argv[])
exit(1); exit(1);
} }
example_loghandler_init(); example_loghandler_init();
/* Suppressing of automatic record writing */
dummy_transaction_object.first_undo_lsn|= TRANSACTION_LOGGED_LONG_ID;
if ((stat= my_stat(first_translog_file, &st, MYF(0))) == 0) if ((stat= my_stat(first_translog_file, &st, MYF(0))) == 0)
{ {
......
...@@ -69,6 +69,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -69,6 +69,8 @@ int main(int argc __attribute__((unused)), char *argv[])
exit(1); exit(1);
} }
example_loghandler_init(); example_loghandler_init();
/* Suppressing of automatic record writing */
dummy_transaction_object.first_undo_lsn|= TRANSACTION_LOGGED_LONG_ID;
/* write more then 1 file */ /* write more then 1 file */
int4store(long_tr_id, 0); int4store(long_tr_id, 0);
......
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