Commit 46202940 authored by Yoni Fogel's avatar Yoni Fogel

closes[t:2542] Fix bug in loader: need to hold ydb lock around pre_acquire_table lock

Let LOADER_USE_PUTS trigger #2440 optimization.  DB_PRELOCKED_WRITE in loader flags prevents pre_acquire_table_lock from being called

git-svn-id: file:///svn/toku/tokudb@19586 c7de825b-a66e-492c-adef-691d508d4ae1
parent 1e6bf0fd
...@@ -160,19 +160,21 @@ int toku_loader_create_loader(DB_ENV *env, ...@@ -160,19 +160,21 @@ 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; int 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++) {
r = toku_db_pre_acquire_table_lock(dbs[i], txn, TRUE); if (!(loader_flags&DB_PRELOCKED_WRITE)) {
if ( r!=0 ) { toku_ydb_lock(); //Must hold ydb lock for pre_acquire
free_loader(loader); r = toku_db_pre_acquire_table_lock(dbs[i], txn, FALSE);
return -1; toku_ydb_unlock();
if (r!=0) break;
} }
r = verify_empty(dbs[i], txn); r = verify_empty(dbs[i], txn);
if ( r!=0 ) { if (r!=0) break;
free_loader(loader); }
return -1; if ( r!=0 ) {
} free_loader(loader);
return -1;
} }
brt_compare_func compare_functions[N]; brt_compare_func compare_functions[N];
......
...@@ -5053,7 +5053,7 @@ int toku_db_pre_acquire_table_lock(DB *db, DB_TXN *txn, BOOL just_lock) { ...@@ -5053,7 +5053,7 @@ int toku_db_pre_acquire_table_lock(DB *db, DB_TXN *txn, BOOL just_lock) {
DB *dbs[1] = {db}; DB *dbs[1] = {db};
uint32_t db_flags[1] = {DB_NOOVERWRITE}; uint32_t db_flags[1] = {DB_NOOVERWRITE};
uint32_t dbt_flags[1] = {0}; uint32_t dbt_flags[1] = {0};
uint32_t loader_flags = 0; uint32_t loader_flags = DB_PRELOCKED_WRITE; //Don't recursively prelock
DB_ENV *env = db->dbenv; DB_ENV *env = db->dbenv;
toku_ydb_unlock(); //Cannot hold ydb lock when creating loader toku_ydb_unlock(); //Cannot hold ydb lock when creating loader
......
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