diff --git a/src/loader.c b/src/loader.c index eed08e09150..a9f784ba854 100644 --- a/src/loader.c +++ b/src/loader.c @@ -162,22 +162,19 @@ int toku_loader_create_loader(DB_ENV *env, loader->close = toku_loader_close; loader->abort = toku_loader_abort; - int r = 0; + int r; // lock tables and check empty for(int i=0;ii->loader_flags & LOADER_USE_PUTS) != 0; - r = toku_db_pre_acquire_table_lock(dbs[i], txn, !using_puts); - toku_ydb_unlock(); - if (r!=0) break; + r = toku_db_pre_acquire_table_lock(dbs[i], txn, TRUE); + if ( r!=0 ) { + free_loader(loader); + return -1; } r = verify_empty(dbs[i], txn); - if (r!=0) break; - } - if ( r!=0 ) { - free_loader(loader); - return -1; + if ( r!=0 ) { + free_loader(loader); + return -1; + } } brt_compare_func compare_functions[N]; diff --git a/src/tests/loader-reference-test.c b/src/tests/loader-reference-test.c index 5d4466bc99d..fbbd62d8e1a 100644 --- a/src/tests/loader-reference-test.c +++ b/src/tests/loader-reference-test.c @@ -11,6 +11,7 @@ DB_ENV *env; enum {MAX_NAME=128}; enum {NUM_DBS=1}; enum {NUM_KV_PAIRS=3}; +int USE_PUTS=0; struct kv_pair { int64_t key; int64_t val; @@ -47,7 +48,7 @@ static void test_loader(DB **dbs) db_flags[i] = DB_NOOVERWRITE; dbt_flags[i] = 0; } - uint32_t loader_flags = 0; + uint32_t loader_flags = USE_PUTS; // set with -p option // create and initialize loader r = env->txn_begin(env, NULL, &txn, 0); @@ -170,6 +171,8 @@ static void do_args(int argc, char * const argv[]) { } else if (strcmp(argv[0],"-q")==0) { verbose--; if (verbose<0) verbose=0; + } else if (strcmp(argv[0], "-p")==0) { + USE_PUTS = 1; } else { fprintf(stderr, "Unknown arg: %s\n", argv[0]); resultcode=1; diff --git a/src/tests/loader-stress-test.c b/src/tests/loader-stress-test.c index b4ca0650841..87294b6eaa7 100644 --- a/src/tests/loader-stress-test.c +++ b/src/tests/loader-stress-test.c @@ -197,8 +197,16 @@ static int poll_function (void *extra, float progress) { return 0; } +static struct timeval starttime; +static double elapsed_time (void) { + struct timeval now; + gettimeofday(&now, NULL); + return now.tv_sec - starttime.tv_sec + 1e-6*(now.tv_usec - starttime.tv_usec); +} + static void test_loader(DB **dbs) { + gettimeofday(&starttime, NULL); int r; DB_TXN *txn; DB_LOADER *loader; @@ -237,12 +245,15 @@ static void test_loader(DB **dbs) poll_count=0; // close the loader - printf("closing"); fflush(stdout); + printf("%9.6fs closing", elapsed_time()); fflush(stdout); r = loader->close(loader); printf(" done\n"); CKERR(r); - assert(poll_count>0); + if ( USE_PUTS == 0 ) { + if (poll_count == 0) printf("%s:%d\n", __FILE__, __LINE__); + assert(poll_count>0); + } r = txn->commit(txn, 0); CKERR(r);