@ -1228,7 +1228,8 @@ Status DBImpl::Recover(
if ( ! s . ok ( ) ) {
if ( ! s . ok ( ) ) {
// Clear memtables if recovery failed
// Clear memtables if recovery failed
for ( auto cfd : * versions_ - > GetColumnFamilySet ( ) ) {
for ( auto cfd : * versions_ - > GetColumnFamilySet ( ) ) {
cfd - > CreateNewMemtable ( ) ;
cfd - > CreateNewMemtable ( MemTableOptions (
* cfd - > GetLatestMutableCFOptions ( ) , * cfd - > options ( ) ) ) ;
}
}
}
}
}
}
@ -1356,7 +1357,8 @@ Status DBImpl::RecoverLogFiles(const std::vector<uint64_t>& log_numbers,
// file-systems cause the DB::Open() to fail.
// file-systems cause the DB::Open() to fail.
return status ;
return status ;
}
}
cfd - > CreateNewMemtable ( ) ;
cfd - > CreateNewMemtable ( MemTableOptions (
* cfd - > GetLatestMutableCFOptions ( ) , * cfd - > options ( ) ) ) ;
}
}
}
}
}
}
@ -1393,7 +1395,8 @@ Status DBImpl::RecoverLogFiles(const std::vector<uint64_t>& log_numbers,
// Recovery failed
// Recovery failed
break ;
break ;
}
}
cfd - > CreateNewMemtable ( ) ;
cfd - > CreateNewMemtable ( MemTableOptions (
* cfd - > GetLatestMutableCFOptions ( ) , * cfd - > options ( ) ) ) ;
}
}
// write MANIFEST with update
// write MANIFEST with update
@ -1623,6 +1626,7 @@ Status DBImpl::FlushMemTableToOutputFile(ColumnFamilyData* cfd,
}
}
if ( s . ok ( ) ) {
if ( s . ok ( ) ) {
// Use latest MutableCFOptions
InstallSuperVersion ( cfd , deletion_state ) ;
InstallSuperVersion ( cfd , deletion_state ) ;
if ( madeProgress ) {
if ( madeProgress ) {
* madeProgress = 1 ;
* madeProgress = 1 ;
@ -1714,6 +1718,13 @@ Status DBImpl::CompactRange(ColumnFamilyHandle* column_family,
return s ;
return s ;
}
}
bool DBImpl : : SetOptions ( ColumnFamilyHandle * column_family ,
const std : : unordered_map < std : : string , std : : string > & options_map ) {
auto cfh = reinterpret_cast < ColumnFamilyHandleImpl * > ( column_family ) ;
MutexLock l ( & mutex_ ) ;
return cfh - > cfd ( ) - > SetOptions ( options_map ) ;
}
// return the same level if it cannot be moved
// return the same level if it cannot be moved
int DBImpl : : FindMinimumEmptyLevelFitting ( ColumnFamilyData * cfd , int level ) {
int DBImpl : : FindMinimumEmptyLevelFitting ( ColumnFamilyData * cfd , int level ) {
mutex_ . AssertHeld ( ) ;
mutex_ . AssertHeld ( ) ;
@ -1784,6 +1795,7 @@ Status DBImpl::ReFitLevel(ColumnFamilyData* cfd, int level, int target_level) {
cfd - > GetName ( ) . c_str ( ) , edit . DebugString ( ) . data ( ) ) ;
cfd - > GetName ( ) . c_str ( ) , edit . DebugString ( ) . data ( ) ) ;
status = versions_ - > LogAndApply ( cfd , & edit , & mutex_ , db_directory_ . get ( ) ) ;
status = versions_ - > LogAndApply ( cfd , & edit , & mutex_ , db_directory_ . get ( ) ) ;
// Use latest MutableCFOptions
superversion_to_free = cfd - > InstallSuperVersion ( new_superversion , & mutex_ ) ;
superversion_to_free = cfd - > InstallSuperVersion ( new_superversion , & mutex_ ) ;
new_superversion = nullptr ;
new_superversion = nullptr ;
@ -2322,6 +2334,7 @@ Status DBImpl::BackgroundCompaction(bool* madeProgress,
}
}
status = versions_ - > LogAndApply ( c - > column_family_data ( ) , c - > edit ( ) , & mutex_ ,
status = versions_ - > LogAndApply ( c - > column_family_data ( ) , c - > edit ( ) , & mutex_ ,
db_directory_ . get ( ) ) ;
db_directory_ . get ( ) ) ;
// Use latest MutableCFOptions
InstallSuperVersion ( c - > column_family_data ( ) , deletion_state ) ;
InstallSuperVersion ( c - > column_family_data ( ) , deletion_state ) ;
LogToBuffer ( log_buffer , " [%s] Deleted %d files \n " ,
LogToBuffer ( log_buffer , " [%s] Deleted %d files \n " ,
c - > column_family_data ( ) - > GetName ( ) . c_str ( ) ,
c - > column_family_data ( ) - > GetName ( ) . c_str ( ) ,
@ -2338,6 +2351,7 @@ Status DBImpl::BackgroundCompaction(bool* madeProgress,
f - > smallest_seqno , f - > largest_seqno ) ;
f - > smallest_seqno , f - > largest_seqno ) ;
status = versions_ - > LogAndApply ( c - > column_family_data ( ) , c - > edit ( ) , & mutex_ ,
status = versions_ - > LogAndApply ( c - > column_family_data ( ) , c - > edit ( ) , & mutex_ ,
db_directory_ . get ( ) ) ;
db_directory_ . get ( ) ) ;
// Use latest MutableCFOptions
InstallSuperVersion ( c - > column_family_data ( ) , deletion_state ) ;
InstallSuperVersion ( c - > column_family_data ( ) , deletion_state ) ;
Version : : LevelSummaryStorage tmp ;
Version : : LevelSummaryStorage tmp ;
@ -3322,6 +3336,7 @@ Status DBImpl::DoCompactionWork(CompactionState* compact,
if ( status . ok ( ) ) {
if ( status . ok ( ) ) {
status = InstallCompactionResults ( compact , log_buffer ) ;
status = InstallCompactionResults ( compact , log_buffer ) ;
// Use latest MutableCFOptions
InstallSuperVersion ( cfd , deletion_state ) ;
InstallSuperVersion ( cfd , deletion_state ) ;
}
}
Version : : LevelSummaryStorage tmp ;
Version : : LevelSummaryStorage tmp ;
@ -3426,6 +3441,7 @@ void DBImpl::InstallSuperVersion(ColumnFamilyData* cfd,
SuperVersion * new_superversion =
SuperVersion * new_superversion =
( deletion_state . new_superversion ! = nullptr ) ?
( deletion_state . new_superversion ! = nullptr ) ?
deletion_state . new_superversion : new SuperVersion ( ) ;
deletion_state . new_superversion : new SuperVersion ( ) ;
// Use latest MutableCFOptions
SuperVersion * old_superversion =
SuperVersion * old_superversion =
cfd - > InstallSuperVersion ( new_superversion , & mutex_ ) ;
cfd - > InstallSuperVersion ( new_superversion , & mutex_ ) ;
deletion_state . new_superversion = nullptr ;
deletion_state . new_superversion = nullptr ;
@ -3618,6 +3634,7 @@ Status DBImpl::CreateColumnFamily(const ColumnFamilyOptions& options,
auto cfd =
auto cfd =
versions_ - > GetColumnFamilySet ( ) - > GetColumnFamily ( column_family_name ) ;
versions_ - > GetColumnFamilySet ( ) - > GetColumnFamily ( column_family_name ) ;
assert ( cfd ! = nullptr ) ;
assert ( cfd ! = nullptr ) ;
// Use latest MutableCFOptions
delete cfd - > InstallSuperVersion ( new SuperVersion ( ) , & mutex_ ) ;
delete cfd - > InstallSuperVersion ( new SuperVersion ( ) , & mutex_ ) ;
* handle = new ColumnFamilyHandleImpl ( cfd , this , & mutex_ ) ;
* handle = new ColumnFamilyHandleImpl ( cfd , this , & mutex_ ) ;
Log ( db_options_ . info_log , " Created column family [%s] (ID %u) " ,
Log ( db_options_ . info_log , " Created column family [%s] (ID %u) " ,
@ -4138,6 +4155,7 @@ Status DBImpl::SetNewMemtableAndNewLogFile(ColumnFamilyData* cfd,
uint64_t new_log_number =
uint64_t new_log_number =
creating_new_log ? versions_ - > NewFileNumber ( ) : logfile_number_ ;
creating_new_log ? versions_ - > NewFileNumber ( ) : logfile_number_ ;
SuperVersion * new_superversion = nullptr ;
SuperVersion * new_superversion = nullptr ;
const MutableCFOptions mutable_cf_options = * cfd - > GetLatestMutableCFOptions ( ) ;
mutex_ . Unlock ( ) ;
mutex_ . Unlock ( ) ;
Status s ;
Status s ;
{
{
@ -4156,8 +4174,8 @@ Status DBImpl::SetNewMemtableAndNewLogFile(ColumnFamilyData* cfd,
if ( s . ok ( ) ) {
if ( s . ok ( ) ) {
new_mem = new MemTable ( cfd - > internal_comparator ( ) ,
new_mem = new MemTable ( cfd - > internal_comparator ( ) ,
* cfd - > ioptions ( ) ,
* cfd - > ioptions ( ) , MemTableOptions ( mutable_cf_options ,
MemTableOptions ( * cfd - > options ( ) ) ) ;
* cfd - > options ( ) ) ) ;
new_superversion = new SuperVersion ( ) ;
new_superversion = new SuperVersion ( ) ;
}
}
}
}
@ -4197,7 +4215,7 @@ Status DBImpl::SetNewMemtableAndNewLogFile(ColumnFamilyData* cfd,
" [%s] New memtable created with log file: #% " PRIu64 " \n " ,
" [%s] New memtable created with log file: #% " PRIu64 " \n " ,
cfd - > GetName ( ) . c_str ( ) , logfile_number_ ) ;
cfd - > GetName ( ) . c_str ( ) , logfile_number_ ) ;
context - > superversions_to_free_ . push_back (
context - > superversions_to_free_ . push_back (
cfd - > InstallSuperVersion ( new_superversion , & mutex_ ) ) ;
cfd - > InstallSuperVersion ( new_superversion , & mutex_ , mutable_cf_options ) ) ;
return s ;
return s ;
}
}
@ -4672,6 +4690,7 @@ Status DB::Open(const DBOptions& db_options, const std::string& dbname,
}
}
if ( s . ok ( ) ) {
if ( s . ok ( ) ) {
for ( auto cfd : * impl - > versions_ - > GetColumnFamilySet ( ) ) {
for ( auto cfd : * impl - > versions_ - > GetColumnFamilySet ( ) ) {
// Use latest MutableCFOptions
delete cfd - > InstallSuperVersion ( new SuperVersion ( ) , & impl - > mutex_ ) ;
delete cfd - > InstallSuperVersion ( new SuperVersion ( ) , & impl - > mutex_ ) ;
}
}
impl - > alive_log_files_ . push_back (
impl - > alive_log_files_ . push_back (