Commit c5cded63 authored by Barry Perlman's avatar Barry Perlman Committed by Yoni Fogel

[t:2892] Improve comments.

git-svn-id: file:///svn/toku/tokudb@25736 c7de825b-a66e-492c-adef-691d508d4ae1
parent 51ec08ee
...@@ -22,6 +22,7 @@ toku_log_upgrade_get_footprint(void) { ...@@ -22,6 +22,7 @@ toku_log_upgrade_get_footprint(void) {
#define FOOTPRINTCAPTURE footprint+=function_footprint; #define FOOTPRINTCAPTURE footprint+=function_footprint;
// return 0 if clean shutdown, TOKUDB_UPGRADE_FAILURE if not clean shutdown
static int static int
verify_clean_shutdown_of_log_version_current(const char *log_dir, LSN * last_lsn) { verify_clean_shutdown_of_log_version_current(const char *log_dir, LSN * last_lsn) {
int rval = TOKUDB_UPGRADE_FAILURE; int rval = TOKUDB_UPGRADE_FAILURE;
...@@ -36,13 +37,13 @@ verify_clean_shutdown_of_log_version_current(const char *log_dir, LSN * last_lsn ...@@ -36,13 +37,13 @@ verify_clean_shutdown_of_log_version_current(const char *log_dir, LSN * last_lsn
struct log_entry *le = NULL; struct log_entry *le = NULL;
r = toku_logcursor_last(cursor, &le); r = toku_logcursor_last(cursor, &le);
if (r == 0) { if (r == 0) {
FOOTPRINT(2); FOOTPRINT(2);
if (le->cmd==LT_shutdown) { if (le->cmd==LT_shutdown) {
LSN lsn = le->u.shutdown.lsn; LSN lsn = le->u.shutdown.lsn;
if (last_lsn) if (last_lsn)
*last_lsn = lsn; *last_lsn = lsn;
rval = 0; rval = 0;
} }
} }
r = toku_logcursor_destroy(&cursor); r = toku_logcursor_destroy(&cursor);
assert(r == 0); assert(r == 0);
...@@ -51,6 +52,7 @@ verify_clean_shutdown_of_log_version_current(const char *log_dir, LSN * last_lsn ...@@ -51,6 +52,7 @@ verify_clean_shutdown_of_log_version_current(const char *log_dir, LSN * last_lsn
} }
// return 0 if clean shutdown, TOKUDB_UPGRADE_FAILURE if not clean shutdown
static int static int
verify_clean_shutdown_of_log_version_old(const char *log_dir, LSN * last_lsn) { verify_clean_shutdown_of_log_version_old(const char *log_dir, LSN * last_lsn) {
int rval = TOKUDB_UPGRADE_FAILURE; int rval = TOKUDB_UPGRADE_FAILURE;
...@@ -67,7 +69,8 @@ verify_clean_shutdown_of_log_version_old(const char *log_dir, LSN * last_lsn) { ...@@ -67,7 +69,8 @@ verify_clean_shutdown_of_log_version_old(const char *log_dir, LSN * last_lsn) {
char *basename; char *basename;
TOKULOGCURSOR cursor; TOKULOGCURSOR cursor;
struct log_entry *entry; struct log_entry *entry;
//Only look at newest log // Only look at newest log
// basename points to first char after last / in file pathname
basename = strrchr(logfiles[n_logfiles-1], '/') + 1; basename = strrchr(logfiles[n_logfiles-1], '/') + 1;
int version; int version;
long long index = -1; long long index = -1;
...@@ -103,24 +106,24 @@ verify_clean_shutdown_of_log_version_old(const char *log_dir, LSN * last_lsn) { ...@@ -103,24 +106,24 @@ verify_clean_shutdown_of_log_version_old(const char *log_dir, LSN * last_lsn) {
static int static int
verify_clean_shutdown_of_log_version(const char *log_dir, uint32_t version, LSN *last_lsn) { verify_clean_shutdown_of_log_version(const char *log_dir, uint32_t version, LSN *last_lsn) {
// return 0 if clean shutdown, TOKUDB_UPGRADE_FAILURE if not clean shutdown // return 0 if clean shutdown, TOKUDB_UPGRADE_FAILURE if not clean shutdown
// examine logfile at logfilenum and possibly logfilenum-1
int r = 0; int r = 0;
FOOTPRINTSETUP(1000); FOOTPRINTSETUP(1000);
if (version < TOKU_LOG_VERSION) { if (version < TOKU_LOG_VERSION) {
FOOTPRINT(1); FOOTPRINT(1);
r = verify_clean_shutdown_of_log_version_old(log_dir, last_lsn); r = verify_clean_shutdown_of_log_version_old(log_dir, last_lsn);
} }
else { else {
FOOTPRINT(2); FOOTPRINT(2);
assert(version == TOKU_LOG_VERSION); assert(version == TOKU_LOG_VERSION);
r = verify_clean_shutdown_of_log_version_current(log_dir, last_lsn); r = verify_clean_shutdown_of_log_version_current(log_dir, last_lsn);
} }
FOOTPRINTCAPTURE; FOOTPRINTCAPTURE;
return r; return r;
} }
// Actually create a log file of the current version, making the environment be of the current version.
static int static int
upgrade_log(const char *env_dir, const char *log_dir, LSN last_lsn) { // the real deal upgrade_log(const char *env_dir, const char *log_dir, LSN last_lsn) { // the real deal
int r; int r;
...@@ -163,7 +166,8 @@ upgrade_log(const char *env_dir, const char *log_dir, LSN last_lsn) { // the rea ...@@ -163,7 +166,8 @@ upgrade_log(const char *env_dir, const char *log_dir, LSN last_lsn) { // the rea
return 0; return 0;
} }
// If log on disk is old (environment is old) and clean shutdown, then create log of current version,
// which will make the environment of the current version (and delete the old logs).
int int
toku_maybe_upgrade_log(const char *env_dir, const char *log_dir, LSN * lsn_of_clean_shutdown, BOOL * upgrade_in_progress) { toku_maybe_upgrade_log(const char *env_dir, const char *log_dir, LSN * lsn_of_clean_shutdown, BOOL * upgrade_in_progress) {
int r; int r;
...@@ -175,7 +179,7 @@ toku_maybe_upgrade_log(const char *env_dir, const char *log_dir, LSN * lsn_of_cl ...@@ -175,7 +179,7 @@ toku_maybe_upgrade_log(const char *env_dir, const char *log_dir, LSN * lsn_of_cl
FOOTPRINT(1); FOOTPRINT(1);
r = toku_recover_lock(log_dir, &lockfd); r = toku_recover_lock(log_dir, &lockfd);
if (r == 0) { if (r == 0) {
FOOTPRINT(2); FOOTPRINT(2);
assert(log_dir); assert(log_dir);
assert(env_dir); assert(env_dir);
...@@ -183,7 +187,7 @@ toku_maybe_upgrade_log(const char *env_dir, const char *log_dir, LSN * lsn_of_cl ...@@ -183,7 +187,7 @@ toku_maybe_upgrade_log(const char *env_dir, const char *log_dir, LSN * lsn_of_cl
BOOL found_any_logs; BOOL found_any_logs;
r = toku_get_version_of_logs_on_disk(log_dir, &found_any_logs, &version_of_logs_on_disk); r = toku_get_version_of_logs_on_disk(log_dir, &found_any_logs, &version_of_logs_on_disk);
if (r==0) { if (r==0) {
FOOTPRINT(3); FOOTPRINT(3);
if (!found_any_logs) if (!found_any_logs)
r = 0; //No logs means no logs to upgrade. r = 0; //No logs means no logs to upgrade.
else if (version_of_logs_on_disk > TOKU_LOG_VERSION) else if (version_of_logs_on_disk > TOKU_LOG_VERSION)
...@@ -198,8 +202,8 @@ toku_maybe_upgrade_log(const char *env_dir, const char *log_dir, LSN * lsn_of_cl ...@@ -198,8 +202,8 @@ toku_maybe_upgrade_log(const char *env_dir, const char *log_dir, LSN * lsn_of_cl
r = verify_clean_shutdown_of_log_version(log_dir, version_of_logs_on_disk, &last_lsn); r = verify_clean_shutdown_of_log_version(log_dir, version_of_logs_on_disk, &last_lsn);
if (r==0) { if (r==0) {
FOOTPRINT(5); FOOTPRINT(5);
*lsn_of_clean_shutdown = last_lsn; *lsn_of_clean_shutdown = last_lsn;
*upgrade_in_progress = TRUE; *upgrade_in_progress = TRUE;
r = upgrade_log(env_dir, log_dir, last_lsn); r = upgrade_log(env_dir, log_dir, last_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