Skip to content

Commit

Permalink
Deal with iter errors
Browse files Browse the repository at this point in the history
Signed-off-by: v01dstar <[email protected]>
  • Loading branch information
v01dstar committed May 16, 2024
1 parent d362e9e commit 1c4a741
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/blob_file_iterator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ void BlobFileIterator::PrefetchAndGet() {
while (readahead_end_offset_ + readahead_size_ <= min_blob_size &&
readahead_size_ < kMaxReadaheadSize)
readahead_size_ <<= 1;
file_->Prefetch(readahead_end_offset_, readahead_size_);
status_ = file_->Prefetch(readahead_end_offset_, readahead_size_);
if (!status_.ok()) return;
readahead_end_offset_ += readahead_size_;
readahead_size_ = std::min(kMaxReadaheadSize, readahead_size_ << 1);
}
Expand Down
29 changes: 18 additions & 11 deletions src/blob_gc_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,14 @@ Status BlobGCJob::HolePunchSingleBlobFile(std::shared_ptr<BlobFileMeta> file) {
std::unique_ptr<BlobFileIterator> iter(
new BlobFileIterator(std::move(file_reader), file->file_number(),
file->file_size(), blob_gc_->titan_cf_options()));
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
iter->SeekToFirst();
if (!iter->status().ok()) {
return iter->status();
}
TITAN_LOG_INFO(db_options_.info_log,
"Hole punch file %" PRIu64 " iterator created",
file->file_number());
for (; iter->Valid(); iter->Next()) {
if (IsShutingDown()) {
return Status::ShutdownInProgress();
}
Expand Down Expand Up @@ -221,6 +228,9 @@ Status BlobGCJob::HolePunchSingleBlobFile(std::shared_ptr<BlobFileMeta> file) {
return Status::NotSupported("Hole punch not supported");
#endif
}
if (!iter->status().ok()) {
return iter->status();
}
hole_punched_files_map_[file->file_number()] = live_blocks;
return Status::OK();
}
Expand Down Expand Up @@ -467,7 +477,7 @@ Status BlobGCJob::DiscardEntry(const Slice& key, const BlobIndex& blob_index,
// added to db before we rewrite any key to LSM
Status BlobGCJob::Finish() {
Status s;
{
if (!blob_gc_->use_punch_hole()) {
mutex_->Unlock();
s = InstallOutputBlobFiles();
if (s.ok()) {
Expand All @@ -486,8 +496,12 @@ Status BlobGCJob::Finish() {
s.ToString().c_str());
}
mutex_->Lock();
}
if (blob_gc_->use_punch_hole()) {
if (s.ok() && !blob_gc_->GetColumnFamilyData()->IsDropped()) {
TEST_SYNC_POINT("BlobGCJob::Finish::BeforeDeleteInputBlobFiles");
s = DeleteInputBlobFiles();
}
TEST_SYNC_POINT("BlobGCJob::Finish::AfterRewriteValidKeyToLSM");
} else {
TITAN_LOG_INFO(db_options_.info_log,
"Titan GC job finished, before batch updates");
// It is possible that while processing the GC job, the input blob files'
Expand Down Expand Up @@ -515,13 +529,6 @@ Status BlobGCJob::Finish() {
s = blob_file_manager_->BatchUpdateFiles(hole_punched_files);
}
}
if (s.ok() && !blob_gc_->GetColumnFamilyData()->IsDropped() &&
!blob_gc_->use_punch_hole()) {
TEST_SYNC_POINT("BlobGCJob::Finish::BeforeDeleteInputBlobFiles");
s = DeleteInputBlobFiles();
}
TEST_SYNC_POINT("BlobGCJob::Finish::AfterRewriteValidKeyToLSM");

if (s.ok()) {
UpdateInternalOpStats();
}
Expand Down

0 comments on commit 1c4a741

Please sign in to comment.