From 02aa22957ab6bd392d5a7963942280159f6f81c3 Mon Sep 17 00:00:00 2001 From: Levi Tamasi Date: Tue, 17 Dec 2019 10:17:27 -0800 Subject: [PATCH] Set CompactionIterator::valid_ to false when PrepareBlobOutput indicates error Summary: With https://github.com/facebook/rocksdb/pull/6121, errors returned by `PrepareBlobValue` result in `CompactionIterator::status_` being set to `Corruption` or `IOError` as appropriate, however, `valid_` is not set to `false`. The error is eventually propagated in `CompactionJob::ProcessKeyValueCompaction` but only after the main loop completes. Setting `valid_` to `false` upon errors enables us to terminate the loop early and fail the compaction sooner. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6170 Test Plan: Ran `make check` and used `db_bench` in BlobDB mode. fbshipit-source-id: a2ca88a3ca71115e2605bd34a4c795d8a28bef27 --- db/compaction/compaction_iterator.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db/compaction/compaction_iterator.cc b/db/compaction/compaction_iterator.cc index 57bb92570..a5846349c 100644 --- a/db/compaction/compaction_iterator.cc +++ b/db/compaction/compaction_iterator.cc @@ -647,8 +647,10 @@ void CompactionIterator::PrepareOutput() { if (blob_decision == CompactionFilter::BlobDecision::kCorruption) { status_ = Status::Corruption( "Corrupted blob reference encountered during GC"); + valid_ = false; } else if (blob_decision == CompactionFilter::BlobDecision::kIOError) { status_ = Status::IOError("Could not relocate blob during GC"); + valid_ = false; } else if (blob_decision == CompactionFilter::BlobDecision::kChangeValue) { value_ = compaction_filter_value_; @@ -666,7 +668,8 @@ void CompactionIterator::PrepareOutput() { // // Can we do the same for levels above bottom level as long as // KeyNotExistsBeyondOutputLevel() return true? - if ((compaction_ != nullptr && !compaction_->allow_ingest_behind()) && + if (valid_ && compaction_ != nullptr && + !compaction_->allow_ingest_behind() && ikeyNotNeededForIncrementalSnapshot() && bottommost_level_ && IN_EARLIEST_SNAPSHOT(ikey_.sequence) && ikey_.type != kTypeMerge) { assert(ikey_.type != kTypeDeletion && ikey_.type != kTypeSingleDeletion);