From ce0e03a800e759bb534affe5122f1b3b8dd24204 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Tue, 5 May 2020 22:04:20 +0000 Subject: [PATCH] Add virtual destructor to SpecialKeyRangeBaseImpl --- fdbclient/DatabaseContext.h | 8 ++++---- fdbclient/NativeAPI.actor.cpp | 17 ++++++++++------- fdbclient/ReadYourWrites.actor.cpp | 2 -- fdbclient/SpecialKeySpace.actor.h | 2 ++ .../SpecialKeySpaceCorrectness.actor.cpp | 2 +- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/fdbclient/DatabaseContext.h b/fdbclient/DatabaseContext.h index fafe04da39..184d1f1fae 100644 --- a/fdbclient/DatabaseContext.h +++ b/fdbclient/DatabaseContext.h @@ -229,10 +229,10 @@ public: double detailedHealthMetricsLastUpdated; UniqueOrderedOptionList transactionDefaults; - std::shared_ptr specialKeySpace; - std::shared_ptr cKImpl; - std::shared_ptr rCRImpl; - std::shared_ptr wCRImpl; + + std::vector> specialKeySpaceModules; + std::unique_ptr specialKeySpace; + void registerSpecialKeySpaceModule(std::unique_ptr module); }; #endif diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index 738f64624f..bf0ab6bcb4 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -493,6 +493,12 @@ ACTOR static Future getHealthMetricsActor(DatabaseContext *cx, bo Future DatabaseContext::getHealthMetrics(bool detailed = false) { return getHealthMetricsActor(this, detailed); } + +void DatabaseContext::registerSpecialKeySpaceModule(std::unique_ptr module) { + specialKeySpace->registerKeyRange(module->getKeyRange(), module.get()); + specialKeySpaceModules.push_back(std::move(module)); +} + DatabaseContext::DatabaseContext(Reference>> connectionFile, Reference> clientInfo, Future clientInfoMonitor, TaskPriority taskID, LocalityData const& clientLocality, @@ -527,10 +533,7 @@ DatabaseContext::DatabaseContext(Reference(normalKeys.begin, specialKeys.end)), - cKImpl(std::make_shared(conflictingKeysRange)), - rCRImpl(std::make_shared(readConflictRangeKeysRange)), - wCRImpl(std::make_shared(writeConflictRangeKeysRange)) { + specialKeySpace(std::make_unique(normalKeys.begin, specialKeys.end)) { dbId = deterministicRandom()->randomUniqueID(); connected = clientInfo->get().proxies.size() ? Void() : clientInfo->onChange(); @@ -550,9 +553,9 @@ DatabaseContext::DatabaseContext(ReferenceregisterKeyRange(conflictingKeysRange, cKImpl.get()); - specialKeySpace->registerKeyRange(readConflictRangeKeysRange, rCRImpl.get()); - specialKeySpace->registerKeyRange(writeConflictRangeKeysRange, wCRImpl.get()); + registerSpecialKeySpaceModule(std::make_unique(conflictingKeysRange)); + registerSpecialKeySpaceModule(std::make_unique(readConflictRangeKeysRange)); + registerSpecialKeySpaceModule(std::make_unique(writeConflictRangeKeysRange)); } } diff --git a/fdbclient/ReadYourWrites.actor.cpp b/fdbclient/ReadYourWrites.actor.cpp index 6a065dec8f..705f46f8a8 100644 --- a/fdbclient/ReadYourWrites.actor.cpp +++ b/fdbclient/ReadYourWrites.actor.cpp @@ -1290,9 +1290,7 @@ Future< Standalone > ReadYourWritesTransaction::getRange( bool snapshot, bool reverse ) { - if (getDatabase()->apiVersionAtLeast(630)) { - // special key space are only allowed to query if both begin and end are in \xff\xff, \xff\xff\xff if (specialKeys.contains(begin.getKey()) && end.getKey() <= specialKeys.end) return getDatabase()->specialKeySpace->getRange(Reference::addRef(this), begin, end, limits, reverse); diff --git a/fdbclient/SpecialKeySpace.actor.h b/fdbclient/SpecialKeySpace.actor.h index d3787f334f..d6bef5d1e5 100644 --- a/fdbclient/SpecialKeySpace.actor.h +++ b/fdbclient/SpecialKeySpace.actor.h @@ -44,6 +44,8 @@ public: ACTOR Future normalizeKeySelectorActor(const SpecialKeyRangeBaseImpl* pkrImpl, Reference ryw, KeySelector* ks); + virtual ~SpecialKeyRangeBaseImpl() {} + protected: KeyRange range; // underlying key range for this function }; diff --git a/fdbserver/workloads/SpecialKeySpaceCorrectness.actor.cpp b/fdbserver/workloads/SpecialKeySpaceCorrectness.actor.cpp index 48e6b8d20c..77744434c4 100644 --- a/fdbserver/workloads/SpecialKeySpaceCorrectness.actor.cpp +++ b/fdbserver/workloads/SpecialKeySpaceCorrectness.actor.cpp @@ -75,7 +75,7 @@ struct SpecialKeySpaceCorrectnessWorkload : TestWorkload { double getCheckTimeout() override { return std::numeric_limits::max(); } Future _setup(Database cx, SpecialKeySpaceCorrectnessWorkload* self) { - cx->specialKeySpace = std::make_shared(); + cx->specialKeySpace = std::make_unique(); if (self->clientId == 0) { self->ryw = Reference(new ReadYourWritesTransaction(cx)); self->ryw->setOption(FDBTransactionOptions::SPECIAL_KEY_SPACE_RELAXED);