Commit 36440b0c authored by Barry Perlman's avatar Barry Perlman Committed by Yoni Fogel

Fixes #1683 Created separate toku_cachetable_minicron_shutdown() to be called...

Fixes #1683 Created separate toku_cachetable_minicron_shutdown() to be called when no locks are held.  Note, toku_cachetable_close() still calls minicron_shutdown() if it was not already shut down to avoid rewriting tests.

git-svn-id: file:///svn/toku/tokudb@11285 c7de825b-a66e-492c-adef-691d508d4ae1
parent 9c3477b2
......@@ -1299,10 +1299,19 @@ static int cachetable_flush_cachefile(CACHETABLE ct, CACHEFILE cf) {
return 0;
}
/* Requires that no locks be held that are used by the checkpoint logic (ydb, etc.) */
void
toku_cachetable_minicron_shutdown(CACHETABLE ct) {
int r = toku_minicron_shutdown(&ct->checkpointer);
assert(r==0);
}
/* Require that it all be flushed. */
int toku_cachetable_close (CACHETABLE *ctp) {
int
toku_cachetable_close (CACHETABLE *ctp) {
CACHETABLE ct=*ctp;
{
if (!toku_minicron_has_been_shutdown(&ct->checkpointer)) {
// for test code only, production code uses toku_cachetable_minicron_shutdown()
int r = toku_minicron_shutdown(&ct->checkpointer);
assert(r==0);
}
......
......@@ -45,6 +45,10 @@ int toku_cachetable_end_checkpoint(CACHETABLE ct, TOKULOGGER logger, char **erro
// Handles the case where cf points to /dev/null
int toku_cachefile_fsync(CACHEFILE cf);
// Shuts down checkpoint thread
// Requires no locks be held that are taken by the checkpoint function
void toku_cachetable_minicron_shutdown(CACHETABLE ct);
// Close the cachetable.
// Effects: All of the memory objects are flushed to disk, and the cachetable is
// destroyed.
......
......@@ -130,3 +130,8 @@ toku_minicron_shutdown(struct minicron *p) {
//printf("%s:%d shutdowned\n", __FILE__, __LINE__);
return 0;
}
BOOL
toku_minicron_has_been_shutdown(struct minicron *p) {
return p->do_shutdown;
}
......@@ -35,4 +35,4 @@ struct minicron {
int toku_minicron_setup (struct minicron *s, u_int32_t period_in_seconds, int(*f)(void *), void *arg);
int toku_minicron_change_period(struct minicron *p, u_int32_t new_period);
int toku_minicron_shutdown(struct minicron *p);
BOOL toku_minicron_has_been_shutdown(struct minicron *p);
......@@ -449,6 +449,9 @@ static int toku_env_close(DB_ENV * env, u_int32_t flags) {
// Even if the env is panicked, try to close as much as we can.
int r0=0,r1=0;
if (env->i->cachetable) {
toku_ydb_unlock(); // ydb lock must not be held when shutting down minicron
toku_cachetable_minicron_shutdown(env->i->cachetable);
toku_ydb_lock();
r0=toku_cachetable_close(&env->i->cachetable);
if (r0) {
toku_ydb_do_error(env, r0, "Cannot close environment (cachetable close error)\n");
......
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