Throw an error if the local client is disabled and there are no external clients

This commit is contained in:
A.J. Beamon 2021-03-11 14:09:52 -08:00
parent d17702e7c4
commit 0dd9fdf9de

View File

@ -1333,6 +1333,18 @@ void MultiVersionApi::setupNetwork() {
} }
} }
if (externalClients.empty() && localClientDisabled) {
// SOMEDAY: this should be allowed when it's possible to add external clients after the
// network is setup.
//
// Typically we would create a more specific error for this case, but since we expect
// this case to go away soon, we can use a trace event and a generic error.
TraceEvent(SevWarn, "CannotSetupNetwork")
.detail("Reason", "Local client is disabled and no external clients configured");
throw client_invalid_operation();
}
networkStartSetup = true; networkStartSetup = true;
if (externalClients.empty()) { if (externalClients.empty()) {
@ -1453,8 +1465,7 @@ Reference<IDatabase> MultiVersionApi::createDatabase(const char* clusterFilePath
} }
std::string clusterFile(clusterFilePath); std::string clusterFile(clusterFilePath);
if (threadCount > 1 || localClientDisabled) { if (localClientDisabled) {
ASSERT(localClientDisabled);
ASSERT(!bypassMultiClientApi); ASSERT(!bypassMultiClientApi);
int threadIdx = nextThread; int threadIdx = nextThread;
@ -1470,6 +1481,8 @@ Reference<IDatabase> MultiVersionApi::createDatabase(const char* clusterFilePath
lock.leave(); lock.leave();
ASSERT_LE(threadCount, 1);
auto db = localClient->api->createDatabase(clusterFilePath); auto db = localClient->api->createDatabase(clusterFilePath);
if (bypassMultiClientApi) { if (bypassMultiClientApi) {
return db; return db;