From 3b4e0056a78a00de6ca0f9df14feb452e25ac8eb Mon Sep 17 00:00:00 2001 From: Ankita Kejriwal Date: Thu, 10 Nov 2022 19:35:21 -0800 Subject: [PATCH] Add a knob to enable/disable storage quota enforcement --- fdbclient/ServerKnobs.cpp | 3 ++- fdbclient/include/fdbclient/ServerKnobs.h | 2 ++ fdbserver/CommitProxyServer.actor.cpp | 7 +++++-- fdbserver/DataDistribution.actor.cpp | 7 ++++--- fdbserver/workloads/StorageQuota.actor.cpp | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/fdbclient/ServerKnobs.cpp b/fdbclient/ServerKnobs.cpp index fdd3ce879e..3bb0178d9a 100644 --- a/fdbclient/ServerKnobs.cpp +++ b/fdbclient/ServerKnobs.cpp @@ -296,7 +296,8 @@ void ServerKnobs::initialize(Randomize randomize, ClientKnobs* clientKnobs, IsSi init( DD_STORAGE_WIGGLE_PAUSE_THRESHOLD, 10 ); if( randomize && BUGGIFY ) DD_STORAGE_WIGGLE_PAUSE_THRESHOLD = 1000; init( DD_STORAGE_WIGGLE_STUCK_THRESHOLD, 20 ); init( DD_STORAGE_WIGGLE_MIN_SS_AGE_SEC, isSimulated ? 2 : 21 * 60 * 60 * 24 ); if(randomize && BUGGIFY) DD_STORAGE_WIGGLE_MIN_SS_AGE_SEC = isSimulated ? 0: 120; - init( DD_TENANT_AWARENESS_ENABLED, false ); if(isSimulated) DD_TENANT_AWARENESS_ENABLED = deterministicRandom()->coinflip(); + init( DD_TENANT_AWARENESS_ENABLED, false ); + init( STORAGE_QUOTA_ENABLED, false ); if(isSimulated) STORAGE_QUOTA_ENABLED = deterministicRandom()->coinflip(); init( TENANT_CACHE_LIST_REFRESH_INTERVAL, 2 ); if( randomize && BUGGIFY ) TENANT_CACHE_LIST_REFRESH_INTERVAL = deterministicRandom()->randomInt(1, 10); init( TENANT_CACHE_STORAGE_USAGE_REFRESH_INTERVAL, 2 ); if( randomize && BUGGIFY ) TENANT_CACHE_STORAGE_USAGE_REFRESH_INTERVAL = deterministicRandom()->randomInt(1, 10); init( TENANT_CACHE_STORAGE_QUOTA_REFRESH_INTERVAL, 10 ); if( randomize && BUGGIFY ) TENANT_CACHE_STORAGE_QUOTA_REFRESH_INTERVAL = deterministicRandom()->randomInt(1, 10); diff --git a/fdbclient/include/fdbclient/ServerKnobs.h b/fdbclient/include/fdbclient/ServerKnobs.h index da85f88625..067e44d26f 100644 --- a/fdbclient/include/fdbclient/ServerKnobs.h +++ b/fdbclient/include/fdbclient/ServerKnobs.h @@ -237,6 +237,8 @@ public: int64_t DD_STORAGE_WIGGLE_MIN_SS_AGE_SEC; // Minimal age of a correct-configured server before it's chosen to be wiggled bool DD_TENANT_AWARENESS_ENABLED; + bool STORAGE_QUOTA_ENABLED; // Whether storage quota enforcement for tenant groups and all the relevant storage + // usage / quota monitors are enabled. int TENANT_CACHE_LIST_REFRESH_INTERVAL; // How often the TenantCache is refreshed int TENANT_CACHE_STORAGE_USAGE_REFRESH_INTERVAL; // How often the storage bytes used by each tenant is refreshed // in the TenantCache diff --git a/fdbserver/CommitProxyServer.actor.cpp b/fdbserver/CommitProxyServer.actor.cpp index bf25314f8e..e8a9575c84 100644 --- a/fdbserver/CommitProxyServer.actor.cpp +++ b/fdbserver/CommitProxyServer.actor.cpp @@ -414,7 +414,8 @@ ACTOR Future commitBatcher(ProxyCommitData* commitData, } Optional const& tenantName = req.tenantInfo.name; - if (tenantName.present() && commitData->tenantsOverStorageQuota.count(tenantName.get()) > 0) { + if (SERVER_KNOBS->STORAGE_QUOTA_ENABLED && tenantName.present() && + commitData->tenantsOverStorageQuota.count(tenantName.get()) > 0) { req.reply.sendError(storage_quota_exceeded()); continue; } @@ -2971,7 +2972,9 @@ ACTOR Future commitProxyServerCore(CommitProxyInterface proxy, proxy.expireIdempotencyId, commitData.expectedIdempotencyIdCountForKey, &commitData.idempotencyClears)); - addActor.send(monitorTenantsOverStorageQuota(proxy.id(), db, &commitData)); + if (SERVER_KNOBS->STORAGE_QUOTA_ENABLED) { + addActor.send(monitorTenantsOverStorageQuota(proxy.id(), db, &commitData)); + } // wait for txnStateStore recovery wait(success(commitData.txnStateStore->readValue(StringRef()))); diff --git a/fdbserver/DataDistribution.actor.cpp b/fdbserver/DataDistribution.actor.cpp index 37c43ae010..962c902984 100644 --- a/fdbserver/DataDistribution.actor.cpp +++ b/fdbserver/DataDistribution.actor.cpp @@ -588,7 +588,6 @@ ACTOR Future dataDistribution(Reference self, state Reference primaryTeamCollection; state Reference remoteTeamCollection; state bool trackerCancelled; - state bool ddIsTenantAware = SERVER_KNOBS->DD_TENANT_AWARENESS_ENABLED; loop { trackerCancelled = false; self->initialized = Promise(); @@ -610,7 +609,7 @@ ACTOR Future dataDistribution(Reference self, state Reference> processingUnhealthy(new AsyncVar(false)); state Reference> processingWiggle(new AsyncVar(false)); - if (ddIsTenantAware) { + if (SERVER_KNOBS->DD_TENANT_AWARENESS_ENABLED || SERVER_KNOBS->STORAGE_QUOTA_ENABLED) { self->ddTenantCache = makeReference(cx, self->ddId); wait(self->ddTenantCache.get()->build()); } @@ -684,6 +683,8 @@ ACTOR Future dataDistribution(Reference self, "DDTenantCacheMonitor", self->ddId, &normalDDQueueErrors())); + } + if (self->ddTenantCache.present() && SERVER_KNOBS->STORAGE_QUOTA_ENABLED) { actors.push_back(reportErrorsExcept(self->ddTenantCache.get()->monitorStorageQuota(), "StorageQuotaTracker", self->ddId, @@ -1320,7 +1321,7 @@ GetStorageWigglerStateReply getStorageWigglerStates(Reference s TenantsOverStorageQuotaReply getTenantsOverStorageQuota(Reference self) { TenantsOverStorageQuotaReply reply; - if (self->ddTenantCache.present()) { + if (self->ddTenantCache.present() && SERVER_KNOBS->STORAGE_QUOTA_ENABLED) { reply.tenants = self->ddTenantCache.get()->getTenantsOverQuota(); } return reply; diff --git a/fdbserver/workloads/StorageQuota.actor.cpp b/fdbserver/workloads/StorageQuota.actor.cpp index 01615a6946..3613d7923e 100644 --- a/fdbserver/workloads/StorageQuota.actor.cpp +++ b/fdbserver/workloads/StorageQuota.actor.cpp @@ -75,7 +75,7 @@ struct StorageQuotaWorkload : TestWorkload { state Optional quotaRead = wait(getStorageQuotaHelper(cx, self->tenant)); ASSERT(quotaRead.present() && quotaRead.get() == quota); - if (!SERVER_KNOBS->DD_TENANT_AWARENESS_ENABLED) { + if (!SERVER_KNOBS->STORAGE_QUOTA_ENABLED) { return Void(); }