@ -276,10 +276,10 @@ void TransactionDB::PrepareWrap(
db_options - > allow_2pc = true ;
db_options - > allow_2pc = true ;
}
}
Status TransactionDB : : WrapDB (
namespace {
// make sure this db is already opened with memtable history enabled,
template < typename DBType >
// auto compaction distabled and 2 phase commit enabled
Status WrapAnotherDBInternal (
DB * db , const TransactionDBOptions & txn_db_options ,
DBType * db , const TransactionDBOptions & txn_db_options ,
const std : : vector < size_t > & compaction_enabled_cf_indices ,
const std : : vector < size_t > & compaction_enabled_cf_indices ,
const std : : vector < ColumnFamilyHandle * > & handles , TransactionDB * * dbptr ) {
const std : : vector < ColumnFamilyHandle * > & handles , TransactionDB * * dbptr ) {
assert ( db ! = nullptr ) ;
assert ( db ! = nullptr ) ;
@ -309,6 +309,17 @@ Status TransactionDB::WrapDB(
}
}
return s ;
return s ;
}
}
} // namespace
Status TransactionDB : : WrapDB (
// make sure this db is already opened with memtable history enabled,
// auto compaction distabled and 2 phase commit enabled
DB * db , const TransactionDBOptions & txn_db_options ,
const std : : vector < size_t > & compaction_enabled_cf_indices ,
const std : : vector < ColumnFamilyHandle * > & handles , TransactionDB * * dbptr ) {
return WrapAnotherDBInternal ( db , txn_db_options ,
compaction_enabled_cf_indices , handles , dbptr ) ;
}
Status TransactionDB : : WrapStackableDB (
Status TransactionDB : : WrapStackableDB (
// make sure this stackable_db is already opened with memtable history
// make sure this stackable_db is already opened with memtable history
@ -316,33 +327,8 @@ Status TransactionDB::WrapStackableDB(
StackableDB * db , const TransactionDBOptions & txn_db_options ,
StackableDB * db , const TransactionDBOptions & txn_db_options ,
const std : : vector < size_t > & compaction_enabled_cf_indices ,
const std : : vector < size_t > & compaction_enabled_cf_indices ,
const std : : vector < ColumnFamilyHandle * > & handles , TransactionDB * * dbptr ) {
const std : : vector < ColumnFamilyHandle * > & handles , TransactionDB * * dbptr ) {
assert ( db ! = nullptr ) ;
return WrapAnotherDBInternal ( db , txn_db_options ,
assert ( dbptr ! = nullptr ) ;
compaction_enabled_cf_indices , handles , dbptr ) ;
* dbptr = nullptr ;
std : : unique_ptr < PessimisticTransactionDB > txn_db ;
switch ( txn_db_options . write_policy ) {
case WRITE_UNPREPARED :
txn_db . reset ( new WriteUnpreparedTxnDB (
db , PessimisticTransactionDB : : ValidateTxnDBOptions ( txn_db_options ) ) ) ;
break ;
case WRITE_PREPARED :
txn_db . reset ( new WritePreparedTxnDB (
db , PessimisticTransactionDB : : ValidateTxnDBOptions ( txn_db_options ) ) ) ;
break ;
case WRITE_COMMITTED :
default :
txn_db . reset ( new WriteCommittedTxnDB (
db , PessimisticTransactionDB : : ValidateTxnDBOptions ( txn_db_options ) ) ) ;
}
txn_db - > UpdateCFComparatorMap ( handles ) ;
Status s = txn_db - > Initialize ( compaction_enabled_cf_indices , handles ) ;
// In case of a failure at this point, db is deleted via the txn_db destructor
// and set to nullptr.
if ( s . ok ( ) ) {
* dbptr = txn_db . release ( ) ;
}
return s ;
}
}
// Let LockManager know that this column family exists so it can
// Let LockManager know that this column family exists so it can