Commit dec996c1 authored by Dave Wells's avatar Dave Wells Committed by Yoni Fogel

add ability to execute 2 callbacks during recovery - for [t:2028]

git-svn-id: file:///svn/toku/tokudb@16279 c7de825b-a66e-492c-adef-691d508d4ae1
parent 84987d50
......@@ -514,6 +514,8 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un
printf("int db_env_set_func_realloc (void *(*)(void*, size_t)) %s;\n", VISIBLE);
printf("void db_env_set_checkpoint_callback (void (*)(void*), void*) %s;\n", VISIBLE);
printf("void db_env_set_checkpoint_callback2 (void (*)(void*), void*) %s;\n", VISIBLE);
printf("void db_env_set_recover_callback (void (*)(void*), void*) %s;\n", VISIBLE);
printf("void db_env_set_recover_callback2 (void (*)(void*), void*) %s;\n", VISIBLE);
printf("#if defined(__cplusplus)\n}\n#endif\n");
printf("#endif\n");
return 0;
......
......@@ -348,6 +348,8 @@ int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) __attribute__
int db_env_set_func_realloc (void *(*)(void*, size_t)) __attribute__((__visibility__("default")));
void db_env_set_checkpoint_callback (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_recover_callback (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_recover_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default")));
#if defined(__cplusplus)
}
#endif
......
......@@ -348,6 +348,8 @@ int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) __attribute__
int db_env_set_func_realloc (void *(*)(void*, size_t)) __attribute__((__visibility__("default")));
void db_env_set_checkpoint_callback (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_recover_callback (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_recover_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default")));
#if defined(__cplusplus)
}
#endif
......
......@@ -874,6 +874,13 @@ static void recover_trace_le(const char *f, int l, int r, struct log_entry *le)
fprintf(stderr, "%s:%d r=%d cmd=?\n", f, l, r);
}
// For test purposes only.
static void (*recover_callback_fx)(void*) = NULL;
static void * recover_callback_args = NULL;
static void (*recover_callback2_fx)(void*) = NULL;
static void * recover_callback2_args = NULL;
static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_dir) {
int r;
int rr = 0;
......@@ -965,6 +972,10 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di
}
}
// run first callback
if (recover_callback_fx)
recover_callback_fx(recover_callback_args);
// scan forwards
if (le)
thislsn = toku_log_entry_get_lsn(le);
......@@ -1004,6 +1015,10 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di
r = toku_logcursor_destroy(&logcursor);
assert(r == 0);
// run second callback
if (recover_callback2_fx)
recover_callback2_fx(recover_callback2_args);
// restart logging
toku_logger_restart(renv->logger, lastlsn);
......@@ -1151,3 +1166,13 @@ tokudb_recover_log_exists(const char * log_dir) {
return r;
}
void toku_recover_set_callback (void (*callback_fx)(void*), void* callback_args) {
recover_callback_fx = callback_fx;
recover_callback_args = callback_args;
}
void toku_recover_set_callback2 (void (*callback_fx)(void*), void* callback_args) {
recover_callback2_fx = callback_fx;
recover_callback2_args = callback_args;
}
......@@ -31,6 +31,9 @@ int tokudb_recover_delete_rolltmp_files(const char *datadir, const char *logdir)
// Return 0 if recovery log exists, ENOENT if log is missing
int tokudb_recover_log_exists(const char * log_dir);
// For test only - set callbacks for recovery testing
void toku_recover_set_callback (void (*)(void*), void*);
void toku_recover_set_callback2 (void (*)(void*), void*);
extern int tokudb_recovery_trace;
......
......@@ -13,6 +13,8 @@
db_env_set_func_write;
db_env_set_checkpoint_callback;
db_env_set_checkpoint_callback2;
db_env_set_recover_callback;
db_env_set_recover_callback2;
toku_os_get_max_rss;
......
......@@ -5003,6 +5003,14 @@ void db_env_set_checkpoint_callback2 (void (*callback_f)(void*), void* extra) {
//printf("set callback2 = %p, extra2 = %p\n", callback2_f, extra2);
}
void db_env_set_recover_callback (void (*callback_f)(void*), void* extra) {
toku_recover_set_callback(callback_f, extra);
}
void db_env_set_recover_callback2 (void (*callback_f)(void*), void* extra) {
toku_recover_set_callback2(callback_f, extra);
}
// HACK: To ensure toku_pthread_yield gets included in the .so
// non-static would require a prototype in a header
// static (since unused) would give a warning
......
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