|
|
@ -886,6 +886,11 @@ Status DBImpl::Recover( |
|
|
|
return s; |
|
|
|
return s; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s = env_->NewDirectory(dbname_, &db_directory_); |
|
|
|
|
|
|
|
if (!s.ok()) { |
|
|
|
|
|
|
|
return s; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
s = env_->LockFile(LockFileName(dbname_), &db_lock_); |
|
|
|
s = env_->LockFile(LockFileName(dbname_), &db_lock_); |
|
|
|
if (!s.ok()) { |
|
|
|
if (!s.ok()) { |
|
|
|
return s; |
|
|
|
return s; |
|
|
@ -1178,6 +1183,9 @@ Status DBImpl::WriteLevel0Table(std::vector<MemTable*> &mems, VersionEdit* edit, |
|
|
|
(unsigned long) meta.number, |
|
|
|
(unsigned long) meta.number, |
|
|
|
(unsigned long) meta.file_size, |
|
|
|
(unsigned long) meta.file_size, |
|
|
|
s.ToString().c_str()); |
|
|
|
s.ToString().c_str()); |
|
|
|
|
|
|
|
if (!options_.disableDataSync) { |
|
|
|
|
|
|
|
db_directory_->Fsync(); |
|
|
|
|
|
|
|
} |
|
|
|
mutex_.Lock(); |
|
|
|
mutex_.Lock(); |
|
|
|
} |
|
|
|
} |
|
|
|
base->Unref(); |
|
|
|
base->Unref(); |
|
|
@ -1272,8 +1280,8 @@ Status DBImpl::FlushMemTableToOutputFile(bool* madeProgress, |
|
|
|
|
|
|
|
|
|
|
|
// Replace immutable memtable with the generated Table
|
|
|
|
// Replace immutable memtable with the generated Table
|
|
|
|
s = imm_.InstallMemtableFlushResults( |
|
|
|
s = imm_.InstallMemtableFlushResults( |
|
|
|
mems, versions_.get(), s, &mutex_, options_.info_log.get(), |
|
|
|
mems, versions_.get(), s, &mutex_, options_.info_log.get(), file_number, |
|
|
|
file_number, pending_outputs_, &deletion_state.memtables_to_free); |
|
|
|
pending_outputs_, &deletion_state.memtables_to_free, db_directory_.get()); |
|
|
|
|
|
|
|
|
|
|
|
if (s.ok()) { |
|
|
|
if (s.ok()) { |
|
|
|
InstallSuperVersion(deletion_state); |
|
|
|
InstallSuperVersion(deletion_state); |
|
|
@ -1401,7 +1409,7 @@ Status DBImpl::ReFitLevel(int level, int target_level) { |
|
|
|
Log(options_.info_log, "Apply version edit:\n%s", |
|
|
|
Log(options_.info_log, "Apply version edit:\n%s", |
|
|
|
edit.DebugString().data()); |
|
|
|
edit.DebugString().data()); |
|
|
|
|
|
|
|
|
|
|
|
status = versions_->LogAndApply(&edit, &mutex_); |
|
|
|
status = versions_->LogAndApply(&edit, &mutex_, db_directory_.get()); |
|
|
|
superversion_to_free = InstallSuperVersion(new_superversion); |
|
|
|
superversion_to_free = InstallSuperVersion(new_superversion); |
|
|
|
new_superversion = nullptr; |
|
|
|
new_superversion = nullptr; |
|
|
|
|
|
|
|
|
|
|
@ -1974,7 +1982,7 @@ Status DBImpl::BackgroundCompaction(bool* madeProgress, |
|
|
|
c->edit()->AddFile(c->level() + 1, f->number, f->file_size, |
|
|
|
c->edit()->AddFile(c->level() + 1, f->number, f->file_size, |
|
|
|
f->smallest, f->largest, |
|
|
|
f->smallest, f->largest, |
|
|
|
f->smallest_seqno, f->largest_seqno); |
|
|
|
f->smallest_seqno, f->largest_seqno); |
|
|
|
status = versions_->LogAndApply(c->edit(), &mutex_); |
|
|
|
status = versions_->LogAndApply(c->edit(), &mutex_, db_directory_.get()); |
|
|
|
InstallSuperVersion(deletion_state); |
|
|
|
InstallSuperVersion(deletion_state); |
|
|
|
Version::LevelSummaryStorage tmp; |
|
|
|
Version::LevelSummaryStorage tmp; |
|
|
|
Log(options_.info_log, "Moved #%lld to level-%d %lld bytes %s: %s\n", |
|
|
|
Log(options_.info_log, "Moved #%lld to level-%d %lld bytes %s: %s\n", |
|
|
@ -2222,7 +2230,8 @@ Status DBImpl::InstallCompactionResults(CompactionState* compact) { |
|
|
|
compact->compaction->output_level(), out.number, out.file_size, |
|
|
|
compact->compaction->output_level(), out.number, out.file_size, |
|
|
|
out.smallest, out.largest, out.smallest_seqno, out.largest_seqno); |
|
|
|
out.smallest, out.largest, out.smallest_seqno, out.largest_seqno); |
|
|
|
} |
|
|
|
} |
|
|
|
return versions_->LogAndApply(compact->compaction->edit(), &mutex_); |
|
|
|
return versions_->LogAndApply(compact->compaction->edit(), &mutex_, |
|
|
|
|
|
|
|
db_directory_.get()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
@ -2595,6 +2604,9 @@ Status DBImpl::DoCompactionWork(CompactionState* compact, |
|
|
|
} |
|
|
|
} |
|
|
|
input.reset(); |
|
|
|
input.reset(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!options_.disableDataSync) { |
|
|
|
|
|
|
|
db_directory_->Fsync(); |
|
|
|
|
|
|
|
} |
|
|
|
CompactionStats stats; |
|
|
|
CompactionStats stats; |
|
|
|
stats.micros = env_->NowMicros() - start_micros - imm_micros; |
|
|
|
stats.micros = env_->NowMicros() - start_micros - imm_micros; |
|
|
|
MeasureTime(options_.statistics.get(), COMPACTION_TIME, stats.micros); |
|
|
|
MeasureTime(options_.statistics.get(), COMPACTION_TIME, stats.micros); |
|
|
@ -3886,7 +3898,7 @@ Status DBImpl::DeleteFile(std::string name) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
edit.DeleteFile(level, number); |
|
|
|
edit.DeleteFile(level, number); |
|
|
|
status = versions_->LogAndApply(&edit, &mutex_); |
|
|
|
status = versions_->LogAndApply(&edit, &mutex_, db_directory_.get()); |
|
|
|
if (status.ok()) { |
|
|
|
if (status.ok()) { |
|
|
|
InstallSuperVersion(deletion_state); |
|
|
|
InstallSuperVersion(deletion_state); |
|
|
|
} |
|
|
|
} |
|
|
@ -4032,7 +4044,8 @@ Status DB::OpenWithColumnFamilies( |
|
|
|
edit.SetLogNumber(new_log_number); |
|
|
|
edit.SetLogNumber(new_log_number); |
|
|
|
impl->logfile_number_ = new_log_number; |
|
|
|
impl->logfile_number_ = new_log_number; |
|
|
|
impl->log_.reset(new log::Writer(std::move(lfile))); |
|
|
|
impl->log_.reset(new log::Writer(std::move(lfile))); |
|
|
|
s = impl->versions_->LogAndApply(&edit, &impl->mutex_); |
|
|
|
s = impl->versions_->LogAndApply(&edit, &impl->mutex_, |
|
|
|
|
|
|
|
impl->db_directory_.get()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (s.ok()) { |
|
|
|
if (s.ok()) { |
|
|
|
// set column family handles
|
|
|
|
// set column family handles
|
|
|
@ -4053,6 +4066,7 @@ Status DB::OpenWithColumnFamilies( |
|
|
|
impl->DeleteObsoleteFiles(); |
|
|
|
impl->DeleteObsoleteFiles(); |
|
|
|
impl->MaybeScheduleFlushOrCompaction(); |
|
|
|
impl->MaybeScheduleFlushOrCompaction(); |
|
|
|
impl->MaybeScheduleLogDBDeployStats(); |
|
|
|
impl->MaybeScheduleLogDBDeployStats(); |
|
|
|
|
|
|
|
s = impl->db_directory_->Fsync(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|