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,
loader->close = toku_loader_close;
loader->abort = toku_loader_abort;
int r;
int r = 0;
// lock tables and check empty
for(int i=0;i<N;i++) {
r = toku_db_pre_acquire_table_lock(dbs[i], txn, TRUE);
if ( r!=0 ) {
free_loader(loader);
return -1;
if (!(loader_flags&DB_PRELOCKED_WRITE)) {
toku_ydb_lock(); //Must hold ydb lock for pre_acquire
r = toku_db_pre_acquire_table_lock(dbs[i], txn, FALSE);
toku_ydb_unlock();
if (r!=0) break;
}
r = verify_empty(dbs[i], txn);
if ( r!=0 ) {
free_loader(loader);
return -1;
}
if (r!=0) break;
}
if ( r!=0 ) {
free_loader(loader);
return -1;
}
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) {
DB *dbs[1] = {db};
uint32_t db_flags[1] = {DB_NOOVERWRITE};
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;
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