Incorporate code review comments + workload code cleanup
This commit is contained in:
parent
854212fe94
commit
a24ab2d4fa
|
@ -710,6 +710,7 @@ struct WaitMetricsRequest {
|
|||
// Waits for any of the given minimum or maximum metrics to be exceeded, and then returns the current values
|
||||
// Send a reversed range for min, max to receive an immediate report
|
||||
constexpr static FileIdentifier file_identifier = 1795961;
|
||||
// Setting the tenantInfo is optional; it makes the request tenant-aware.
|
||||
TenantInfo tenantInfo;
|
||||
Arena arena;
|
||||
KeyRangeRef keys;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
// When actually compiled (NO_INTELLISENSE), include the generated
|
||||
// version of this file. In intellisense use the source version.
|
||||
#include "fdbrpc/TenantName.h"
|
||||
#if defined(NO_INTELLISENSE) && !defined(FDBSERVER_BULK_SETUP_ACTOR_G_H)
|
||||
#define FDBSERVER_BULK_SETUP_ACTOR_G_H
|
||||
#include "fdbserver/workloads/BulkSetup.actor.g.h"
|
||||
|
@ -38,6 +37,7 @@
|
|||
#include "fdbserver/ServerDBInfo.h"
|
||||
#include "fdbserver/QuietDatabase.h"
|
||||
#include "fdbrpc/simulator.h"
|
||||
#include "fdbrpc/TenantName.h"
|
||||
#include "flow/actorcompiler.h" // This must be the last #include.
|
||||
|
||||
template <class T>
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "fdbclient/BlobCipher.h"
|
||||
#include "fdbclient/BlobGranuleCommon.h"
|
||||
#include "fdbrpc/TenantInfo.h"
|
||||
#include "flow/ApiVersion.h"
|
||||
#include "fmt/format.h"
|
||||
#include "fdbclient/CommitTransaction.h"
|
||||
|
@ -9878,7 +9879,7 @@ ACTOR Future<Void> metricsCore(StorageServer* self, StorageServerInterface ssi)
|
|||
loop {
|
||||
choose {
|
||||
when(state WaitMetricsRequest req = waitNext(ssi.waitMetrics.getFuture())) {
|
||||
if (req.tenantInfo.tenantId == -1 && !self->isReadable(req.keys)) {
|
||||
if (req.tenantInfo.tenantId == TenantInfo::INVALID_TENANT && !self->isReadable(req.keys)) {
|
||||
CODE_PROBE(true, "waitMetrics immediate wrong_shard_server()");
|
||||
self->sendErrorWithPenalty(req.reply, wrong_shard_server(), self->getPenalty());
|
||||
} else {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include <cstring>
|
||||
|
||||
#include "fdbrpc/TenantName.h"
|
||||
#include "fdbrpc/simulator.h"
|
||||
#include "fdbclient/FDBTypes.h"
|
||||
#include "fdbclient/SystemData.h"
|
||||
|
@ -27,6 +28,7 @@
|
|||
#include "fdbserver/workloads/BulkSetup.actor.h"
|
||||
|
||||
#include "flow/Error.h"
|
||||
#include "flow/Trace.h"
|
||||
#include "flow/actorcompiler.h" // This must be the last #include.
|
||||
|
||||
struct GetEstimatedRangeSizeWorkload : TestWorkload {
|
||||
|
@ -34,23 +36,27 @@ struct GetEstimatedRangeSizeWorkload : TestWorkload {
|
|||
double testDuration;
|
||||
Key keyPrefix;
|
||||
bool hasTenant;
|
||||
TenantName tenant;
|
||||
Optional<TenantName> tenant;
|
||||
bool checkOnly;
|
||||
|
||||
GetEstimatedRangeSizeWorkload(WorkloadContext const& wcx) : TestWorkload(wcx) {
|
||||
testDuration = getOption(options, "testDuration"_sr, 10.0);
|
||||
nodeCount = getOption(options, "nodeCount"_sr, 10000.0);
|
||||
nodeCount = getOption(options, "nodeCount"_sr, 10000);
|
||||
keyPrefix = unprintable(getOption(options, "keyPrefix"_sr, ""_sr).toString());
|
||||
hasTenant = hasOption(options, "tenant"_sr);
|
||||
tenant = getOption(options, "tenant"_sr, "DefaultTenant"_sr);
|
||||
tenant = hasTenant ? getOption(options, "tenant"_sr, "DefaultNeverUsed"_sr) : Optional<TenantName>();
|
||||
checkOnly = getOption(options, "checkOnly"_sr, false);
|
||||
}
|
||||
|
||||
std::string description() const override { return "GetEstimatedRangeSize"; }
|
||||
|
||||
Future<Void> setup(Database const& cx) override {
|
||||
if (!hasTenant) {
|
||||
if (checkOnly) {
|
||||
return Void();
|
||||
}
|
||||
// Use default values for arguments between (and including) postSetupWarming and endNodeIdx params
|
||||
// The following call to bulkSetup() assumes that we have a valid tenant.
|
||||
ASSERT(hasTenant);
|
||||
// Use default values for arguments between (and including) postSetupWarming and endNodeIdx params.
|
||||
return bulkSetup(cx,
|
||||
this,
|
||||
nodeCount,
|
||||
|
@ -64,7 +70,7 @@ struct GetEstimatedRangeSizeWorkload : TestWorkload {
|
|||
0.1,
|
||||
0,
|
||||
0,
|
||||
{ tenant });
|
||||
{ tenant.get() });
|
||||
}
|
||||
|
||||
Future<Void> start(Database const& cx) override {
|
||||
|
@ -85,40 +91,31 @@ struct GetEstimatedRangeSizeWorkload : TestWorkload {
|
|||
Standalone<KeyValueRef> operator()(int n) { return KeyValueRef(key(n), value((n + 1) % nodeCount)); }
|
||||
|
||||
ACTOR static Future<Void> checkSize(GetEstimatedRangeSizeWorkload* self, Database cx) {
|
||||
state Optional<TenantName> tenant = self->hasTenant ? self->tenant : Optional<TenantName>();
|
||||
state int64_t size = wait(getSize(self, cx, tenant));
|
||||
ASSERT(sizeIsAsExpected(size, tenant));
|
||||
state int64_t size = wait(getSize(self, cx));
|
||||
ASSERT(sizeIsAsExpected(self, size));
|
||||
return Void();
|
||||
}
|
||||
|
||||
static bool sizeIsAsExpected(int64_t size, Optional<TenantName> tenant) {
|
||||
// The following expected values are hard coded based on expected size for the
|
||||
// tenants. We use a wide range to avoid flakiness because the underlying function
|
||||
static bool sizeIsAsExpected(GetEstimatedRangeSizeWorkload* self, int64_t size) {
|
||||
int nodeSize = self->key(0).size() + self->value(0).size();
|
||||
// We use a wide range to avoid flakiness because the underlying function
|
||||
// is making an estimation.
|
||||
if (!tenant.present()) {
|
||||
return size > 10230000 / 5 && size < 10230000 * 5;
|
||||
} else if (tenant == "First"_sr) {
|
||||
return size > 8525000 / 5 && size < 8525000 * 5;
|
||||
} else if (tenant == "Second"_sr) {
|
||||
return size > 930000 / 5 && size < 930000 * 5;
|
||||
}
|
||||
return false;
|
||||
return size > self->nodeCount * nodeSize / 2 && size < self->nodeCount * nodeSize * 5;
|
||||
}
|
||||
|
||||
ACTOR static Future<int64_t> getSize(GetEstimatedRangeSizeWorkload* self,
|
||||
Database cx,
|
||||
Optional<TenantName> tenant) {
|
||||
state ReadYourWritesTransaction tr(cx, tenant);
|
||||
ACTOR static Future<int64_t> getSize(GetEstimatedRangeSizeWorkload* self, Database cx) {
|
||||
state ReadYourWritesTransaction tr(cx, self->tenant);
|
||||
state double totalDelay = 0.0;
|
||||
TraceEvent(SevDebug, "GetSize1").detail("Tenant", tr.getTenant().present() ? tr.getTenant().get() : "none"_sr);
|
||||
TraceEvent(SevDebug, "GetSizeStart")
|
||||
.detail("Tenant", tr.getTenant().present() ? tr.getTenant().get() : "none"_sr);
|
||||
|
||||
loop {
|
||||
try {
|
||||
state int64_t size = wait(tr.getEstimatedRangeSizeBytes(normalKeys));
|
||||
TraceEvent(SevDebug, "GetSize2")
|
||||
TraceEvent(SevDebug, "GetSizeResult")
|
||||
.detail("Tenant", tr.getTenant().present() ? tr.getTenant().get() : "none"_sr)
|
||||
.detail("Size", size);
|
||||
if (!sizeIsAsExpected(size, tenant) && totalDelay < 300.0) {
|
||||
if (!sizeIsAsExpected(self, size) && totalDelay < 300.0) {
|
||||
totalDelay += 5.0;
|
||||
wait(delay(5.0));
|
||||
} else {
|
||||
|
|
|
@ -19,12 +19,14 @@ testTitle = 'GetEstimatedRangeSizeTest'
|
|||
[[test.workload]]
|
||||
testName = 'GetEstimatedRangeSize'
|
||||
tenant = 'First'
|
||||
nodeCount = 250000.0
|
||||
nodeCount = 250000
|
||||
|
||||
[[test.workload]]
|
||||
testName = 'GetEstimatedRangeSize'
|
||||
tenant = 'Second'
|
||||
nodeCount = 25000.0
|
||||
nodeCount = 25000
|
||||
|
||||
[[test.workload]]
|
||||
testName = 'GetEstimatedRangeSize'
|
||||
checkOnly = true # don't run setup
|
||||
nodeCount = 275000
|
||||
|
|
Loading…
Reference in New Issue