Commit 6196e6ef authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

cleanup recovery fprintf strings refs[t:2177]

git-svn-id: file:///svn/toku/tokudb@15870 c7de825b-a66e-492c-adef-691d508d4ae1
parent 441c408d
...@@ -73,7 +73,7 @@ static int lc_check_lsn(TOKULOGCURSOR lc, int dir) { ...@@ -73,7 +73,7 @@ static int lc_check_lsn(TOKULOGCURSOR lc, int dir) {
// int index = lc->cur_logfiles_index; // int index = lc->cur_logfiles_index;
// fprintf(stderr, "Bad LSN: %d %s direction = %d, lsn.lsn = %"PRIu64", cur_lsn.lsn=%"PRIu64"\n", // fprintf(stderr, "Bad LSN: %d %s direction = %d, lsn.lsn = %"PRIu64", cur_lsn.lsn=%"PRIu64"\n",
// index, lc->logfiles[index], dir, lsn.lsn, lc->cur_lsn.lsn); // index, lc->logfiles[index], dir, lsn.lsn, lc->cur_lsn.lsn);
if (toku_recover_trace) if (tokudb_recovery_trace)
printf("DB_RUNRECOVERY: %s:%d r=%d\n", __FUNCTION__, __LINE__, 0); printf("DB_RUNRECOVERY: %s:%d r=%d\n", __FUNCTION__, __LINE__, 0);
return LC_LSN_ERROR; return LC_LSN_ERROR;
} }
......
...@@ -7,7 +7,9 @@ ...@@ -7,7 +7,9 @@
#include "log_header.h" #include "log_header.h"
#include "checkpoint.h" #include "checkpoint.h"
int toku_recover_trace = 0; int tokudb_recovery_trace = 0;
#define TOKUDB_RECOVERY "Tokudb recovery"
//#define DO_VERIFY_COUNTS //#define DO_VERIFY_COUNTS
#ifdef DO_VERIFY_COUNTS #ifdef DO_VERIFY_COUNTS
...@@ -85,8 +87,8 @@ static void file_map_close_dictionaries(struct file_map *fmap, BOOL recovery_suc ...@@ -85,8 +87,8 @@ static void file_map_close_dictionaries(struct file_map *fmap, BOOL recovery_suc
DB *fake_db = tuple->brt->db; //Need to free the fake db that was malloced DB *fake_db = tuple->brt->db; //Need to free the fake db that was malloced
r = toku_close_brt(tuple->brt, &error_string); r = toku_close_brt(tuple->brt, &error_string);
if (!recovery_succeeded) { if (!recovery_succeeded) {
if (toku_recover_trace) if (tokudb_recovery_trace)
printf("%s:%d %d %s\n", __FUNCTION__, __LINE__, r, error_string); fprintf(stderr, "%s:%d %d %s\n", __FUNCTION__, __LINE__, r, error_string);
assert(r != 0); assert(r != 0);
} else } else
assert(r == 0); assert(r == 0);
...@@ -163,8 +165,8 @@ static int recover_env_init (RECOVER_ENV renv, brt_compare_func bt_compare, brt_ ...@@ -163,8 +165,8 @@ static int recover_env_init (RECOVER_ENV renv, brt_compare_func bt_compare, brt_
file_map_init(&renv->fmap); file_map_init(&renv->fmap);
renv->goforward = FALSE; renv->goforward = FALSE;
if (toku_recover_trace) if (tokudb_recovery_trace)
printf("%s:%d\n", __FUNCTION__, __LINE__); fprintf(stderr, "%s:%d\n", __FUNCTION__, __LINE__);
return r; return r;
} }
...@@ -180,8 +182,8 @@ static void recover_env_cleanup (RECOVER_ENV renv, BOOL recovery_succeeded) { ...@@ -180,8 +182,8 @@ static void recover_env_cleanup (RECOVER_ENV renv, BOOL recovery_succeeded) {
r = toku_cachetable_close(&renv->ct); r = toku_cachetable_close(&renv->ct);
assert(r == 0); assert(r == 0);
if (toku_recover_trace) if (tokudb_recovery_trace)
printf("%s:%d\n", __FUNCTION__, __LINE__); fprintf(stderr, "%s:%d\n", __FUNCTION__, __LINE__);
} }
// Null function supplied to transaction commit and abort // Null function supplied to transaction commit and abort
...@@ -253,7 +255,7 @@ static void create_dir_from_file (const char *fname) { ...@@ -253,7 +255,7 @@ static void create_dir_from_file (const char *fname) {
mode_t oldu = umask(0); mode_t oldu = umask(0);
int r = toku_os_mkdir(tmp, S_IRWXU); int r = toku_os_mkdir(tmp, S_IRWXU);
if (r!=0 && errno!=EEXIST) { if (r!=0 && errno!=EEXIST) {
printf("error: %s\n", strerror(errno)); fprintf(stderr, "error: %s\n", strerror(errno));
} }
assert (r == 0 || (errno==EEXIST)); assert (r == 0 || (errno==EEXIST));
umask(oldu); umask(oldu);
...@@ -290,7 +292,7 @@ static int internal_toku_recover_fopen_or_fcreate (RECOVER_ENV renv, int flags, ...@@ -290,7 +292,7 @@ static int internal_toku_recover_fopen_or_fcreate (RECOVER_ENV renv, int flags,
// maybe unlink // maybe unlink
r = unlink(fixedfname); r = unlink(fixedfname);
if (r != 0 && errno != ENOENT) { if (r != 0 && errno != ENOENT) {
printf("%s:%d unlink %d\n", __FUNCTION__, __LINE__, errno); fprintf(stderr, "%s:%d unlink %d\n", __FUNCTION__, __LINE__, errno);
return r; return r;
} }
} }
...@@ -682,12 +684,12 @@ static int toku_recover_backward_xbegin (struct logtype_xbegin *l, RECOVER_ENV r ...@@ -682,12 +684,12 @@ static int toku_recover_backward_xbegin (struct logtype_xbegin *l, RECOVER_ENV r
assert(ss->n_live_txns > 0); // the only thing we are doing here is looking for a live txn, so there better be one assert(ss->n_live_txns > 0); // the only thing we are doing here is looking for a live txn, so there better be one
// If we got to the min, return nonzero // If we got to the min, return nonzero
if (ss->min_live_txn >= l->lsn.lsn) { if (ss->min_live_txn >= l->lsn.lsn) {
if (toku_recover_trace) if (tokudb_recovery_trace)
fprintf(stderr, "Tokudb recovery turning around at xbegin %" PRIu64 "\n", l->lsn.lsn); fprintf(stderr, "Tokudb recovery turning around at xbegin %" PRIu64 "\n", l->lsn.lsn);
renv->goforward = TRUE; renv->goforward = TRUE;
return 0; return 0;
} else { } else {
if (toku_recover_trace) if (tokudb_recovery_trace)
fprintf(stderr, "Tokudb recovery scanning back at xbegin %" PRIu64 " (looking for %" PRIu64 ")\n", l->lsn.lsn, ss->min_live_txn); fprintf(stderr, "Tokudb recovery scanning back at xbegin %" PRIu64 " (looking for %" PRIu64 ")\n", l->lsn.lsn, ss->min_live_txn);
return 0; return 0;
} }
...@@ -818,6 +820,14 @@ static void recover_abort_live_txns(RECOVER_ENV renv) { ...@@ -818,6 +820,14 @@ static void recover_abort_live_txns(RECOVER_ENV renv) {
} }
} }
static void recover_trace_le(const char *f, int l, int r, struct log_entry *le) {
if (le) {
LSN thislsn = toku_log_entry_get_lsn(le);
fprintf(stderr, "%s:%d r=%d cmd=%c lsn=%"PRIu64"\n", f, l, r, le->cmd, thislsn.lsn);
} else
fprintf(stderr, "%s:%d r=%d cmd=?\n", f, l, r);
}
static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_dir) { static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_dir) {
int r; int r;
int rr = 0; int rr = 0;
...@@ -830,7 +840,6 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di ...@@ -830,7 +840,6 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di
{ {
char *wd=getcwd(org_wd, sizeof(org_wd)); char *wd=getcwd(org_wd, sizeof(org_wd));
assert(wd!=0); assert(wd!=0);
//printf("%s:%d org_wd=\"%s\"\n", __FILE__, __LINE__, org_wd);
} }
r = toku_logger_open(log_dir, renv->logger); r = toku_logger_open(log_dir, renv->logger);
...@@ -845,8 +854,8 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di ...@@ -845,8 +854,8 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di
r = toku_logcursor_last(logcursor, &le); r = toku_logcursor_last(logcursor, &le);
if (r != 0) { if (r != 0) {
if (toku_recover_trace) if (tokudb_recovery_trace)
printf("RUNRECOVERY: %s:%d r=%d\n", __FUNCTION__, __LINE__, r); fprintf(stderr, "RUNRECOVERY: %s:%d r=%d\n", __FUNCTION__, __LINE__, r);
rr = DB_RUNRECOVERY; goto errorexit; rr = DB_RUNRECOVERY; goto errorexit;
} }
...@@ -869,8 +878,8 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di ...@@ -869,8 +878,8 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di
while (1) { while (1) {
le = NULL; le = NULL;
r = toku_logcursor_prev(logcursor, &le); r = toku_logcursor_prev(logcursor, &le);
if (toku_recover_trace) if (tokudb_recovery_trace)
printf("%s:%d r=%d cmd=%c\n", __FUNCTION__, __LINE__, r, le ? le->cmd : '?'); recover_trace_le(__FUNCTION__, __LINE__, r, le);
if (r != 0) { if (r != 0) {
if (r == DB_RUNRECOVERY) { if (r == DB_RUNRECOVERY) {
rr = DB_RUNRECOVERY; goto errorexit; rr = DB_RUNRECOVERY; goto errorexit;
...@@ -878,20 +887,20 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di ...@@ -878,20 +887,20 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di
break; break;
} }
logtype_dispatch_assign(le, toku_recover_backward_, r, renv); logtype_dispatch_assign(le, toku_recover_backward_, r, renv);
if (toku_recover_trace) if (tokudb_recovery_trace)
printf("%s:%d r=%d cmd=%c\n", __FUNCTION__, __LINE__, r, le ? le->cmd : '?'); recover_trace_le(__FUNCTION__, __LINE__, r, le);
if (r != 0) { if (r != 0) {
if (toku_recover_trace) if (tokudb_recovery_trace)
printf("DB_RUNRECOVERY: %s:%d r=%d\n", __FUNCTION__, __LINE__, r); fprintf(stderr, "DB_RUNRECOVERY: %s:%d r=%d\n", __FUNCTION__, __LINE__, r);
rr = DB_RUNRECOVERY; goto errorexit; rr = DB_RUNRECOVERY; goto errorexit;
} }
if (renv->goforward) { if (renv->goforward) {
logtype_dispatch_assign(le, toku_recover_, r, renv); logtype_dispatch_assign(le, toku_recover_, r, renv);
if (toku_recover_trace) if (tokudb_recovery_trace)
printf("%s:%d r=%d cmd=%c\n", __FUNCTION__, __LINE__, r, le ? le->cmd : '?'); recover_trace_le(__FUNCTION__, __LINE__, r, le);
if (r != 0) { if (r != 0) {
if (toku_recover_trace) if (tokudb_recovery_trace)
printf("DB_RUNRECOVERY: %s:%d r=%d\n", __FUNCTION__, __LINE__, r); fprintf(stderr, "DB_RUNRECOVERY: %s:%d r=%d\n", __FUNCTION__, __LINE__, r);
rr = DB_RUNRECOVERY; goto errorexit; rr = DB_RUNRECOVERY; goto errorexit;
} }
break; break;
...@@ -899,13 +908,13 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di ...@@ -899,13 +908,13 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di
} }
// scan forwards // scan forwards
LSN lsn = toku_log_entry_get_lsn(le); LSN thislsn = toku_log_entry_get_lsn(le);
fprintf(stderr, "Tokudb recovery scanning forward from %"PRIu64"\n", lsn.lsn); fprintf(stderr, "Tokudb recovery scanning forward from %"PRIu64"\n", thislsn.lsn);
while (1) { while (1) {
le = NULL; le = NULL;
r = toku_logcursor_next(logcursor, &le); r = toku_logcursor_next(logcursor, &le);
if (toku_recover_trace) if (tokudb_recovery_trace)
printf("%s:%d r=%d cmd=%c\n", __FUNCTION__, __LINE__, r, le ? le->cmd : '?'); recover_trace_le(__FUNCTION__, __LINE__, r, le);
if (r != 0) { if (r != 0) {
if (r == DB_RUNRECOVERY) { if (r == DB_RUNRECOVERY) {
rr = DB_RUNRECOVERY; goto errorexit; rr = DB_RUNRECOVERY; goto errorexit;
...@@ -913,11 +922,11 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di ...@@ -913,11 +922,11 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di
break; break;
} }
logtype_dispatch_assign(le, toku_recover_, r, renv); logtype_dispatch_assign(le, toku_recover_, r, renv);
if (toku_recover_trace) if (tokudb_recovery_trace)
printf("%s:%d r=%d cmd=%c\n", __FUNCTION__, __LINE__, r, le ? le->cmd : '?'); recover_trace_le(__FUNCTION__, __LINE__, r, le);
if (r != 0) { if (r != 0) {
if (toku_recover_trace) if (tokudb_recovery_trace)
printf("DB_RUNRECOVERY: %s:%d r=%d\n", __FUNCTION__, __LINE__, r); fprintf(stderr, "DB_RUNRECOVERY: %s:%d r=%d\n", __FUNCTION__, __LINE__, r);
rr = DB_RUNRECOVERY; goto errorexit; rr = DB_RUNRECOVERY; goto errorexit;
} }
} }
...@@ -976,7 +985,7 @@ static int recover_lock(const char *lock_dir, int *lockfd) { ...@@ -976,7 +985,7 @@ static int recover_lock(const char *lock_dir, int *lockfd) {
*lockfd = toku_os_lock_file(lockfname); *lockfd = toku_os_lock_file(lockfname);
if (*lockfd < 0) { if (*lockfd < 0) {
int e = errno; int e = errno;
printf("Couldn't run recovery because some other process holds the recovery lock %s\n", lockfname); fprintf(stderr, "Couldn't run recovery because some other process holds the recovery lock %s\n", lockfname);
return e; return e;
} }
return 0; return 0;
......
...@@ -32,6 +32,6 @@ int tokudb_recover_delete_rolltmp_files(const char *datadir, const char *logdir) ...@@ -32,6 +32,6 @@ int tokudb_recover_delete_rolltmp_files(const char *datadir, const char *logdir)
int tokudb_recover_log_exists(const char * log_dir); int tokudb_recover_log_exists(const char * log_dir);
extern int toku_recover_trace; extern int tokudb_recovery_trace;
#endif // TOKURECOVER_H #endif // TOKURECOVER_H
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