Commit e8e3f3ea authored by Yoni Fogel's avatar Yoni Fogel

refs #5203 Fix error handling code in loader to make it easier to track down...

refs #5203 Fix error handling code in loader to make it easier to track down errors if test_stress5 fails again (and general debugging)

git-svn-id: file:///svn/toku/tokudb@46352 c7de825b-a66e-492c-adef-691d508d4ae1
parent b0e3547a
...@@ -210,7 +210,7 @@ int toku_loader_create_loader(DB_ENV *env, ...@@ -210,7 +210,7 @@ int toku_loader_create_loader(DB_ENV *env,
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); 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) ) { if ( !(n>0 && n<MAX_FILE_SIZE) ) {
rval = -1; rval = ENAMETOOLONG;
goto create_exit; goto create_exit;
} }
...@@ -225,21 +225,20 @@ int toku_loader_create_loader(DB_ENV *env, ...@@ -225,21 +225,20 @@ int toku_loader_create_loader(DB_ENV *env,
loader->close = toku_loader_close; loader->close = toku_loader_close;
loader->abort = toku_loader_abort; loader->abort = toku_loader_abort;
int r;
r = 0;
// lock tables and check empty // lock tables and check empty
for(int i=0;i<N;i++) { for(int i=0;i<N;i++) {
if (!(loader_flags&DB_PRELOCKED_WRITE)) { if (!(loader_flags&DB_PRELOCKED_WRITE)) {
r = toku_db_pre_acquire_table_lock(dbs[i], txn); rval = toku_db_pre_acquire_table_lock(dbs[i], txn);
if (r!=0) break; if (rval!=0) {
goto create_exit;
} }
r = !toku_ft_is_empty_fast(dbs[i]->i->ft_handle);
if (r!=0) break;
} }
if ( r!=0 ) { bool empty = toku_ft_is_empty_fast(dbs[i]->i->ft_handle);
rval = -1; if (!empty) {
rval = ENOTEMPTY;
goto create_exit; goto create_exit;
} }
}
{ {
ft_compare_func compare_functions[N]; ft_compare_func compare_functions[N];
...@@ -256,15 +255,14 @@ int toku_loader_create_loader(DB_ENV *env, ...@@ -256,15 +255,14 @@ int toku_loader_create_loader(DB_ENV *env,
loader->i->ekeys = NULL; loader->i->ekeys = NULL;
loader->i->evals = NULL; loader->i->evals = NULL;
LSN load_lsn; LSN load_lsn;
r = locked_load_inames(env, txn, N, dbs, new_inames_in_env, &load_lsn, use_ft_loader); rval = locked_load_inames(env, txn, N, dbs, new_inames_in_env, &load_lsn, use_ft_loader);
if ( r!=0 ) { if ( rval!=0 ) {
toku_free(new_inames_in_env); toku_free(new_inames_in_env);
toku_free(brts); toku_free(brts);
rval = r;
goto create_exit; goto create_exit;
} }
TOKUTXN ttxn = txn ? db_txn_struct_i(txn)->tokutxn : NULL; TOKUTXN ttxn = txn ? db_txn_struct_i(txn)->tokutxn : NULL;
r = toku_ft_loader_open(&loader->i->ft_loader, rval = toku_ft_loader_open(&loader->i->ft_loader,
loader->i->env->i->cachetable, loader->i->env->i->cachetable,
loader->i->env->i->generate_row_for_put, loader->i->env->i->generate_row_for_put,
src_db, src_db,
...@@ -276,10 +274,9 @@ int toku_loader_create_loader(DB_ENV *env, ...@@ -276,10 +274,9 @@ int toku_loader_create_loader(DB_ENV *env,
load_lsn, load_lsn,
ttxn, ttxn,
!use_puts); !use_puts);
if ( r!=0 ) { if ( rval!=0 ) {
toku_free(new_inames_in_env); toku_free(new_inames_in_env);
toku_free(brts); toku_free(brts);
rval = r;
goto create_exit; goto create_exit;
} }
loader->i->inames_in_env = new_inames_in_env; loader->i->inames_in_env = new_inames_in_env;
......
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