Commit 19921b4e authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

Fixes #2782. The brtloader uses temp dir. Note however that #2783 isn't...

Fixes #2782.  The brtloader uses temp dir.   Note however that #2783 isn't fixed yet. close[t:2782].

git-svn-id: file:///svn/toku/tokudb@21827 c7de825b-a66e-492c-adef-691d508d4ae1
parent 47919cfd
......@@ -158,7 +158,7 @@ int toku_loader_create_loader(DB_ENV *env,
loader->i->loader_flags = loader_flags;
loader->i->temp_file_template = (char *)toku_malloc(MAX_FILE_SIZE);
int n = snprintf(loader->i->temp_file_template, MAX_FILE_SIZE, "%s/%s%s", env->i->real_data_dir, loader_temp_prefix, loader_temp_suffix);
int n = snprintf(loader->i->temp_file_template, MAX_FILE_SIZE, "%s/%s%s", env->i->real_tmp_dir, loader_temp_prefix, loader_temp_suffix);
if ( !(n>0 && n<MAX_FILE_SIZE) ) {
rval = -1;
goto create_exit;
......@@ -227,16 +227,16 @@ int toku_loader_create_loader(DB_ENV *env,
goto create_exit;
}
r = toku_brt_loader_open(&loader->i->brt_loader,
loader->i->env->i->cachetable,
loader->i->env->i->generate_row_for_put,
src_db,
N,
dbs,
descriptors,
(const char **)new_inames_in_env,
compare_functions,
loader->i->temp_file_template,
load_lsn);
loader->i->env->i->cachetable,
loader->i->env->i->generate_row_for_put,
src_db,
N,
dbs,
descriptors,
(const char **)new_inames_in_env,
compare_functions,
loader->i->temp_file_template,
load_lsn);
if ( r!=0 ) {
toku_free(new_inames_in_env);
toku_free(descriptors);
......
......@@ -346,6 +346,7 @@ static void test_loader(DB **dbs)
char *free_me = NULL;
char *env_dir = ENVDIR; // the default env_dir.
char *tmp_subdir = "tmp.subdir";
static void run_test(void)
{
......@@ -358,8 +359,15 @@ static void run_test(void)
r = system(syscmd); CKERR(r);
}
r = toku_os_mkdir(env_dir, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_env_create(&env, 0); CKERR(r);
{
char len = strlen(env_dir) + strlen(tmp_subdir) + 10;
char tmpdir[len];
r = snprintf(tmpdir, len, "%s/%s", env_dir, tmp_subdir);
assert(r<len);
r = toku_os_mkdir(tmpdir, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_env_create(&env, 0); CKERR(r);
r = env->set_tmp_dir(env, tmp_subdir); CKERR(r);
}
r = env->set_default_bt_compare(env, uint_dbt_cmp); CKERR(r);
r = env->set_default_dup_compare(env, uint_dbt_cmp); CKERR(r);
if ( verbose ) printf("CACHESIZE = %d MB\n", CACHESIZE);
......
This diff is collapsed.
......@@ -70,8 +70,9 @@ struct __toku_db_env_internal {
DB *persistent_environment; // Stores environment settings, can be used for upgrade
OMT open_dbs; // Stores open db handles, sorted first by dname and then by numerical value of pointer to the db (arbitrarily assigned memory location)
char *real_data_dir; // data dir used when the env is opened (relative to cwd)
char *real_log_dir; // log dir used when the env is opened (relative to cwd)
char *real_data_dir; // data dir used when the env is opened (relative to cwd, or absolute with leading /)
char *real_log_dir; // log dir used when the env is opened (relative to cwd, or absolute with leading /)
char *real_tmp_dir; // tmp dir used for temporary files (relative to cwd, or absoulte with leading /)
enum {
FS_GREEN = 0, // green zone (we have lots of space)
......
......@@ -464,31 +464,34 @@ static int toku_c_count(DBC *cursor, db_recno_t *count, u_int32_t flags);
static int toku_c_close(DBC * c);
static void
env_setup_real_data_dir(DB_ENV *env) {
toku_free(env->i->real_data_dir);
env->i->real_data_dir = NULL;
env_setup_real_dir(DB_ENV *env, char **real_dir, const char *nominal_dir) {
toku_free(*real_dir);
*real_dir = NULL;
assert(env->i->dir);
if (env->i->data_dir)
env->i->real_data_dir = toku_construct_full_name(2, env->i->dir, env->i->data_dir);
if (nominal_dir)
*real_dir = toku_construct_full_name(2, env->i->dir, nominal_dir);
else
env->i->real_data_dir = toku_strdup(env->i->dir);
*real_dir = toku_strdup(env->i->dir);
}
static void
env_setup_real_data_dir(DB_ENV *env) {
env_setup_real_dir(env, &env->i->real_data_dir, env->i->data_dir);
}
static void
env_setup_real_log_dir(DB_ENV *env) {
toku_free(env->i->real_log_dir);
env->i->real_log_dir = NULL;
env_setup_real_dir(env, &env->i->real_log_dir, env->i->lg_dir);
}
if (env->i->lg_dir) {
assert(env->i->dir);
env->i->real_log_dir = toku_construct_full_name(2, env->i->dir, env->i->lg_dir);
} else {
assert(env->i->dir);
env->i->real_log_dir = toku_strdup(env->i->dir);
}
static void
env_setup_real_tmp_dir(DB_ENV *env) {
env_setup_real_dir(env, &env->i->real_tmp_dir, env->i->tmp_dir);
}
static int
ydb_do_recovery (DB_ENV *env) {
assert(env->i->real_log_dir);
......@@ -783,6 +786,7 @@ toku_env_open(DB_ENV * env, const char *home, u_int32_t flags, int mode) {
env_setup_real_data_dir(env);
env_setup_real_log_dir(env);
env_setup_real_tmp_dir(env);
BOOL need_rollback_cachefile = FALSE;
if (flags & (DB_INIT_TXN | DB_INIT_LOG)) {
......
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