Skip to content

Commit f3d9ebb

Browse files
authored
Merge pull request facebook#23 from cockroachdb/fsync-errs
Store the return value of Fsync for check
2 parents 94691be + c4e711a commit f3d9ebb

File tree

5 files changed

+21
-17
lines changed

5 files changed

+21
-17
lines changed

db/compaction_job.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -547,10 +547,6 @@ Status CompactionJob::Run() {
547547
thread.join();
548548
}
549549

550-
if (output_directory_) {
551-
output_directory_->Fsync();
552-
}
553-
554550
compaction_stats_.micros = env_->NowMicros() - start_micros;
555551
MeasureTime(stats_, COMPACTION_TIME, compaction_stats_.micros);
556552

@@ -563,6 +559,10 @@ Status CompactionJob::Run() {
563559
}
564560
}
565561

562+
if (status.ok() && output_directory_) {
563+
status = output_directory_->Fsync();
564+
}
565+
566566
TablePropertiesCollection tp;
567567
for (const auto& state : compact_->sub_compact_states) {
568568
for (const auto& output : state.outputs) {

db/flush_job.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ Status FlushJob::WriteLevel0Table() {
365365
s.ToString().c_str(),
366366
meta_.marked_for_compaction ? " (needs compaction)" : "");
367367

368-
if (output_file_directory_ != nullptr) {
369-
output_file_directory_->Fsync();
368+
if (s.ok() && output_file_directory_ != nullptr) {
369+
s = output_file_directory_->Fsync();
370370
}
371371
TEST_SYNC_POINT("FlushJob::WriteLevel0Table");
372372
db_mutex_->Lock();

util/filename.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ Status SetCurrentFile(Env* env, const std::string& dbname,
370370
}
371371
if (s.ok()) {
372372
if (directory_to_fsync != nullptr) {
373-
directory_to_fsync->Fsync();
373+
s = directory_to_fsync->Fsync();
374374
}
375375
} else {
376376
env->DeleteFile(tmp);

utilities/backupable/backupable_db.cc

+9-9
Original file line numberDiff line numberDiff line change
@@ -874,19 +874,19 @@ Status BackupEngineImpl::CreateNewBackupWithMetadata(
874874
GetAbsolutePath(GetPrivateFileRel(new_backup_id, false)),
875875
&backup_private_directory);
876876
if (backup_private_directory != nullptr) {
877-
backup_private_directory->Fsync();
877+
s = backup_private_directory->Fsync();
878878
}
879-
if (private_directory_ != nullptr) {
880-
private_directory_->Fsync();
879+
if (s.ok() && private_directory_ != nullptr) {
880+
s = private_directory_->Fsync();
881881
}
882-
if (meta_directory_ != nullptr) {
883-
meta_directory_->Fsync();
882+
if (s.ok() && meta_directory_ != nullptr) {
883+
s = meta_directory_->Fsync();
884884
}
885-
if (shared_directory_ != nullptr) {
886-
shared_directory_->Fsync();
885+
if (s.ok() && shared_directory_ != nullptr) {
886+
s = shared_directory_->Fsync();
887887
}
888-
if (backup_directory_ != nullptr) {
889-
backup_directory_->Fsync();
888+
if (s.ok() && backup_directory_ != nullptr) {
889+
s = backup_directory_->Fsync();
890890
}
891891
}
892892

utilities/blob_db/blob_db_impl.cc

+5-1
Original file line numberDiff line numberDiff line change
@@ -1716,7 +1716,11 @@ std::pair<bool, int64_t> BlobDBImpl::DeleteObsoleteFiles(bool aborted) {
17161716

17171717
// directory change. Fsync
17181718
if (file_deleted) {
1719-
dir_ent_->Fsync();
1719+
Status s = dir_ent_->Fsync();
1720+
if (!s.ok()) {
1721+
ROCKS_LOG_ERROR(db_options_.info_log, "Failed to sync dir %s: %s",
1722+
blob_dir_.c_str(), s.ToString().c_str());
1723+
}
17201724
}
17211725

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

0 commit comments

Comments
 (0)