Skip to content

Commit

Permalink
Store the return value of Fsync for check
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: facebook#4361

Differential Revision: D9803723

Pulled By: riversand963

fbshipit-source-id: 5a0d4cd3e57fd195571dcd5822895ee00547fa6a
  • Loading branch information
riversand963 authored and benesch committed Dec 6, 2018
1 parent 94691be commit c4e711a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
8 changes: 4 additions & 4 deletions db/compaction_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -547,10 +547,6 @@ Status CompactionJob::Run() {
thread.join();
}

if (output_directory_) {
output_directory_->Fsync();
}

compaction_stats_.micros = env_->NowMicros() - start_micros;
MeasureTime(stats_, COMPACTION_TIME, compaction_stats_.micros);

Expand All @@ -563,6 +559,10 @@ Status CompactionJob::Run() {
}
}

if (status.ok() && output_directory_) {
status = output_directory_->Fsync();
}

TablePropertiesCollection tp;
for (const auto& state : compact_->sub_compact_states) {
for (const auto& output : state.outputs) {
Expand Down
4 changes: 2 additions & 2 deletions db/flush_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ Status FlushJob::WriteLevel0Table() {
s.ToString().c_str(),
meta_.marked_for_compaction ? " (needs compaction)" : "");

if (output_file_directory_ != nullptr) {
output_file_directory_->Fsync();
if (s.ok() && output_file_directory_ != nullptr) {
s = output_file_directory_->Fsync();
}
TEST_SYNC_POINT("FlushJob::WriteLevel0Table");
db_mutex_->Lock();
Expand Down
2 changes: 1 addition & 1 deletion util/filename.cc
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ Status SetCurrentFile(Env* env, const std::string& dbname,
}
if (s.ok()) {
if (directory_to_fsync != nullptr) {
directory_to_fsync->Fsync();
s = directory_to_fsync->Fsync();
}
} else {
env->DeleteFile(tmp);
Expand Down
18 changes: 9 additions & 9 deletions utilities/backupable/backupable_db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -874,19 +874,19 @@ Status BackupEngineImpl::CreateNewBackupWithMetadata(
GetAbsolutePath(GetPrivateFileRel(new_backup_id, false)),
&backup_private_directory);
if (backup_private_directory != nullptr) {
backup_private_directory->Fsync();
s = backup_private_directory->Fsync();
}
if (private_directory_ != nullptr) {
private_directory_->Fsync();
if (s.ok() && private_directory_ != nullptr) {
s = private_directory_->Fsync();
}
if (meta_directory_ != nullptr) {
meta_directory_->Fsync();
if (s.ok() && meta_directory_ != nullptr) {
s = meta_directory_->Fsync();
}
if (shared_directory_ != nullptr) {
shared_directory_->Fsync();
if (s.ok() && shared_directory_ != nullptr) {
s = shared_directory_->Fsync();
}
if (backup_directory_ != nullptr) {
backup_directory_->Fsync();
if (s.ok() && backup_directory_ != nullptr) {
s = backup_directory_->Fsync();
}
}

Expand Down
6 changes: 5 additions & 1 deletion utilities/blob_db/blob_db_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1716,7 +1716,11 @@ std::pair<bool, int64_t> BlobDBImpl::DeleteObsoleteFiles(bool aborted) {

// directory change. Fsync
if (file_deleted) {
dir_ent_->Fsync();
Status s = dir_ent_->Fsync();
if (!s.ok()) {
ROCKS_LOG_ERROR(db_options_.info_log, "Failed to sync dir %s: %s",
blob_dir_.c_str(), s.ToString().c_str());
}
}

// put files back into obsolete if for some reason, delete failed
Expand Down

0 comments on commit c4e711a

Please sign in to comment.