Add virtual destructor to SpecialKeyRangeBaseImpl

This commit is contained in:
Andrew Noyes 2020-05-05 22:04:20 +00:00
parent de53322d20
commit ce0e03a800
5 changed files with 17 additions and 14 deletions

View File

@ -229,10 +229,10 @@ public:
double detailedHealthMetricsLastUpdated;
UniqueOrderedOptionList<FDBTransactionOptions> transactionDefaults;
std::shared_ptr<SpecialKeySpace> specialKeySpace;
std::shared_ptr<ConflictingKeysImpl> cKImpl;
std::shared_ptr<ReadConflictRangeImpl> rCRImpl;
std::shared_ptr<WriteConflictRangeImpl> wCRImpl;
std::vector<std::unique_ptr<SpecialKeyRangeBaseImpl>> specialKeySpaceModules;
std::unique_ptr<SpecialKeySpace> specialKeySpace;
void registerSpecialKeySpaceModule(std::unique_ptr<SpecialKeyRangeBaseImpl> module);
};
#endif

View File

@ -493,6 +493,12 @@ ACTOR static Future<HealthMetrics> getHealthMetricsActor(DatabaseContext *cx, bo
Future<HealthMetrics> DatabaseContext::getHealthMetrics(bool detailed = false) {
return getHealthMetricsActor(this, detailed);
}
void DatabaseContext::registerSpecialKeySpaceModule(std::unique_ptr<SpecialKeyRangeBaseImpl> module) {
specialKeySpace->registerKeyRange(module->getKeyRange(), module.get());
specialKeySpaceModules.push_back(std::move(module));
}
DatabaseContext::DatabaseContext(Reference<AsyncVar<Reference<ClusterConnectionFile>>> connectionFile,
Reference<AsyncVar<ClientDBInfo>> clientInfo, Future<Void> clientInfoMonitor,
TaskPriority taskID, LocalityData const& clientLocality,
@ -527,10 +533,7 @@ DatabaseContext::DatabaseContext(Reference<AsyncVar<Reference<ClusterConnectionF
transactionsProcessBehind("ProcessBehind", cc), outstandingWatches(0), latencies(1000), readLatencies(1000),
commitLatencies(1000), GRVLatencies(1000), mutationsPerCommit(1000), bytesPerCommit(1000), mvCacheInsertLocation(0),
healthMetricsLastUpdated(0), detailedHealthMetricsLastUpdated(0), internal(internal),
specialKeySpace(std::make_shared<SpecialKeySpace>(normalKeys.begin, specialKeys.end)),
cKImpl(std::make_shared<ConflictingKeysImpl>(conflictingKeysRange)),
rCRImpl(std::make_shared<ReadConflictRangeImpl>(readConflictRangeKeysRange)),
wCRImpl(std::make_shared<WriteConflictRangeImpl>(writeConflictRangeKeysRange)) {
specialKeySpace(std::make_unique<SpecialKeySpace>(normalKeys.begin, specialKeys.end)) {
dbId = deterministicRandom()->randomUniqueID();
connected = clientInfo->get().proxies.size() ? Void() : clientInfo->onChange();
@ -550,9 +553,9 @@ DatabaseContext::DatabaseContext(Reference<AsyncVar<Reference<ClusterConnectionF
monitorMasterProxiesInfoChange = monitorMasterProxiesChange(clientInfo, &masterProxiesChangeTrigger);
clientStatusUpdater.actor = clientStatusUpdateActor(this);
if (apiVersionAtLeast(630)) {
specialKeySpace->registerKeyRange(conflictingKeysRange, cKImpl.get());
specialKeySpace->registerKeyRange(readConflictRangeKeysRange, rCRImpl.get());
specialKeySpace->registerKeyRange(writeConflictRangeKeysRange, wCRImpl.get());
registerSpecialKeySpaceModule(std::make_unique<ConflictingKeysImpl>(conflictingKeysRange));
registerSpecialKeySpaceModule(std::make_unique<ReadConflictRangeImpl>(readConflictRangeKeysRange));
registerSpecialKeySpaceModule(std::make_unique<WriteConflictRangeImpl>(writeConflictRangeKeysRange));
}
}

View File

@ -1290,9 +1290,7 @@ Future< Standalone<RangeResultRef> > 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<ReadYourWritesTransaction>::addRef(this), begin,
end, limits, reverse);

View File

@ -44,6 +44,8 @@ public:
ACTOR Future<Void> normalizeKeySelectorActor(const SpecialKeyRangeBaseImpl* pkrImpl,
Reference<ReadYourWritesTransaction> ryw, KeySelector* ks);
virtual ~SpecialKeyRangeBaseImpl() {}
protected:
KeyRange range; // underlying key range for this function
};

View File

@ -75,7 +75,7 @@ struct SpecialKeySpaceCorrectnessWorkload : TestWorkload {
double getCheckTimeout() override { return std::numeric_limits<double>::max(); }
Future<Void> _setup(Database cx, SpecialKeySpaceCorrectnessWorkload* self) {
cx->specialKeySpace = std::make_shared<SpecialKeySpace>();
cx->specialKeySpace = std::make_unique<SpecialKeySpace>();
if (self->clientId == 0) {
self->ryw = Reference(new ReadYourWritesTransaction(cx));
self->ryw->setOption(FDBTransactionOptions::SPECIAL_KEY_SPACE_RELAXED);