Don't check whether tenants are enabled when watch is called. Support unknown_tenant error.
This commit is contained in:
parent
ecccfd0868
commit
1e1098ca9a
|
@ -61,6 +61,7 @@ void ClientKnobs::initialize(Randomize randomize) {
|
||||||
|
|
||||||
init( WRONG_SHARD_SERVER_DELAY, .01 ); if( randomize && BUGGIFY ) WRONG_SHARD_SERVER_DELAY = deterministicRandom()->random01(); // FLOW_KNOBS->PREVENT_FAST_SPIN_DELAY; // SOMEDAY: This delay can limit performance of retrieving data when the cache is mostly wrong (e.g. dumping the database after a test)
|
init( WRONG_SHARD_SERVER_DELAY, .01 ); if( randomize && BUGGIFY ) WRONG_SHARD_SERVER_DELAY = deterministicRandom()->random01(); // FLOW_KNOBS->PREVENT_FAST_SPIN_DELAY; // SOMEDAY: This delay can limit performance of retrieving data when the cache is mostly wrong (e.g. dumping the database after a test)
|
||||||
init( FUTURE_VERSION_RETRY_DELAY, .01 ); if( randomize && BUGGIFY ) FUTURE_VERSION_RETRY_DELAY = deterministicRandom()->random01();// FLOW_KNOBS->PREVENT_FAST_SPIN_DELAY;
|
init( FUTURE_VERSION_RETRY_DELAY, .01 ); if( randomize && BUGGIFY ) FUTURE_VERSION_RETRY_DELAY = deterministicRandom()->random01();// FLOW_KNOBS->PREVENT_FAST_SPIN_DELAY;
|
||||||
|
init( UNKNOWN_TENANT_RETRY_DELAY, 0.0 ); if( randomize && BUGGIFY ) UNKNOWN_TENANT_RETRY_DELAY = deterministicRandom()->random01();
|
||||||
init( REPLY_BYTE_LIMIT, 80000 );
|
init( REPLY_BYTE_LIMIT, 80000 );
|
||||||
init( DEFAULT_BACKOFF, .01 ); if( randomize && BUGGIFY ) DEFAULT_BACKOFF = deterministicRandom()->random01();
|
init( DEFAULT_BACKOFF, .01 ); if( randomize && BUGGIFY ) DEFAULT_BACKOFF = deterministicRandom()->random01();
|
||||||
init( DEFAULT_MAX_BACKOFF, 1.0 );
|
init( DEFAULT_MAX_BACKOFF, 1.0 );
|
||||||
|
|
|
@ -60,6 +60,7 @@ public:
|
||||||
double WRONG_SHARD_SERVER_DELAY; // SOMEDAY: This delay can limit performance of retrieving data when the cache is
|
double WRONG_SHARD_SERVER_DELAY; // SOMEDAY: This delay can limit performance of retrieving data when the cache is
|
||||||
// mostly wrong (e.g. dumping the database after a test)
|
// mostly wrong (e.g. dumping the database after a test)
|
||||||
double FUTURE_VERSION_RETRY_DELAY;
|
double FUTURE_VERSION_RETRY_DELAY;
|
||||||
|
double UNKNOWN_TENANT_RETRY_DELAY;
|
||||||
int REPLY_BYTE_LIMIT;
|
int REPLY_BYTE_LIMIT;
|
||||||
double DEFAULT_BACKOFF;
|
double DEFAULT_BACKOFF;
|
||||||
double DEFAULT_MAX_BACKOFF;
|
double DEFAULT_MAX_BACKOFF;
|
||||||
|
|
|
@ -3146,9 +3146,10 @@ ACTOR Future<Optional<Value>> getValue(Reference<TransactionState> trState,
|
||||||
(e.code() == error_code_transaction_too_old && ver == latestVersion)) {
|
(e.code() == error_code_transaction_too_old && ver == latestVersion)) {
|
||||||
trState->cx->invalidateCache(useTenant ? locationInfo.tenantEntry.prefix : Key(), key);
|
trState->cx->invalidateCache(useTenant ? locationInfo.tenantEntry.prefix : Key(), key);
|
||||||
wait(delay(CLIENT_KNOBS->WRONG_SHARD_SERVER_DELAY, trState->taskID));
|
wait(delay(CLIENT_KNOBS->WRONG_SHARD_SERVER_DELAY, trState->taskID));
|
||||||
} else if (e.code() == error_code_tenant_not_found) {
|
} else if (e.code() == error_code_unknown_tenant) {
|
||||||
ASSERT(useTenant && trState->tenant.present());
|
ASSERT(useTenant && trState->tenant.present());
|
||||||
trState->cx->invalidateCachedTenant(trState->tenant.get());
|
trState->cx->invalidateCachedTenant(trState->tenant.get());
|
||||||
|
wait(delay(CLIENT_KNOBS->UNKNOWN_TENANT_RETRY_DELAY, trState->taskID));
|
||||||
} else {
|
} else {
|
||||||
if (trState->trLogInfo && recordLogInfo)
|
if (trState->trLogInfo && recordLogInfo)
|
||||||
trState->trLogInfo->addLog(FdbClientLogEvents::EventGetError(startTimeD,
|
trState->trLogInfo->addLog(FdbClientLogEvents::EventGetError(startTimeD,
|
||||||
|
@ -3248,9 +3249,10 @@ ACTOR Future<Key> getKey(Reference<TransactionState> trState,
|
||||||
trState->cx->invalidateCache(locationInfo.tenantEntry.prefix, k.getKey(), Reverse{ k.isBackward() });
|
trState->cx->invalidateCache(locationInfo.tenantEntry.prefix, k.getKey(), Reverse{ k.isBackward() });
|
||||||
|
|
||||||
wait(delay(CLIENT_KNOBS->WRONG_SHARD_SERVER_DELAY, trState->taskID));
|
wait(delay(CLIENT_KNOBS->WRONG_SHARD_SERVER_DELAY, trState->taskID));
|
||||||
} else if (e.code() == error_code_tenant_not_found) {
|
} else if (e.code() == error_code_unknown_tenant) {
|
||||||
ASSERT(useTenant && trState->tenant.present());
|
ASSERT(useTenant && trState->tenant.present());
|
||||||
trState->cx->invalidateCachedTenant(trState->tenant.get());
|
trState->cx->invalidateCachedTenant(trState->tenant.get());
|
||||||
|
wait(delay(CLIENT_KNOBS->UNKNOWN_TENANT_RETRY_DELAY, trState->taskID));
|
||||||
} else {
|
} else {
|
||||||
TraceEvent(SevInfo, "GetKeyError").error(e).detail("AtKey", k.getKey()).detail("Offset", k.offset);
|
TraceEvent(SevInfo, "GetKeyError").error(e).detail("AtKey", k.getKey()).detail("Offset", k.offset);
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -3371,9 +3373,10 @@ ACTOR Future<Version> watchValue(Database cx, Reference<const WatchParameters> p
|
||||||
if (e.code() == error_code_wrong_shard_server || e.code() == error_code_all_alternatives_failed) {
|
if (e.code() == error_code_wrong_shard_server || e.code() == error_code_all_alternatives_failed) {
|
||||||
cx->invalidateCache(locationInfo.tenantEntry.prefix, parameters->key);
|
cx->invalidateCache(locationInfo.tenantEntry.prefix, parameters->key);
|
||||||
wait(delay(CLIENT_KNOBS->WRONG_SHARD_SERVER_DELAY, parameters->taskID));
|
wait(delay(CLIENT_KNOBS->WRONG_SHARD_SERVER_DELAY, parameters->taskID));
|
||||||
} else if (e.code() == error_code_tenant_not_found) {
|
} else if (e.code() == error_code_unknown_tenant) {
|
||||||
ASSERT(parameters->tenant.name.present());
|
ASSERT(parameters->tenant.name.present());
|
||||||
cx->invalidateCachedTenant(parameters->tenant.name.get());
|
cx->invalidateCachedTenant(parameters->tenant.name.get());
|
||||||
|
wait(delay(CLIENT_KNOBS->UNKNOWN_TENANT_RETRY_DELAY, parameters->taskID));
|
||||||
} else if (e.code() == error_code_watch_cancelled || e.code() == error_code_process_behind) {
|
} else if (e.code() == error_code_watch_cancelled || e.code() == error_code_process_behind) {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
TEST(e.code() == error_code_watch_cancelled); // Too many watches on the storage server, poll for changes instead
|
TEST(e.code() == error_code_watch_cancelled); // Too many watches on the storage server, poll for changes instead
|
||||||
|
@ -3751,9 +3754,10 @@ Future<RangeResultFamily> getExactRange(Reference<TransactionState> trState,
|
||||||
|
|
||||||
wait(delay(CLIENT_KNOBS->WRONG_SHARD_SERVER_DELAY, trState->taskID));
|
wait(delay(CLIENT_KNOBS->WRONG_SHARD_SERVER_DELAY, trState->taskID));
|
||||||
break;
|
break;
|
||||||
} else if (e.code() == error_code_tenant_not_found) {
|
} else if (e.code() == error_code_unknown_tenant) {
|
||||||
ASSERT(useTenant && trState->tenant.present());
|
ASSERT(useTenant && trState->tenant.present());
|
||||||
trState->cx->invalidateCachedTenant(trState->tenant.get());
|
trState->cx->invalidateCachedTenant(trState->tenant.get());
|
||||||
|
wait(delay(CLIENT_KNOBS->UNKNOWN_TENANT_RETRY_DELAY, trState->taskID));
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
TraceEvent(SevInfo, "GetExactRangeError")
|
TraceEvent(SevInfo, "GetExactRangeError")
|
||||||
|
@ -4201,9 +4205,10 @@ Future<RangeResultFamily> getRange(Reference<TransactionState> trState,
|
||||||
}
|
}
|
||||||
|
|
||||||
wait(delay(CLIENT_KNOBS->WRONG_SHARD_SERVER_DELAY, trState->taskID));
|
wait(delay(CLIENT_KNOBS->WRONG_SHARD_SERVER_DELAY, trState->taskID));
|
||||||
} else if (e.code() == error_code_tenant_not_found) {
|
} else if (e.code() == error_code_unknown_tenant) {
|
||||||
ASSERT(useTenant && trState->tenant.present());
|
ASSERT(useTenant && trState->tenant.present());
|
||||||
trState->cx->invalidateCachedTenant(trState->tenant.get());
|
trState->cx->invalidateCachedTenant(trState->tenant.get());
|
||||||
|
wait(delay(CLIENT_KNOBS->UNKNOWN_TENANT_RETRY_DELAY, trState->taskID));
|
||||||
} else {
|
} else {
|
||||||
if (trState->trLogInfo)
|
if (trState->trLogInfo)
|
||||||
trState->trLogInfo->addLog(
|
trState->trLogInfo->addLog(
|
||||||
|
@ -4650,9 +4655,10 @@ ACTOR Future<Void> getRangeStreamFragment(Reference<TransactionState> trState,
|
||||||
|
|
||||||
wait(delay(CLIENT_KNOBS->WRONG_SHARD_SERVER_DELAY, trState->taskID));
|
wait(delay(CLIENT_KNOBS->WRONG_SHARD_SERVER_DELAY, trState->taskID));
|
||||||
break;
|
break;
|
||||||
} else if (e.code() == error_code_tenant_not_found) {
|
} else if (e.code() == error_code_unknown_tenant) {
|
||||||
ASSERT(trState->tenant.present());
|
ASSERT(trState->tenant.present());
|
||||||
trState->cx->invalidateCachedTenant(trState->tenant.get());
|
trState->cx->invalidateCachedTenant(trState->tenant.get());
|
||||||
|
wait(delay(CLIENT_KNOBS->UNKNOWN_TENANT_RETRY_DELAY, trState->taskID));
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
results->sendError(e);
|
results->sendError(e);
|
||||||
|
@ -4986,12 +4992,6 @@ Future<Version> Transaction::getRawReadVersion() {
|
||||||
Future<Void> Transaction::watch(Reference<Watch> watch) {
|
Future<Void> Transaction::watch(Reference<Watch> watch) {
|
||||||
++trState->cx->transactionWatchRequests;
|
++trState->cx->transactionWatchRequests;
|
||||||
|
|
||||||
if (!trState->cx->internal && !trState->options.rawAccess &&
|
|
||||||
trState->cx->clientInfo->get().tenantMode == TenantMode::REQUIRED && !trState->tenant.present()) {
|
|
||||||
throw tenant_name_required();
|
|
||||||
} else if (trState->cx->clientInfo->get().tenantMode == TenantMode::DISABLED && trState->tenant.present()) {
|
|
||||||
throw tenants_disabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
trState->cx->addWatch();
|
trState->cx->addWatch();
|
||||||
watches.push_back(watch);
|
watches.push_back(watch);
|
||||||
|
@ -5797,11 +5797,12 @@ ACTOR static Future<Void> tryCommit(Reference<TransactionState> trState,
|
||||||
state Key tenantPrefix;
|
state Key tenantPrefix;
|
||||||
if (trState->tenant.present()) {
|
if (trState->tenant.present()) {
|
||||||
KeyRangeLocationInfo locationInfo = wait(getKeyLocation(trState, ""_sr, &StorageServerInterface::getValue));
|
KeyRangeLocationInfo locationInfo = wait(getKeyLocation(trState, ""_sr, &StorageServerInterface::getValue));
|
||||||
req.tenantInfo = trState->getTenantInfo();
|
|
||||||
applyTenantPrefix(req, locationInfo.tenantEntry.prefix);
|
applyTenantPrefix(req, locationInfo.tenantEntry.prefix);
|
||||||
tenantPrefix = locationInfo.tenantEntry.prefix;
|
tenantPrefix = locationInfo.tenantEntry.prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
req.tenantInfo = trState->getTenantInfo();
|
||||||
|
|
||||||
startTime = now();
|
startTime = now();
|
||||||
state Optional<UID> commitID = Optional<UID>();
|
state Optional<UID> commitID = Optional<UID>();
|
||||||
|
|
||||||
|
@ -5933,6 +5934,10 @@ ACTOR static Future<Void> tryCommit(Reference<TransactionState> trState,
|
||||||
// The user needs to be informed that we aren't sure whether the commit happened. Standard retry loops
|
// The user needs to be informed that we aren't sure whether the commit happened. Standard retry loops
|
||||||
// retry it anyway (relying on transaction idempotence) but a client might do something else.
|
// retry it anyway (relying on transaction idempotence) but a client might do something else.
|
||||||
throw commit_unknown_result();
|
throw commit_unknown_result();
|
||||||
|
} else if (e.code() == error_code_unknown_tenant) {
|
||||||
|
ASSERT(trState->tenant.present());
|
||||||
|
trState->cx->invalidateCachedTenant(trState->tenant.get());
|
||||||
|
throw;
|
||||||
} else {
|
} else {
|
||||||
if (e.code() != error_code_transaction_too_old && e.code() != error_code_not_committed &&
|
if (e.code() != error_code_transaction_too_old && e.code() != error_code_not_committed &&
|
||||||
e.code() != error_code_database_locked && e.code() != error_code_proxy_memory_limit_exceeded &&
|
e.code() != error_code_database_locked && e.code() != error_code_proxy_memory_limit_exceeded &&
|
||||||
|
@ -6788,6 +6793,11 @@ Future<Void> Transaction::onError(Error const& e) {
|
||||||
reset();
|
reset();
|
||||||
return delay(std::min(CLIENT_KNOBS->FUTURE_VERSION_RETRY_DELAY, maxBackoff), trState->taskID);
|
return delay(std::min(CLIENT_KNOBS->FUTURE_VERSION_RETRY_DELAY, maxBackoff), trState->taskID);
|
||||||
}
|
}
|
||||||
|
if (e.code() == error_code_unknown_tenant) {
|
||||||
|
double maxBackoff = trState->options.maxBackoff;
|
||||||
|
reset();
|
||||||
|
return delay(std::min(CLIENT_KNOBS->UNKNOWN_TENANT_RETRY_DELAY, maxBackoff), trState->taskID);
|
||||||
|
}
|
||||||
|
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
@ -7138,9 +7148,10 @@ ACTOR Future<Standalone<VectorRef<KeyRef>>> getRangeSplitPoints(Reference<Transa
|
||||||
if (e.code() == error_code_wrong_shard_server || e.code() == error_code_all_alternatives_failed) {
|
if (e.code() == error_code_wrong_shard_server || e.code() == error_code_all_alternatives_failed) {
|
||||||
trState->cx->invalidateCache(locations[0].tenantEntry.prefix, keys);
|
trState->cx->invalidateCache(locations[0].tenantEntry.prefix, keys);
|
||||||
wait(delay(CLIENT_KNOBS->WRONG_SHARD_SERVER_DELAY, TaskPriority::DataDistribution));
|
wait(delay(CLIENT_KNOBS->WRONG_SHARD_SERVER_DELAY, TaskPriority::DataDistribution));
|
||||||
} else if (e.code() == error_code_tenant_not_found) {
|
} else if (e.code() == error_code_unknown_tenant) {
|
||||||
ASSERT(trState->tenant.present());
|
ASSERT(trState->tenant.present());
|
||||||
trState->cx->invalidateCachedTenant(trState->tenant.get());
|
trState->cx->invalidateCachedTenant(trState->tenant.get());
|
||||||
|
wait(delay(CLIENT_KNOBS->UNKNOWN_TENANT_RETRY_DELAY, trState->taskID));
|
||||||
} else {
|
} else {
|
||||||
TraceEvent(SevError, "GetRangeSplitPoints").error(e);
|
TraceEvent(SevError, "GetRangeSplitPoints").error(e);
|
||||||
throw;
|
throw;
|
||||||
|
|
Loading…
Reference in New Issue