diff --git a/include/rocksdb/slice.h b/include/rocksdb/slice.h index 924f1faef72d1abe2b68c12ce6a766380cab4296..38e7efb65656c70c8cfd4f57ee3b911ba28e94e1 100644 --- a/include/rocksdb/slice.h +++ b/include/rocksdb/slice.h @@ -150,6 +150,10 @@ class PinnableSlice : public Slice, public Cleanable { } else { buf_ = other.buf_; } + // Re-initialize the other PinnablaeSlice. + other.self_space_.clear(); + other.buf_ = &other.self_space_; + other.pinned_ = false; } return *this; } diff --git a/util/slice_test.cc b/util/slice_test.cc index 308e1c312ff81add43e27cbb25df0c7a40d802af..33903ec72b9cde83bb549939f4b65bfab0a836df 100644 --- a/util/slice_test.cc +++ b/util/slice_test.cc @@ -47,6 +47,7 @@ TEST_F(SliceTest, PinnableSliceMoveConstruct) { ASSERT_EQ("bar", s2->ToString()); s2->RegisterCleanup(BumpCounter, &orig_cleanup, nullptr); *s2 = std::move(*s1); + ASSERT_FALSE(s1->IsPinned()); ASSERT_EQ("foo", s2->ToString()); ASSERT_EQ(1, orig_cleanup); ASSERT_EQ(0, moved_cleanup); diff --git a/utilities/blob_db/blob_db_impl.cc b/utilities/blob_db/blob_db_impl.cc index 41c640f17e94f776b2a6cdac1aa84698ca779139..98ab4037654c586cfb6550041c733bf95eae25d1 100644 --- a/utilities/blob_db/blob_db_impl.cc +++ b/utilities/blob_db/blob_db_impl.cc @@ -1226,13 +1226,16 @@ Status BlobDBImpl::Get(const ReadOptions& read_options, Status s; bool is_blob_index = false; - s = db_impl_->GetImpl(ro, column_family, key, value, nullptr /*value_found*/, - nullptr /*read_callback*/, &is_blob_index); + PinnableSlice index_entry; + s = db_impl_->GetImpl(ro, column_family, key, &index_entry, + nullptr /*value_found*/, nullptr /*read_callback*/, + &is_blob_index); TEST_SYNC_POINT("BlobDBImpl::Get:AfterIndexEntryGet:1"); TEST_SYNC_POINT("BlobDBImpl::Get:AfterIndexEntryGet:2"); if (s.ok()) { - if (is_blob_index) { - PinnableSlice index_entry = std::move(*value); + if (!is_blob_index) { + *value = std::move(index_entry); + } else { s = GetBlobValue(key, index_entry, value); } }