Remove mutex that was only needed for a minor optimization.
This commit is contained in:
parent
052e32ae18
commit
0e9dabcabb
|
@ -896,25 +896,25 @@ 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;
|
||||
} catch (Error& e) {
|
||||
// This connection is not initialized. It is still possible to connect with it,
|
||||
// but we may not see trace logs from this client until a successful connection
|
||||
// is established.
|
||||
TraceEvent(SevWarnAlways, "FailedToInitializeExternalClient")
|
||||
.detail("LibraryPath", client->libPath)
|
||||
.detail("ClusterFilePath", clusterFilePath)
|
||||
.error(e);
|
||||
}
|
||||
try {
|
||||
Reference<IDatabase> newDb = client->api->createDatabase(clusterFilePath.c_str());
|
||||
client->initialized = true;
|
||||
} catch (Error& e) {
|
||||
// This connection is not initialized. It is still possible to connect with it,
|
||||
// but we may not see trace logs from this client until a successful connection
|
||||
// is established.
|
||||
TraceEvent(SevWarnAlways, "FailedToInitializeExternalClient")
|
||||
.detail("LibraryPath", client->libPath)
|
||||
.detail("ClusterFilePath", clusterFilePath)
|
||||
.error(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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…
Reference in New Issue