1
0
mirror of https://github.com/apple/foundationdb.git synced 2025-05-31 10:14:52 +08:00

Merge pull request from sfc-gh-ajbeamon/mvc-error-when-no-clients

Multi-version client: throw an error if local client is disabled an there are no external clients
This commit is contained in:
Vishesh Yadav 2021-03-11 16:29:49 -08:00 committed by GitHub
commit 868311daac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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;
if (externalClients.empty()) {
@ -1453,8 +1465,7 @@ Reference<IDatabase> MultiVersionApi::createDatabase(const char* clusterFilePath
}
std::string clusterFile(clusterFilePath);
if (threadCount > 1 || localClientDisabled) {
ASSERT(localClientDisabled);
if (localClientDisabled) {
ASSERT(!bypassMultiClientApi);
int threadIdx = nextThread;
@ -1470,6 +1481,8 @@ Reference<IDatabase> MultiVersionApi::createDatabase(const char* clusterFilePath
lock.leave();
ASSERT_LE(threadCount, 1);
auto db = localClient->api->createDatabase(clusterFilePath);
if (bypassMultiClientApi) {
return db;