Commit e73a7f83 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

test some recovery error paths closes[t:2199]

git-svn-id: file:///svn/toku/tokudb@15979 c7de825b-a66e-492c-adef-691d508d4ae1
parent 87bbf72c
......@@ -576,6 +576,8 @@ static int toku_recover_begin_checkpoint (struct logtype_begin_checkpoint *UU(l)
case SS_FORWARD_SAW_CKPT:
assert(l->lsn.lsn > ss->checkpoint_lsn.lsn);
return 0; // ignore it
case SS_INIT:
return 0; // ignore it (log only has a begin checkpoint)
default:
break;
}
......@@ -932,7 +934,10 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di
}
// scan forwards
thislsn = toku_log_entry_get_lsn(le);
if (le)
thislsn = toku_log_entry_get_lsn(le);
else
thislsn = ZERO_LSN;
tnow = time(NULL);
fprintf(stderr, "%.24s Tokudb recovery (%s) scanning forward to %"PRIu64" from %"PRIu64" left %"PRIu64"\n", ctime(&tnow), recover_state(renv), lastlsn.lsn, thislsn.lsn, lastlsn.lsn - thislsn.lsn);
for (unsigned i=0; 1; i++) {
......@@ -1021,6 +1026,9 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di
}
static int recover_lock(const char *lock_dir, int *lockfd) {
if (!lock_dir)
return ENOENT;
const char fname[] = "/__tokudb_recoverylock_dont_delete_me";
int namelen=strlen(lock_dir);
char lockfname[namelen+sizeof(fname)];
......
......@@ -92,6 +92,14 @@ REGRESSION_TESTS_RAW = \
minicron-test \
omt-cursor-test \
omt-test \
recovery-begin-checkpoint \
recovery-begin-end-checkpoint \
recovery-begin-end-checkpoint-hello \
recovery-empty \
recovery-hello \
recovery-no-datadir \
recovery-no-log \
recovery-no-logdir \
shortcut \
test1308a \
test-assert \
......@@ -180,7 +188,7 @@ benchmark-test.$(OEXT): ../brt.h ../brt-search.h ../../include/db.h
clean:
rm -rf log-test7.c.dir_*
rm -rf *.dir
rm -rf *.dir dir.*
rm -f cachetable-fd-test.ctest2.data test_oexcl.c.tmp
rm -f *.brt *.clean *.dirty *.tdb *.dat *.data *.out *.check.valgrind
......
#include "test.h"
#include "includes.h"
#define TESTDIR "dir." __FILE__
static int
run_test(void) {
int r;
// setup the test dir
system("rm -rf " TESTDIR);
r = toku_os_mkdir(TESTDIR, S_IRWXU); assert(r == 0);
// create the log
TOKULOGGER logger;
r = toku_logger_create(&logger); assert(r == 0);
r = toku_logger_open(TESTDIR, logger); assert(r == 0);
LSN beginlsn;
r = toku_log_begin_checkpoint(logger, &beginlsn, TRUE, 0); assert(r == 0);
r = toku_logger_close(&logger); assert(r == 0);
// run recovery
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, 0);
printf("%s:%d %d\n", __FUNCTION__, __LINE__, r);
assert(r == 0);
return 0;
}
int
test_main(int UU(argc), const char *UU(argv[])) {
int r;
r = run_test();
return r;
}
#include "test.h"
#include "includes.h"
#define TESTDIR "dir." __FILE__
static int
run_test(void) {
int r;
// setup the test dir
system("rm -rf " TESTDIR);
r = toku_os_mkdir(TESTDIR, S_IRWXU); assert(r == 0);
// create the log
TOKULOGGER logger;
r = toku_logger_create(&logger); assert(r == 0);
r = toku_logger_open(TESTDIR, logger); assert(r == 0);
// add begin checkpoint, end checkpoint
LSN beginlsn;
r = toku_log_begin_checkpoint(logger, &beginlsn, FALSE, 0); assert(r == 0);
r = toku_log_end_checkpoint(logger, NULL, TRUE, beginlsn.lsn, 0); assert(r == 0);
r = toku_logger_close(&logger); assert(r == 0);
// add hello
for (int i=0; i<2; i++) {
r = toku_logger_create(&logger); assert(r == 0);
r = toku_logger_open(TESTDIR, logger); assert(r == 0);
BYTESTRING hello = { strlen("hello"), "hello" };
r = toku_log_comment(logger, NULL, TRUE, 0, hello);
r = toku_logger_close(&logger); assert(r == 0);
}
// run recovery
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, 0);
assert(r == 0);
return 0;
}
int
test_main(int UU(argc), const char *UU(argv[])) {
int r;
r = run_test();
return r;
}
#include "test.h"
#include "includes.h"
#define TESTDIR "dir." __FILE__
static int
run_test(void) {
int r;
// setup the test dir
system("rm -rf " TESTDIR);
r = toku_os_mkdir(TESTDIR, S_IRWXU); assert(r == 0);
// put begin and end checkpoint into separate log files
TOKULOGGER logger;
r = toku_logger_create(&logger); assert(r == 0);
r = toku_logger_open(TESTDIR, logger); assert(r == 0);
LSN beginlsn;
r = toku_log_begin_checkpoint(logger, &beginlsn, FALSE, 0); assert(r == 0);
r = toku_logger_close(&logger); assert(r == 0);
r = toku_logger_create(&logger); assert(r == 0);
r = toku_logger_open(TESTDIR, logger); assert(r == 0);
r = toku_log_end_checkpoint(logger, NULL, TRUE, beginlsn.lsn, 0); assert(r == 0);
r = toku_logger_close(&logger); assert(r == 0);
// run recovery
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, 0);
assert(r == 0);
return 0;
}
int
test_main(int UU(argc), const char *UU(argv[])) {
int r;
r = run_test();
return r;
}
// test recovery from a log that exist but has no log entries
#include "test.h"
#include "includes.h"
#define TESTDIR "dir." __FILE__
static int
run_test(void) {
int r;
// setup the test dir
system("rm -rf " TESTDIR);
r = toku_os_mkdir(TESTDIR, S_IRWXU); assert(r == 0);
// create the log
TOKULOGGER logger;
r = toku_logger_create(&logger); assert(r == 0);
r = toku_logger_open(TESTDIR, logger); assert(r == 0);
r = toku_logger_close(&logger); assert(r == 0);
// run recovery
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, 0);
assert(r == DB_RUNRECOVERY);
return 0;
}
int
test_main(int UU(argc), const char *UU(argv[])) {
int r;
r = run_test();
return r;
}
#include "test.h"
#include "includes.h"
#define TESTDIR "dir." __FILE__
static int
run_test(void) {
int r;
// setup the test dir
system("rm -rf " TESTDIR);
r = toku_os_mkdir(TESTDIR, S_IRWXU); assert(r == 0);
// create the log
TOKULOGGER logger;
r = toku_logger_create(&logger); assert(r == 0);
r = toku_logger_open(TESTDIR, logger); assert(r == 0);
BYTESTRING hello = { strlen("hello"), "hello" };
r = toku_log_comment(logger, NULL, TRUE, 0, hello);
r = toku_logger_close(&logger); assert(r == 0);
// run recovery
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, 0);
assert(r == 0);
return 0;
}
int
test_main(int UU(argc), const char *UU(argv[])) {
int r;
r = run_test();
return r;
}
#include "test.h"
#include "includes.h"
#define TESTDIR "dir." __FILE__
static int
run_test(void) {
int r;
// setup the test dir
system("rm -rf " TESTDIR);
r = toku_os_mkdir(TESTDIR, S_IRWXU); assert(r == 0);
// create the log
TOKULOGGER logger;
r = toku_logger_create(&logger); assert(r == 0);
r = toku_logger_open(TESTDIR, logger); assert(r == 0);
BYTESTRING hello = { strlen("hello"), "hello" };
r = toku_log_comment(logger, NULL, TRUE, 0, hello);
r = toku_logger_close(&logger); assert(r == 0);
// run recovery
r = tokudb_recover(NULL, TESTDIR, 0, 0, 0);
assert(r != 0);
return 0;
}
int
test_main(int UU(argc), const char *UU(argv[])) {
int r;
r = run_test();
return r;
}
#include "test.h"
#include "includes.h"
#define TESTDIR "dir." __FILE__
static int
run_test(void) {
int r;
// setup the test dir
system("rm -rf " TESTDIR);
r = toku_os_mkdir(TESTDIR, S_IRWXU); assert(r == 0);
// run recovery
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, 0);
assert(r != 0);
return 0;
}
int
test_main(int UU(argc), const char *UU(argv[])) {
int r;
r = run_test();
return r;
}
#include "test.h"
#include "includes.h"
#define TESTDIR "dir." __FILE__
static int
run_test(void) {
int r;
// setup the test dir
system("rm -rf " TESTDIR);
r = toku_os_mkdir(TESTDIR, S_IRWXU); assert(r == 0);
// run recovery
r = tokudb_recover(NULL, NULL, 0, 0, 0);
assert(r != 0);
return 0;
}
int
test_main(int UU(argc), const char *UU(argv[])) {
int r;
r = run_test();
return r;
}
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