Adds a client (local or externally loaded) that can be used to connect to the cluster
| 1858 | |
| 1859 | // Adds a client (local or externally loaded) that can be used to connect to the cluster |
| 1860 | void MultiVersionDatabase::DatabaseState::addClient(Reference<ClientInfo> client) { |
| 1861 | ProtocolVersion baseVersion = client->protocolVersion.normalizedVersion(); |
| 1862 | auto [itr, inserted] = clients.insert({ baseVersion, client }); |
| 1863 | if (!inserted) { |
| 1864 | // SOMEDAY: prefer client with higher release version if protocol versions are compatible |
| 1865 | Reference<ClientInfo> keptClient = itr->second; |
| 1866 | Reference<ClientInfo> discardedClient = client; |
| 1867 | if (client->canReplace(itr->second)) { |
| 1868 | std::swap(keptClient, discardedClient); |
| 1869 | clients[baseVersion] = client; |
| 1870 | } |
| 1871 | |
| 1872 | discardedClient->failed = true; |
| 1873 | TraceEvent(SevWarn, "DuplicateClientVersion") |
| 1874 | .detail("Keeping", keptClient->libPath) |
| 1875 | .detail("KeptProtocolVersion", keptClient->protocolVersion) |
| 1876 | .detail("Disabling", discardedClient->libPath) |
| 1877 | .detail("DisabledProtocolVersion", discardedClient->protocolVersion); |
| 1878 | |
| 1879 | MultiVersionApi::api->updateSupportedVersions(); |
| 1880 | } |
| 1881 | |
| 1882 | if (!client->protocolVersion.hasInexpensiveMultiVersionClient() && !client->failed) { |
| 1883 | TraceEvent("AddingLegacyVersionMonitor") |
| 1884 | .detail("LibPath", client->libPath) |
| 1885 | .detail("ProtocolVersion", client->protocolVersion); |
| 1886 | |
| 1887 | legacyVersionMonitors.emplace_back(new LegacyVersionMonitor(client)); |
| 1888 | } |
| 1889 | } |
| 1890 | |
| 1891 | // Watch the cluster protocol version for changes and update the database state when it does. |
| 1892 | // Must be called from the main thread |
no test coverage detected