mirror of
https://github.com/apple/foundationdb.git
synced 2025-06-02 19:25:52 +08:00
Remove mutex that was only needed for a minor optimization.
This commit is contained in:
parent
052e32ae18
commit
0e9dabcabb
@ -896,13 +896,14 @@ MultiVersionDatabase::MultiVersionDatabase(MultiVersionApi* api,
|
||||
api->runOnExternalClients(threadIdx, [this](Reference<ClientInfo> client) { dbState->addClient(client); });
|
||||
|
||||
api->runOnExternalClientsAllThreads([&clusterFilePath](Reference<ClientInfo> client) {
|
||||
// This creates a database to initialize some client state on the external library
|
||||
// We only do this on 6.2+ clients to avoid some bugs associated with older versions
|
||||
// This deletes the new database immediately to discard its connections
|
||||
// This creates a database to initialize some client state on the external library.
|
||||
// We only do this on 6.2+ clients to avoid some bugs associated with older versions.
|
||||
// This deletes the new database immediately to discard its connections.
|
||||
//
|
||||
// Simultaneous attempts to create a database could result in us running this initialization
|
||||
// code in multiple threads simultaneously. It is necessary that each attempt have a chance
|
||||
// to run this initialization in case the other fails, and it's safe to run them in parallel.
|
||||
if (client->protocolVersion.hasCloseUnusedConnection() && !client->initialized) {
|
||||
MutexHolder holder(client->initializationMutex);
|
||||
|
||||
if (!client->initialized) {
|
||||
try {
|
||||
Reference<IDatabase> newDb = client->api->createDatabase(clusterFilePath.c_str());
|
||||
client->initialized = true;
|
||||
@ -916,7 +917,6 @@ MultiVersionDatabase::MultiVersionDatabase(MultiVersionApi* api,
|
||||
.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// For clients older than 6.2 we create and maintain our database connection
|
||||
|
@ -420,8 +420,6 @@ struct ClientInfo : ClientDesc, ThreadSafeReferenceCounted<ClientInfo> {
|
||||
std::atomic_bool initialized;
|
||||
std::vector<std::pair<void (*)(void*), void*>> threadCompletionHooks;
|
||||
|
||||
Mutex initializationMutex;
|
||||
|
||||
ClientInfo()
|
||||
: ClientDesc(std::string(), false), protocolVersion(0), api(nullptr), failed(true), initialized(false) {}
|
||||
ClientInfo(IClientApi* api)
|
||||
|
Loading…
x
Reference in New Issue
Block a user