Add ContainsRecommended boolean parameter

This commit is contained in:
sfc-gh-tclinkenbeard 2022-03-18 17:14:15 -07:00
parent 63ec6d5f5b
commit 6eaa20078f
4 changed files with 13 additions and 7 deletions

View File

@ -75,7 +75,7 @@ ACTOR Future<bool> throttleCommandActor(Reference<IDatabase> db, std::vector<Str
state std::vector<TagThrottleInfo> tags;
if (reportThrottled && reportRecommended) {
wait(store(tags, ThrottleApi::getThrottledTags(db, throttleListLimit, true)));
wait(store(tags, ThrottleApi::getThrottledTags(db, throttleListLimit, ContainsRecommended::True)));
} else if (reportThrottled) {
wait(store(tags, ThrottleApi::getThrottledTags(db, throttleListLimit)));
} else if (reportRecommended) {

View File

@ -110,3 +110,5 @@ TagThrottleValue TagThrottleValue::fromValue(const ValueRef& value) {
reader >> throttleValue;
return throttleValue;
}
FDB_DEFINE_BOOLEAN_PARAM(ContainsRecommended);

View File

@ -27,6 +27,7 @@
#pragma once
#include "contrib/fmt-8.1.1/include/fmt/format.h"
#include "flow/Error.h"
#include "flow/flow.h"
#include "flow/network.h"
@ -39,6 +40,8 @@
typedef StringRef TransactionTagRef;
typedef Standalone<TransactionTagRef> TransactionTag;
FDB_DECLARE_BOOLEAN_PARAM(ContainsRecommended);
class TagSet {
public:
typedef std::vector<TransactionTagRef>::const_iterator const_iterator;
@ -58,7 +61,7 @@ public:
}
template <class Context>
void save(uint8_t* out, Context& c) const {
void save(uint8_t* out, Context&) const {
uint8_t* start = out;
for (const auto& tag : *this) {
*(out++) = (uint8_t)tag.size();
@ -295,13 +298,14 @@ Future<std::vector<TagThrottleInfo>> getRecommendedTags(Reference<DB> db, int li
}
ACTOR template <class DB>
Future<std::vector<TagThrottleInfo>> getThrottledTags(Reference<DB> db, int limit, bool containsRecommend = false) {
Future<std::vector<TagThrottleInfo>>
getThrottledTags(Reference<DB> db, int limit, ContainsRecommended containsRecommended = ContainsRecommended::False) {
state Reference<typename DB::TransactionT> tr = db->createTransaction();
state bool reportAuto = containsRecommend;
state bool reportAuto = containsRecommended;
loop {
tr->setOption(FDBTransactionOptions::READ_SYSTEM_KEYS);
try {
if (!containsRecommend) {
if (!containsRecommended) {
wait(store(reportAuto, getValidAutoEnabled(tr)));
}
state typename DB::TransactionT::template FutureT<RangeResult> f = tr->getRange(

View File

@ -310,9 +310,9 @@ struct WriteTagThrottlingWorkload : KVWorkload {
state Reference<DatabaseContext> db = cx.getReference();
loop {
wait(delay(1.0));
wait(store(tags, ThrottleApi::getThrottledTags(db, CLIENT_KNOBS->TOO_MANY, true)));
wait(store(tags, ThrottleApi::getThrottledTags(db, CLIENT_KNOBS->TOO_MANY, ContainsRecommended::True)));
self->recordThrottledTags(tags);
};
}
}
static std::string setToString(const std::set<std::string>& myset) {