diff --git a/cloud/replication_test.cc b/cloud/replication_test.cc index 740054735b6..0adb9af20e8 100644 --- a/cloud/replication_test.cc +++ b/cloud/replication_test.cc @@ -1315,13 +1315,15 @@ TEST_F(ReplicationTest, SuperSnapshot) { ASSERT_OK(follower->Get(ro, "k1", &val)); EXPECT_EQ(val, "v1"); - auto iter = follower->NewIterator(ro, follower->DefaultColumnFamily()); + auto iter = std::unique_ptr( + follower->NewIterator(ro, follower->DefaultColumnFamily())); iter->SeekToFirst(); EXPECT_TRUE(iter->Valid()); EXPECT_EQ(iter->key(), "k1"); EXPECT_EQ(iter->value(), "v1"); iter->Next(); EXPECT_FALSE(iter->Valid()); + iter.reset(); ro.snapshot = nullptr; ASSERT_OK(follower->Get(ro, followerCF("cf1"), "cf1k1", &val)); diff --git a/db/db_impl/db_impl.cc b/db/db_impl/db_impl.cc index 2af3fcf42be..1a784212a98 100644 --- a/db/db_impl/db_impl.cc +++ b/db/db_impl/db_impl.cc @@ -4077,6 +4077,8 @@ Status DBImpl::GetSuperSnapshots( return Status::InvalidArgument( "GetSuperSnapshots only supported in RocksDB compiled with USE_RTTI=1"); #endif + InstrumentedMutexLock l(&mutex_); + if (!is_snapshot_supported_) { return Status::InvalidArgument("Snapshot not supported"); } @@ -4092,7 +4094,8 @@ Status DBImpl::GetSuperSnapshots( for (auto& cf : column_families) { auto cfh = static_cast_with_check(cf); auto cfd = cfh->cfd(); - auto sv = cfd->GetReferencedSuperVersion(this); + auto sv = cfd->GetSuperVersion(); + sv->Ref(); auto ss = new SuperSnapshotImpl(cfd, sv); snapshots_.New(ss, snapshot_seq, unix_time, /*is_write_conflict_boundary=*/false);