diff options
author | unknown <guilhem@gbichot3.local> | 2007-06-26 16:49:23 +0200 |
---|---|---|
committer | unknown <guilhem@gbichot3.local> | 2007-06-26 16:49:23 +0200 |
commit | adac9798bff81a682b346f438eb7b58264b1b541 (patch) | |
tree | 383c7bc6ee4d81c714bf92c7dd72a3fae0bef3a2 /storage/maria/unittest | |
parent | bb8bde8f931ec934b1926489da5b2fb087105f6e (diff) | |
download | mariadb-git-adac9798bff81a682b346f438eb7b58264b1b541.tar.gz |
WL#3072 Maria Recovery
- new program maria_read_log to display and apply log records
found in a Maria log (see file's revision comment)
- minor, misc fixes
storage/maria/Makefile.am:
new program maria_read_log
storage/maria/ha_maria.cc:
create control file if missing
storage/maria/ma_blockrec.c:
0 -> LSN_IMPOSSIBLE; comments
storage/maria/ma_checkpoint.h:
preparations for Checkpoint module
storage/maria/ma_close.c:
comment
storage/maria/ma_control_file.c:
renaming constants.
Possibility to say "open control file but don't create it if it's
missing" (used by maria_read_log which does not want to create
anything)
storage/maria/ma_control_file.h:
renaming constants
storage/maria/ma_create.c:
I had duplicated "linkname" and "linkname_ptr", now I see it's not
needed, reverting. Indeed those variables don't contain interesting
information; fixing log record accordingly (the links are in
ci->data/index_file_name). Storing keystart in log record is needed,
to know at which size we must extend the file if we replay
LOGREC_CREATE_TABLE.
storage/maria/ma_loghandler.c:
some structures need to be known to maria_read_log.c, taking
them to ma_loghandler.h
storage/maria/ma_loghandler.h:
we have page_store, adding page_korr.
translog_lock() made public, because Checkpoint will need it (to
write to control file).
Some structures moved from ma_loghandler.c because maria_read_log.c
needs them (needs to know the execute-in-REDO-phase hooks of each
record).
storage/maria/ma_loghandler_lsn.h:
constants defined in ma_control_file.h serve everywhere,
and they relate to LSNs, so putting them in ma_loghandler_lsn.h.
Stronger constraints in LSN_VALID().
storage/maria/ma_pagecache.c:
renaming constants
storage/maria/ma_recovery.h:
copyright
storage/maria/ma_test1.c:
new prototype
storage/maria/ma_test2.c:
new prototype
storage/maria/trnman_public.h:
double-inclusion safe
storage/maria/unittest/ma_control_file-t.c:
constants renamed, new prototype
storage/maria/unittest/ma_test_loghandler-t.c:
constants renamed, new prototype
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
constants renamed, new prototype
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
constants renamed, new prototype
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
constants renamed, new prototype
storage/myisam/mi_close.c:
comment
storage/maria/maria_read_log.c:
program to read and print log records from a Maria transaction log,
and optionally apply them to tables. Very basic, early version.
Should serve as a base for Recovery's code. Designed to be idempotent.
Create a log by running maria.test, then cd to var/master-data
and run "maria_read_log --only-display" to see info about records;
run "maria_read_log --display-and-apply" to also apply the records
to tables (it's more interesting if you first wipe out the
tables in var/master-data/test, to see how they get re-created).
Only a few records are handled by now: LONG_TRANSACTION_ID,
COMMIT, FILE_ID, REDO_CREATE_TABLE; place is ready for
REDO_INSERT_ROW_HEAD where I could use Monty's help (search for
"Monty" in the file). Note: changes to the index pages, index's header
and bitmap pages are not properly logged yet, so don't expect
the program to work with that.
Diffstat (limited to 'storage/maria/unittest')
5 files changed, 25 insertions, 24 deletions
diff --git a/storage/maria/unittest/ma_control_file-t.c b/storage/maria/unittest/ma_control_file-t.c index 71a1157f1ba..a7472361dad 100644 --- a/storage/maria/unittest/ma_control_file-t.c +++ b/storage/maria/unittest/ma_control_file-t.c @@ -121,8 +121,8 @@ static int delete_file(myf my_flags) The error will however be printed on stderr. */ my_delete(file_name, my_flags); - expect_checkpoint_lsn= CONTROL_FILE_IMPOSSIBLE_LSN; - expect_logno= CONTROL_FILE_IMPOSSIBLE_FILENO; + expect_checkpoint_lsn= LSN_IMPOSSIBLE; + expect_logno= FILENO_IMPOSSIBLE; return 0; } @@ -146,9 +146,9 @@ static int verify_module_values_match_expected() */ static int verify_module_values_are_impossible() { - RET_ERR_UNLESS(last_logno == CONTROL_FILE_IMPOSSIBLE_FILENO); + RET_ERR_UNLESS(last_logno == FILENO_IMPOSSIBLE); RET_ERR_UNLESS(last_checkpoint_lsn == - CONTROL_FILE_IMPOSSIBLE_LSN); + LSN_IMPOSSIBLE); return 0; } @@ -164,7 +164,7 @@ static int close_file() static int create_or_open_file() { - RET_ERR_UNLESS(ma_control_file_create_or_open() == CONTROL_FILE_OK); + RET_ERR_UNLESS(ma_control_file_create_or_open(TRUE) == CONTROL_FILE_OK); /* Check that the module reports expected information */ RET_ERR_UNLESS(verify_module_values_match_expected() == 0); return 0; @@ -188,7 +188,7 @@ static int test_one_log() RET_ERR_UNLESS(create_or_open_file() == CONTROL_FILE_OK); objs_to_write= CONTROL_FILE_UPDATE_ONLY_LOGNO; expect_logno= 123; - RET_ERR_UNLESS(write_file(CONTROL_FILE_IMPOSSIBLE_LSN, + RET_ERR_UNLESS(write_file(LSN_IMPOSSIBLE, expect_logno, objs_to_write) == 0); RET_ERR_UNLESS(close_file() == 0); @@ -206,7 +206,7 @@ static int test_five_logs() for (i= 0; i<5; i++) { expect_logno*= 3; - RET_ERR_UNLESS(write_file(CONTROL_FILE_IMPOSSIBLE_LSN, expect_logno, + RET_ERR_UNLESS(write_file(LSN_IMPOSSIBLE, expect_logno, objs_to_write) == 0); } RET_ERR_UNLESS(close_file() == 0); @@ -320,7 +320,7 @@ static int test_bad_magic_string() RET_ERR_UNLESS(my_pwrite(fd, "papa", 4, 0, MYF(MY_FNABP | MY_WME)) == 0); /* Check that control file module sees the problem */ - RET_ERR_UNLESS(ma_control_file_create_or_open() == + RET_ERR_UNLESS(ma_control_file_create_or_open(TRUE) == CONTROL_FILE_BAD_MAGIC_STRING); /* Restore magic string */ RET_ERR_UNLESS(my_pwrite(fd, buffer, 4, 0, MYF(MY_FNABP | MY_WME)) == 0); @@ -346,7 +346,7 @@ static int test_bad_checksum() buffer[0]+= 3; /* mangle checksum */ RET_ERR_UNLESS(my_pwrite(fd, buffer, 1, 8, MYF(MY_FNABP | MY_WME)) == 0); /* Check that control file module sees the problem */ - RET_ERR_UNLESS(ma_control_file_create_or_open() == + RET_ERR_UNLESS(ma_control_file_create_or_open(TRUE) == CONTROL_FILE_BAD_CHECKSUM); /* Restore checksum */ buffer[0]-= 3; @@ -369,10 +369,11 @@ static int test_bad_size() MYF(MY_WME))) >= 0); RET_ERR_UNLESS(my_write(fd, buffer, 10, MYF(MY_FNABP | MY_WME)) == 0); /* Check that control file module sees the problem */ - RET_ERR_UNLESS(ma_control_file_create_or_open() == CONTROL_FILE_TOO_SMALL); + RET_ERR_UNLESS(ma_control_file_create_or_open(TRUE) == + CONTROL_FILE_TOO_SMALL); RET_ERR_UNLESS(my_write(fd, buffer, 30, MYF(MY_FNABP | MY_WME)) == 0); /* Check that control file module sees the problem */ - RET_ERR_UNLESS(ma_control_file_create_or_open() == CONTROL_FILE_TOO_BIG); + RET_ERR_UNLESS(ma_control_file_create_or_open(TRUE) == CONTROL_FILE_TOO_BIG); RET_ERR_UNLESS(my_close(fd, MYF(MY_WME)) == 0); /* Leave a correct control file */ diff --git a/storage/maria/unittest/ma_test_loghandler-t.c b/storage/maria/unittest/ma_test_loghandler-t.c index e31136d52ec..19e6704dc5a 100644 --- a/storage/maria/unittest/ma_test_loghandler-t.c +++ b/storage/maria/unittest/ma_test_loghandler-t.c @@ -164,7 +164,7 @@ int main(int argc __attribute__((unused)), char *argv[]) } #endif - if (ma_control_file_create_or_open()) + if (ma_control_file_create_or_open(TRUE)) { fprintf(stderr, "Can't init control file (%d)\n", errno); exit(1); @@ -336,7 +336,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ma_control_file_end(); - if (ma_control_file_create_or_open()) + if (ma_control_file_create_or_open(TRUE)) { fprintf(stderr, "pass2: Can't init control file (%d)\n", errno); exit(1); @@ -398,7 +398,7 @@ int main(int argc __attribute__((unused)), char *argv[]) i, errno); goto err; } - if (rec.lsn == CONTROL_FILE_IMPOSSIBLE_LSN) + if (rec.lsn == LSN_IMPOSSIBLE) { if (i != ITERATIONS) { @@ -477,7 +477,7 @@ int main(int argc __attribute__((unused)), char *argv[]) "failed (%d)\n", i, errno); goto err; } - if (rec.lsn == CONTROL_FILE_IMPOSSIBLE_LSN) + if (rec.lsn == LSN_IMPOSSIBLE) { fprintf(stderr, "EOL met at the middle of iteration (first var) %u " "instead of beginning of %u\n", i, ITERATIONS); @@ -572,7 +572,7 @@ int main(int argc __attribute__((unused)), char *argv[]) i, errno); goto err; } - if (rec.lsn == CONTROL_FILE_IMPOSSIBLE_LSN) + if (rec.lsn == LSN_IMPOSSIBLE) { fprintf(stderr, "EOL met at the middle of iteration %u " "instead of beginning of %u\n", i, ITERATIONS); diff --git a/storage/maria/unittest/ma_test_loghandler_multigroup-t.c b/storage/maria/unittest/ma_test_loghandler_multigroup-t.c index 1281ee425d8..5fe24be597d 100644 --- a/storage/maria/unittest/ma_test_loghandler_multigroup-t.c +++ b/storage/maria/unittest/ma_test_loghandler_multigroup-t.c @@ -161,7 +161,7 @@ int main(int argc __attribute__((unused)), char *argv[]) } #endif - if (ma_control_file_create_or_open()) + if (ma_control_file_create_or_open(TRUE)) { fprintf(stderr, "Can't init control file (%d)\n", errno); exit(1); @@ -325,7 +325,7 @@ int main(int argc __attribute__((unused)), char *argv[]) end_pagecache(&pagecache, 1); ma_control_file_end(); - if (ma_control_file_create_or_open()) + if (ma_control_file_create_or_open(TRUE)) { fprintf(stderr, "pass2: Can't init control file (%d)\n", errno); exit(1); @@ -390,7 +390,7 @@ int main(int argc __attribute__((unused)), char *argv[]) translog_free_record_header(&rec); goto err; } - if (rec.lsn == CONTROL_FILE_IMPOSSIBLE_LSN) + if (rec.lsn == LSN_IMPOSSIBLE) { if (i != ITERATIONS) { @@ -470,7 +470,7 @@ int main(int argc __attribute__((unused)), char *argv[]) "failed (%d)\n", i, errno); goto err; } - if (rec.lsn == CONTROL_FILE_IMPOSSIBLE_LSN) + if (rec.lsn == LSN_IMPOSSIBLE) { fprintf(stderr, "EOL met at the middle of iteration (first var) %u " "instead of beginning of %u\n", i, ITERATIONS); @@ -568,7 +568,7 @@ int main(int argc __attribute__((unused)), char *argv[]) translog_free_record_header(&rec); goto err; } - if (rec.lsn == CONTROL_FILE_IMPOSSIBLE_LSN) + if (rec.lsn == LSN_IMPOSSIBLE) { fprintf(stderr, "EOL met at the middle of iteration %u " "instead of beginning of %u\n", i, ITERATIONS); diff --git a/storage/maria/unittest/ma_test_loghandler_multithread-t.c b/storage/maria/unittest/ma_test_loghandler_multithread-t.c index ff966160acc..ba5d217a45a 100644 --- a/storage/maria/unittest/ma_test_loghandler_multithread-t.c +++ b/storage/maria/unittest/ma_test_loghandler_multithread-t.c @@ -270,7 +270,7 @@ int main(int argc __attribute__((unused)), my_thread_global_init(); - if (ma_control_file_create_or_open()) + if (ma_control_file_create_or_open(TRUE)) { fprintf(stderr, "Can't init control file (%d)\n", errno); exit(1); @@ -384,7 +384,7 @@ int main(int argc __attribute__((unused)), translog_free_record_header(&rec); goto err; } - if (rec.lsn == CONTROL_FILE_IMPOSSIBLE_LSN) + if (rec.lsn == LSN_IMPOSSIBLE) { if (i != WRITERS * ITERATIONS * 2) { diff --git a/storage/maria/unittest/ma_test_loghandler_pagecache-t.c b/storage/maria/unittest/ma_test_loghandler_pagecache-t.c index 35e05f9c997..4ac500ce8b2 100644 --- a/storage/maria/unittest/ma_test_loghandler_pagecache-t.c +++ b/storage/maria/unittest/ma_test_loghandler_pagecache-t.c @@ -56,7 +56,7 @@ int main(int argc __attribute__((unused)), char *argv[]) } #endif - if (ma_control_file_create_or_open()) + if (ma_control_file_create_or_open(TRUE)) { fprintf(stderr, "Can't init control file (%d)\n", errno); exit(1); |