Merge pull request #8787 from sfc-gh-akejriwal/monitorusage
Add a knob to enable/disable storage quota enforcement
This commit is contained in:
commit
314c0b8c9b
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -414,7 +414,8 @@ ACTOR Future<Void> commitBatcher(ProxyCommitData* commitData,
|
|||
}
|
||||
|
||||
Optional<TenantNameRef> 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<Void> 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())));
|
||||
|
|
|
@ -588,7 +588,6 @@ ACTOR Future<Void> dataDistribution(Reference<DataDistributor> self,
|
|||
state Reference<DDTeamCollection> primaryTeamCollection;
|
||||
state Reference<DDTeamCollection> remoteTeamCollection;
|
||||
state bool trackerCancelled;
|
||||
state bool ddIsTenantAware = SERVER_KNOBS->DD_TENANT_AWARENESS_ENABLED;
|
||||
loop {
|
||||
trackerCancelled = false;
|
||||
self->initialized = Promise<Void>();
|
||||
|
@ -610,7 +609,7 @@ ACTOR Future<Void> dataDistribution(Reference<DataDistributor> self,
|
|||
state Reference<AsyncVar<bool>> processingUnhealthy(new AsyncVar<bool>(false));
|
||||
state Reference<AsyncVar<bool>> processingWiggle(new AsyncVar<bool>(false));
|
||||
|
||||
if (ddIsTenantAware) {
|
||||
if (SERVER_KNOBS->DD_TENANT_AWARENESS_ENABLED || SERVER_KNOBS->STORAGE_QUOTA_ENABLED) {
|
||||
self->ddTenantCache = makeReference<TenantCache>(cx, self->ddId);
|
||||
wait(self->ddTenantCache.get()->build());
|
||||
}
|
||||
|
@ -684,6 +683,8 @@ ACTOR Future<Void> dataDistribution(Reference<DataDistributor> 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<DataDistributor> s
|
|||
|
||||
TenantsOverStorageQuotaReply getTenantsOverStorageQuota(Reference<DataDistributor> self) {
|
||||
TenantsOverStorageQuotaReply reply;
|
||||
if (self->ddTenantCache.present()) {
|
||||
if (self->ddTenantCache.present() && SERVER_KNOBS->STORAGE_QUOTA_ENABLED) {
|
||||
reply.tenants = self->ddTenantCache.get()->getTenantsOverQuota();
|
||||
}
|
||||
return reply;
|
||||
|
|
|
@ -87,7 +87,7 @@ struct StorageQuotaWorkload : TestWorkload {
|
|||
state Optional<int64_t> quotaRead = wait(getStorageQuotaHelper(cx, self->group));
|
||||
ASSERT(quotaRead.present() && quotaRead.get() == quota);
|
||||
|
||||
if (!SERVER_KNOBS->DD_TENANT_AWARENESS_ENABLED) {
|
||||
if (!SERVER_KNOBS->STORAGE_QUOTA_ENABLED) {
|
||||
return Void();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue