@ -3747,7 +3747,7 @@ Status VersionSet::ProcessManifestWrites(
nullptr , db_options_ - > listeners ) ) ;
descriptor_log_ . reset (
new log : : Writer ( std : : move ( file_writer ) , 0 , false ) ) ;
s = WriteSnapsho t ( descriptor_log_ . get ( ) ) ;
s = WriteCurrentStateToManifes t ( descriptor_log_ . get ( ) ) ;
}
}
@ -4061,10 +4061,7 @@ Status VersionSet::ApplyOneVersionEditToBuilder(
std : : unordered_map < int , std : : string > & column_families_not_found ,
std : : unordered_map < uint32_t , std : : unique_ptr < BaseReferencedVersionBuilder > > &
builders ,
bool * have_log_number , uint64_t * log_number , bool * have_prev_log_number ,
uint64_t * previous_log_number , bool * have_next_file , uint64_t * next_file ,
bool * have_last_sequence , SequenceNumber * last_sequence ,
uint64_t * min_log_number_to_keep , uint32_t * max_column_family ) {
VersionEditParams * version_edit_params ) {
// Not found means that user didn't supply that column
// family option AND we encountered column family add
// record. Once we encounter column family drop record,
@ -4150,61 +4147,55 @@ Status VersionSet::ApplyOneVersionEditToBuilder(
return s ;
}
}
return ExtractInfoFromVersionEdit (
cfd , edit , have_log_number , log_number , have_prev_log_number ,
previous_log_number , have_next_file , next_file , have_last_sequence ,
last_sequence , min_log_number_to_keep , max_column_family ) ;
return ExtractInfoFromVersionEdit ( cfd , edit , version_edit_params ) ;
}
Status VersionSet : : ExtractInfoFromVersionEdit (
ColumnFamilyData * cfd , const VersionEdit & edit , bool * have_log_number ,
uint64_t * log_number , bool * have_prev_log_number ,
uint64_t * previous_log_number , bool * have_next_file , uint64_t * next_file ,
bool * have_last_sequence , SequenceNumber * last_sequence ,
uint64_t * min_log_number_to_keep , uint32_t * max_column_family ) {
ColumnFamilyData * cfd , const VersionEdit & from_edit ,
VersionEditParams * version_edit_params ) {
if ( cfd ! = nullptr ) {
if ( edit . has_log_number_ ) {
if ( cfd - > GetLogNumber ( ) > edit . log_number_ ) {
if ( from_edit . has_db_id_ ) {
version_edit_params - > SetDBId ( from_edit . db_id_ ) ;
}
if ( from_edit . has_log_number_ ) {
if ( cfd - > GetLogNumber ( ) > from_edit . log_number_ ) {
ROCKS_LOG_WARN (
db_options_ - > info_log ,
" MANIFEST corruption detected, but ignored - Log numbers in "
" records NOT monotonically increasing " ) ;
} else {
cfd - > SetLogNumber ( edit . log_number_ ) ;
* have_log_number = true ;
* log_number = edit . log_number_ ;
cfd - > SetLogNumber ( from_edit . log_number_ ) ;
version_edit_params - > SetLogNumber ( from_edit . log_number_ ) ;
}
}
if ( edit . has_comparator_ & &
edit . comparator_ ! = cfd - > user_comparator ( ) - > Name ( ) ) {
if ( from_ edit. has_comparator_ & &
from_ edit. comparator_ ! = cfd - > user_comparator ( ) - > Name ( ) ) {
return Status : : InvalidArgument (
cfd - > user_comparator ( ) - > Name ( ) ,
" does not match existing comparator " + edit . comparator_ ) ;
" does not match existing comparator " + from_ edit. comparator_ ) ;
}
}
if ( edit . has_prev_log_number_ ) {
* previous_log_number = edit . prev_log_number_ ;
* have_prev_log_number = true ;
if ( from_edit . has_prev_log_number_ ) {
version_edit_params - > SetPrevLogNumber ( from_edit . prev_log_number_ ) ;
}
if ( edit . has_next_file_number_ ) {
* next_file = edit . next_file_number_ ;
* have_next_file = true ;
if ( from_edit . has_next_file_number_ ) {
version_edit_params - > SetNextFile ( from_edit . next_file_number_ ) ;
}
if ( edit . has_max_column_family_ ) {
* max_column_family = edit . max_column_family_ ;
if ( from_ edit. has_max_column_family_ ) {
version_edit_params - > SetMaxColumnFamily ( from_ edit. max_column_family_ ) ;
}
if ( edit . has_min_log_number_to_keep_ ) {
* min_log_number_to_keep =
std : : max ( * min_log_number_to_keep , edit . min_log_number_to_keep_ ) ;
if ( from_edit . has_min_log_number_to_keep_ ) {
version_edit_params - > min_log_number_to_keep_ =
std : : max ( version_edit_params - > min_log_number_to_keep_ ,
from_edit . min_log_number_to_keep_ ) ;
}
if ( edit . has_last_sequence_ ) {
* last_sequence = edit . last_sequence_ ;
* have_last_sequence = true ;
if ( from_edit . has_last_sequence_ ) {
version_edit_params - > SetLastSequence ( from_edit . last_sequence_ ) ;
}
return Status : : OK ( ) ;
}
@ -4245,10 +4236,7 @@ Status VersionSet::ReadAndRecover(
std : : unordered_map < int , std : : string > & column_families_not_found ,
std : : unordered_map < uint32_t , std : : unique_ptr < BaseReferencedVersionBuilder > > &
builders ,
bool * have_log_number , uint64_t * log_number , bool * have_prev_log_number ,
uint64_t * previous_log_number , bool * have_next_file , uint64_t * next_file ,
bool * have_last_sequence , SequenceNumber * last_sequence ,
uint64_t * min_log_number_to_keep , uint32_t * max_column_family ) {
VersionEditParams * version_edit_params , std : : string * db_id ) {
assert ( reader ! = nullptr ) ;
assert ( read_buffer ! = nullptr ) ;
Status s ;
@ -4261,6 +4249,12 @@ Status VersionSet::ReadAndRecover(
if ( ! s . ok ( ) ) {
break ;
}
if ( edit . has_db_id_ ) {
db_id_ = edit . GetDbId ( ) ;
if ( db_id ! = nullptr ) {
db_id - > assign ( edit . GetDbId ( ) ) ;
}
}
s = read_buffer - > AddEdit ( & edit ) ;
if ( ! s . ok ( ) ) {
break ;
@ -4270,12 +4264,9 @@ Status VersionSet::ReadAndRecover(
// Apply edits in an atomic group when we have read all edits in the
// group.
for ( auto & e : read_buffer - > replay_buffer ( ) ) {
s = ApplyOneVersionEditToBuilder (
e , name_to_options , column_families_not_found , builders ,
have_log_number , log_number , have_prev_log_number ,
previous_log_number , have_next_file , next_file ,
have_last_sequence , last_sequence , min_log_number_to_keep ,
max_column_family ) ;
s = ApplyOneVersionEditToBuilder ( e , name_to_options ,
column_families_not_found , builders ,
version_edit_params ) ;
if ( ! s . ok ( ) ) {
break ;
}
@ -4288,11 +4279,9 @@ Status VersionSet::ReadAndRecover(
}
} else {
// Apply a normal edit immediately.
s = ApplyOneVersionEditToBuilder (
edit , name_to_options , column_families_not_found , builders ,
have_log_number , log_number , have_prev_log_number ,
previous_log_number , have_next_file , next_file , have_last_sequence ,
last_sequence , min_log_number_to_keep , max_column_family ) ;
s = ApplyOneVersionEditToBuilder ( edit , name_to_options ,
column_families_not_found , builders ,
version_edit_params ) ;
if ( s . ok ( ) ) {
recovered_edits + + ;
}
@ -4308,8 +4297,8 @@ Status VersionSet::ReadAndRecover(
}
Status VersionSet : : Recover (
const std : : vector < ColumnFamilyDescriptor > & column_families ,
bool read_only ) {
const std : : vector < ColumnFamilyDescriptor > & column_families , bool read_only ,
std : : string * db_id ) {
std : : unordered_map < std : : string , ColumnFamilyOptions > cf_name_to_options ;
for ( auto cf : column_families ) {
cf_name_to_options . insert ( { cf . name , cf . options } ) ;
@ -4348,16 +4337,6 @@ Status VersionSet::Recover(
return s ;
}
bool have_log_number = false ;
bool have_prev_log_number = false ;
bool have_next_file = false ;
bool have_last_sequence = false ;
uint64_t next_file = 0 ;
uint64_t last_sequence = 0 ;
uint64_t log_number = 0 ;
uint64_t previous_log_number = 0 ;
uint32_t max_column_family = 0 ;
uint64_t min_log_number_to_keep = 0 ;
std : : unordered_map < uint32_t , std : : unique_ptr < BaseReferencedVersionBuilder > >
builders ;
@ -4377,7 +4356,7 @@ Status VersionSet::Recover(
builders . insert (
std : : make_pair ( 0 , std : : unique_ptr < BaseReferencedVersionBuilder > (
new BaseReferencedVersionBuilder ( default_cfd ) ) ) ) ;
VersionEditParams version_edit_params ;
{
VersionSet : : LogReporter reporter ;
reporter . status = & s ;
@ -4386,33 +4365,32 @@ Status VersionSet::Recover(
Slice record ;
std : : string scratch ;
AtomicGroupReadBuffer read_buffer ;
s = ReadAndRecover (
& reader , & read_buffer , cf_name_to_options , column_families_not_found ,
builders , & have_log_number , & log_number , & have_prev_log_number ,
& previous_log_number , & have_next_file , & next_file , & have_last_sequence ,
& last_sequence , & min_log_number_to_keep , & max_column_family ) ;
s = ReadAndRecover ( & reader , & read_buffer , cf_name_to_options ,
column_families_not_found , builders ,
& version_edit_params , db_id ) ;
}
if ( s . ok ( ) ) {
if ( ! have_next_file ) {
if ( ! version_edit_params . has_next_file_number_ ) {
s = Status : : Corruption ( " no meta-nextfile entry in descriptor " ) ;
} else if ( ! ha ve_log_number) {
} else if ( ! version_edit_params . has _log_number_ ) {
s = Status : : Corruption ( " no meta-lognumber entry in descriptor " ) ;
} else if ( ! ha ve_last_sequence) {
} else if ( ! version_edit_params . has _last_sequence_ ) {
s = Status : : Corruption ( " no last-sequence-number entry in descriptor " ) ;
}
if ( ! ha ve_prev_log_number) {
previous_log_number = 0 ;
if ( ! version_edit_params . has _prev_log_number_ ) {
version_edit_params . SetPrevLogNumber ( 0 ) ;
}
column_family_set_ - > UpdateMaxColumnFamily ( max_column_family ) ;
column_family_set_ - > UpdateMaxColumnFamily (
version_edit_params . max_column_family_ ) ;
// When reading DB generated using old release, min_log_number_to_keep=0.
// All log files will be scanned for potential prepare entries.
MarkMinLogNumberToKeep2PC ( min_log_number_to_keep ) ;
MarkFileNumberUsed ( previous _log_number ) ;
MarkFileNumberUsed ( log_number ) ;
MarkMinLogNumberToKeep2PC ( version_edit_params . min_log_number_to_keep_ ) ;
MarkFileNumberUsed ( version_edit_params . prev_log_number_ ) ;
MarkFileNumberUsed ( version_edit_params . log_number_ ) ;
}
// there were some column families in the MANIFEST that weren't specified
@ -4473,11 +4451,11 @@ Status VersionSet::Recover(
}
manifest_file_size_ = current_manifest_file_size ;
next_file_number_ . store ( next_file + 1 ) ;
last_allocated_sequence_ = last_sequence ;
last_published_sequence_ = last_sequence ;
last_sequence_ = last_sequence ;
prev_log_number_ = previous _log_number ;
next_file_number_ . store ( version_edit_params . next_file_number_ + 1 ) ;
last_allocated_sequence_ = version_edit_params . last_sequence_ ;
last_published_sequence_ = version_edit_params . last_sequence_ ;
last_sequence_ = version_edit_params . last_sequence_ ;
prev_log_number_ = version_edit_params . prev_log_number_ ;
ROCKS_LOG_INFO (
db_options_ - > info_log ,
@ -4487,8 +4465,9 @@ Status VersionSet::Recover(
" ,prev_log_number is % " PRIu64 " ,max_column_family is % " PRIu32
" ,min_log_number_to_keep is % " PRIu64 " \n " ,
manifest_path . c_str ( ) , manifest_file_number_ , next_file_number_ . load ( ) ,
last_sequence_ . load ( ) , log_number , prev_log_number_ ,
column_family_set_ - > GetMaxColumnFamily ( ) , min_log_number_to_keep_2pc ( ) ) ;
last_sequence_ . load ( ) , version_edit_params . log_number_ ,
prev_log_number_ , column_family_set_ - > GetMaxColumnFamily ( ) ,
min_log_number_to_keep_2pc ( ) ) ;
for ( auto cfd : * column_family_set_ ) {
if ( cfd - > IsDropped ( ) ) {
@ -4633,7 +4612,7 @@ Status VersionSet::ReduceNumberOfLevels(const std::string& dbname,
}
// we need to allocate an array with the old number of levels size to
// avoid SIGSEGV in WriteSnapsho t()
// avoid SIGSEGV in WriteCurrentStatetoManifes t()
// however, all levels bigger or equal to new_levels will be empty
std : : vector < FileMetaData * > * new_files_list =
new std : : vector < FileMetaData * > [ current_levels ] ;
@ -4873,7 +4852,6 @@ void VersionSet::MarkFileNumberUsed(uint64_t number) {
next_file_number_ . store ( number + 1 , std : : memory_order_relaxed ) ;
}
}
// Called only either from ::LogAndApply which is protected by mutex or during
// recovery which is single-threaded.
void VersionSet : : MarkMinLogNumberToKeep2PC ( uint64_t number ) {
@ -4882,7 +4860,7 @@ void VersionSet::MarkMinLogNumberToKeep2PC(uint64_t number) {
}
}
Status VersionSet : : WriteSnapsho t ( log : : Writer * log ) {
Status VersionSet : : WriteCurrentStateToManifes t ( log : : Writer * log ) {
// TODO: Break up into multiple records to reduce memory usage on recovery?
// WARNING: This method doesn't hold a mutex!!
@ -4890,6 +4868,22 @@ Status VersionSet::WriteSnapshot(log::Writer* log) {
// This is done without DB mutex lock held, but only within single-threaded
// LogAndApply. Column family manipulations can only happen within LogAndApply
// (the same single thread), so we're safe to iterate.
if ( db_options_ - > write_dbid_to_manifest ) {
VersionEdit edit_for_db_id ;
assert ( ! db_id_ . empty ( ) ) ;
edit_for_db_id . SetDBId ( db_id_ ) ;
std : : string db_id_record ;
if ( ! edit_for_db_id . EncodeTo ( & db_id_record ) ) {
return Status : : Corruption ( " Unable to Encode VersionEdit: " +
edit_for_db_id . DebugString ( true ) ) ;
}
Status add_record = log - > AddRecord ( db_id_record ) ;
if ( ! add_record . ok ( ) ) {
return add_record ;
}
}
for ( auto cfd : * column_family_set_ ) {
if ( cfd - > IsDropped ( ) ) {
continue ;
@ -4943,7 +4937,6 @@ Status VersionSet::WriteSnapshot(log::Writer* log) {
}
}
}
return Status : : OK ( ) ;
}
@ -5467,17 +5460,6 @@ Status ReactiveVersionSet::Recover(
// In recovery, nobody else can access it, so it's fine to set it to be
// initialized earlier.
default_cfd - > set_initialized ( ) ;
bool have_log_number = false ;
bool have_prev_log_number = false ;
bool have_next_file = false ;
bool have_last_sequence = false ;
uint64_t next_file = 0 ;
uint64_t last_sequence = 0 ;
uint64_t log_number = 0 ;
uint64_t previous_log_number = 0 ;
uint32_t max_column_family = 0 ;
uint64_t min_log_number_to_keep = 0 ;
std : : unordered_map < uint32_t , std : : unique_ptr < BaseReferencedVersionBuilder > >
builders ;
std : : unordered_map < int , std : : string > column_families_not_found ;
@ -5493,17 +5475,17 @@ Status ReactiveVersionSet::Recover(
log : : Reader * reader = manifest_reader - > get ( ) ;
int retry = 0 ;
VersionEdit version_edit ;
while ( s . ok ( ) & & retry < 1 ) {
assert ( reader ! = nullptr ) ;
Slice record ;
std : : string scratch ;
s = ReadAndRecover (
reader , & read_buffer_ , cf_name_to_options , column_families_not_found ,
builders , & have_log_number , & log_number , & have_prev_log_number ,
& previous_log_number , & have_next_file , & next_file , & have_last_sequence ,
& last_sequence , & min_log_number_to_keep , & max_column_family ) ;
s = ReadAndRecover ( reader , & read_buffer_ , cf_name_to_options ,
column_families_not_found , builders , & version_edit ) ;
if ( s . ok ( ) ) {
bool enough = have_next_file & & have_log_number & & have_last_sequence ;
bool enough = version_edit . has_next_file_number_ & &
version_edit . has_log_number_ & &
version_edit . has_last_sequence_ ;
if ( enough ) {
for ( const auto & cf : column_families ) {
auto cfd = column_family_set_ - > GetColumnFamily ( cf . name ) ;
@ -5545,14 +5527,14 @@ Status ReactiveVersionSet::Recover(
}
if ( s . ok ( ) ) {
if ( ! have_prev_log_number ) {
previous_log_number = 0 ;
if ( ! version_edit . has_prev_log_number_ ) {
version_edit . prev_log_number_ = 0 ;
}
column_family_set_ - > UpdateMaxColumnFamily ( max_column_family ) ;
column_family_set_ - > UpdateMaxColumnFamily ( version_edit . max_column_family_ ) ;
MarkMinLogNumberToKeep2PC ( min_log_number_to_keep ) ;
MarkFileNumberUsed ( previous_log_number ) ;
MarkFileNumberUsed ( log_number ) ;
MarkMinLogNumberToKeep2PC ( version_edit . min_log_number_to_keep_ ) ;
MarkFileNumberUsed ( version_edit . prev_log_number_ ) ;
MarkFileNumberUsed ( version_edit . log_number_ ) ;
for ( auto cfd : * column_family_set_ ) {
assert ( builders . count ( cfd - > GetID ( ) ) > 0 ) ;
@ -5585,11 +5567,11 @@ Status ReactiveVersionSet::Recover(
! ( db_options_ - > skip_stats_update_on_db_open ) ) ;
AppendVersion ( cfd , v ) ;
}
next_file_number_ . store ( next_file + 1 ) ;
last_allocated_sequence_ = last_sequence ;
last_published_sequence_ = last_sequence ;
last_sequence_ = last_sequence ;
prev_log_number_ = previous_log_number ;
next_file_number_ . store ( version_edit . next_file_number_ + 1 ) ;
last_allocated_sequence_ = version_edit . last_sequence_ ;
last_published_sequence_ = version_edit . last_sequence_ ;
last_sequence_ = version_edit . last_sequence_ ;
prev_log_number_ = version_edit . prev_log_number_ ;
for ( auto cfd : * column_family_set_ ) {
if ( cfd - > IsDropped ( ) ) {
continue ;
@ -5611,16 +5593,6 @@ Status ReactiveVersionSet::ReadAndApply(
mu - > AssertHeld ( ) ;
Status s ;
bool have_log_number = false ;
bool have_prev_log_number = false ;
bool have_next_file = false ;
bool have_last_sequence = false ;
uint64_t next_file = 0 ;
uint64_t last_sequence = 0 ;
uint64_t log_number = 0 ;
uint64_t previous_log_number = 0 ;
uint32_t max_column_family = 0 ;
uint64_t min_log_number_to_keep = 0 ;
uint64_t applied_edits = 0 ;
while ( s . ok ( ) ) {
Slice record ;
@ -5635,7 +5607,7 @@ Status ReactiveVersionSet::ReadAndApply(
}
// Skip the first VersionEdits of each MANIFEST generated by
// VersionSet::WriteSnapsho t.
// VersionSet::WriteCurrentStatetoManifes t.
if ( number_of_edits_to_skip_ > 0 ) {
ColumnFamilyData * cfd =
column_family_set_ - > GetColumnFamily ( edit . column_family_ ) ;
@ -5649,16 +5621,13 @@ Status ReactiveVersionSet::ReadAndApply(
if ( ! s . ok ( ) ) {
break ;
}
VersionEdit temp_edit ;
if ( edit . is_in_atomic_group_ ) {
if ( read_buffer_ . IsFull ( ) ) {
// Apply edits in an atomic group when we have read all edits in the
// group.
for ( auto & e : read_buffer_ . replay_buffer ( ) ) {
s = ApplyOneVersionEditToBuilder (
e , cfds_changed , & have_log_number , & log_number ,
& have_prev_log_number , & previous_log_number , & have_next_file ,
& next_file , & have_last_sequence , & last_sequence ,
& min_log_number_to_keep , & max_column_family ) ;
s = ApplyOneVersionEditToBuilder ( e , cfds_changed , & temp_edit ) ;
if ( ! s . ok ( ) ) {
break ;
}
@ -5671,11 +5640,7 @@ Status ReactiveVersionSet::ReadAndApply(
}
} else {
// Apply a normal edit immediately.
s = ApplyOneVersionEditToBuilder (
edit , cfds_changed , & have_log_number , & log_number ,
& have_prev_log_number , & previous_log_number , & have_next_file ,
& next_file , & have_last_sequence , & last_sequence ,
& min_log_number_to_keep , & max_column_family ) ;
s = ApplyOneVersionEditToBuilder ( edit , cfds_changed , & temp_edit ) ;
if ( s . ok ( ) ) {
applied_edits + + ;
}
@ -5700,28 +5665,32 @@ Status ReactiveVersionSet::ReadAndApply(
break ;
} else {
// We have switched to a new MANIFEST whose first records have been
// generated by VersionSet::WriteSnapshot. Since the secondary instanc e
// has already finished recovering upon start, there is no need for th e
// secondary to process these records. Actually, if the secondary were
// to replay these records, the secondary may end up adding the same
// SST files AGAIN to each column family, causing consistency checks
// done by VersionBuilder to fail. Therefore, we record the number of
// records to skip at the beginning of the new MANIFEST and ignore
// them.
// generated by VersionSet::WriteCurrentStatetoManifest. Since th e
// secondary instance has already finished recovering upon start, there
// is no need for the secondary to process these records. Actually, if
// the secondary were t o replay these records, the secondary may end up
// adding the same SST files AGAIN to each column family, causing
// consistency checks done by VersionBuilder to fail. Therefore, we
// record the number of record s to skip at the beginning of the new
// MANIFEST and ignore them.
number_of_edits_to_skip_ = 0 ;
for ( auto * cfd : * column_family_set_ ) {
if ( cfd - > IsDropped ( ) ) {
continue ;
}
// Increase number_of_edits_to_skip by 2 because WriteSnapshot()
// writes 2 version edits for each column family at the beginning of
// the newly-generated MANIFEST.
// Increase number_of_edits_to_skip by 2 because
// WriteCurrentStatetoManifest() writes 2 version edits for each
// column family at the beginning of the newly-generated MANIFEST.
// TODO(yanqin) remove hard-coded value.
if ( db_options_ - > write_dbid_to_manifest ) {
number_of_edits_to_skip_ + = 3 ;
} else {
number_of_edits_to_skip_ + = 2 ;
}
}
}
}
}
if ( s . ok ( ) ) {
for ( auto cfd : * column_family_set_ ) {
@ -5744,10 +5713,7 @@ Status ReactiveVersionSet::ReadAndApply(
Status ReactiveVersionSet : : ApplyOneVersionEditToBuilder (
VersionEdit & edit , std : : unordered_set < ColumnFamilyData * > * cfds_changed ,
bool * have_log_number , uint64_t * log_number , bool * have_prev_log_number ,
uint64_t * previous_log_number , bool * have_next_file , uint64_t * next_file ,
bool * have_last_sequence , SequenceNumber * last_sequence ,
uint64_t * min_log_number_to_keep , uint32_t * max_column_family ) {
VersionEdit * version_edit ) {
ColumnFamilyData * cfd =
column_family_set_ - > GetColumnFamily ( edit . column_family_ ) ;
@ -5794,10 +5760,7 @@ Status ReactiveVersionSet::ApplyOneVersionEditToBuilder(
return s ;
}
}
Status s = ExtractInfoFromVersionEdit (
cfd , edit , have_log_number , log_number , have_prev_log_number ,
previous_log_number , have_next_file , next_file , have_last_sequence ,
last_sequence , min_log_number_to_keep , max_column_family ) ;
Status s = ExtractInfoFromVersionEdit ( cfd , edit , version_edit ) ;
if ( ! s . ok ( ) ) {
return s ;
}
@ -5830,23 +5793,23 @@ Status ReactiveVersionSet::ApplyOneVersionEditToBuilder(
// Some other error has occurred during LoadTableHandlers.
}
if ( ha ve_next_file) {
next_file_number_ . store ( * next_file + 1 ) ;
if ( version_edit - > has _next_file_number ( ) ) {
next_file_number_ . store ( version_edit - > next_file_number_ + 1 ) ;
}
if ( ha ve_last_sequence) {
last_allocated_sequence_ = * last_sequence ;
last_published_sequence_ = * last_sequence ;
last_sequence_ = * last_sequence ;
if ( version_edit - > has _last_sequence_ ) {
last_allocated_sequence_ = version_edit - > last_sequence_ ;
last_published_sequence_ = version_edit - > last_sequence_ ;
last_sequence_ = version_edit - > last_sequence_ ;
}
if ( ha ve_prev_log_number) {
prev_log_number_ = * previous_log_number ;
MarkFileNumberUsed ( * previous_log_number ) ;
if ( version_edit - > has _prev_log_number_ ) {
prev_log_number_ = version_edit - > prev_log_number_ ;
MarkFileNumberUsed ( version_edit - > prev_log_number_ ) ;
}
if ( ha ve_log_number) {
MarkFileNumberUsed ( * log_number ) ;
if ( version_edit - > has _log_number_ ) {
MarkFileNumberUsed ( version_edit - > log_number_ ) ;
}
column_family_set_ - > UpdateMaxColumnFamily ( * max_column_family ) ;
MarkMinLogNumberToKeep2PC ( * min_log_number_to_keep ) ;
column_family_set_ - > UpdateMaxColumnFamily ( version_edit - > max_column_family_ ) ;
MarkMinLogNumberToKeep2PC ( version_edit - > min_log_number_to_keep_ ) ;
return s ;
}
@ -5890,8 +5853,8 @@ Status ReactiveVersionSet::MaybeSwitchManifest(
// TODO (yanqin) every time we switch to a new MANIFEST, we clear the
// active_version_builders_ map because we choose to construct the
// versions from scratch, thanks to the first part of each MANIFEST
// written by VersionSet::WriteSnapshot. This is not necessary, but we
// choose this at present for the sake of simplicity.
// written by VersionSet::WriteCurrentStatetoManifest. This is not
// necessary, but we choose this at present for the sake of simplicity.
active_version_builders_ . clear ( ) ;
}
} while ( s . IsPathNotFound ( ) ) ;