diff --git a/db/db_impl_write.cc b/db/db_impl_write.cc index 74f0fea5e..86c29c34d 100644 --- a/db/db_impl_write.cc +++ b/db/db_impl_write.cc @@ -142,7 +142,7 @@ Status DBImpl::WriteImpl(const WriteOptions& write_options, WriteContext write_context; WriteThread::WriteGroup write_group; bool in_parallel_group = false; - uint64_t last_sequence; + uint64_t last_sequence = kMaxSequenceNumber; if (!concurrent_prepare_) { last_sequence = versions_->LastSequence(); } @@ -247,6 +247,7 @@ Status DBImpl::WriteImpl(const WriteOptions& write_options, last_sequence = versions_->FetchAddLastToBeWrittenSequence(total_count); } } + assert(last_sequence != kMaxSequenceNumber); const SequenceNumber current_sequence = last_sequence + 1; last_sequence += total_count; diff --git a/db/db_iter.cc b/db/db_iter.cc index 37be16ab0..a64a355e7 100644 --- a/db/db_iter.cc +++ b/db/db_iter.cc @@ -644,6 +644,7 @@ void DBIter::ReverseToBackward() { while (iter_->Valid() && user_comparator_->Compare(ikey.user_key, saved_key_.GetUserKey()) > 0) { + assert(ikey.sequence != kMaxSequenceNumber); if (ikey.sequence > sequence_) { PERF_COUNTER_ADD(internal_recent_skipped_count, 1); } else { @@ -956,6 +957,7 @@ void DBIter::FindPrevUserKey() { ++num_skipped; } } + assert(ikey.sequence != kMaxSequenceNumber); if (ikey.sequence > sequence_) { PERF_COUNTER_ADD(internal_recent_skipped_count, 1); } else { diff --git a/db/dbformat.h b/db/dbformat.h index 0e4367c3c..ff40ab015 100644 --- a/db/dbformat.h +++ b/db/dbformat.h @@ -80,7 +80,9 @@ struct ParsedInternalKey { SequenceNumber sequence; ValueType type; - ParsedInternalKey() { } // Intentionally left uninitialized (for speed) + ParsedInternalKey() + : sequence(kMaxSequenceNumber) // Make code analyzer happy + {} // Intentionally left uninitialized (for speed) ParsedInternalKey(const Slice& u, const SequenceNumber& seq, ValueType t) : user_key(u), sequence(seq), type(t) { } std::string DebugString(bool hex = false) const; diff --git a/utilities/blob_db/blob_db_impl.cc b/utilities/blob_db/blob_db_impl.cc index a80b1e9bb..90277b5b9 100644 --- a/utilities/blob_db/blob_db_impl.cc +++ b/utilities/blob_db/blob_db_impl.cc @@ -1230,7 +1230,7 @@ Status BlobDBImpl::CommonGet(const ColumnFamilyData* cfd, const Slice& key, } // 0 - size - if (!handle.size()) { + if (!handle.size() && value != nullptr) { value->clear(); return Status::OK(); } diff --git a/utilities/blob_db/blob_db_test.cc b/utilities/blob_db/blob_db_test.cc index 3ce68e8e0..b2db9cb97 100644 --- a/utilities/blob_db/blob_db_test.cc +++ b/utilities/blob_db/blob_db_test.cc @@ -35,17 +35,7 @@ class BlobDBTest : public testing::Test { void Open(BlobDBOptionsImpl bdb_options = BlobDBOptionsImpl(), Options options = Options()) { options.create_if_missing = true; - Reopen(bdb_options, options); - } - - void Reopen(BlobDBOptionsImpl bdb_options = BlobDBOptionsImpl(), - Options options = Options()) { - if (blob_db_) { - delete blob_db_; - blob_db_ = nullptr; - } ASSERT_OK(BlobDB::Open(options, bdb_options, dbname_, &blob_db_)); - ASSERT_TRUE(blob_db_); } void Destroy() {