From b48f6b016aa09aed2dec3b964ef982af8ab11a4c Mon Sep 17 00:00:00 2001 From: Jason Carey Date: Tue, 2 Jan 2018 13:32:21 -0500 Subject: Revert "SERVER-28822 Add new dbclient connection pool options" This reverts commit 9e7df79d3907a743e29b7333de6ea08a01f33a05. --- src/mongo/client/SConscript | 11 -- src/mongo/client/connpool.cpp | 219 +++++++------------------ src/mongo/client/connpool.h | 102 ++---------- src/mongo/client/connpool_integration_test.cpp | 173 ------------------- src/mongo/db/conn_pool_options.cpp | 32 ---- src/mongo/db/conn_pool_options.h | 26 +-- src/mongo/db/db.cpp | 4 - src/mongo/s/server.cpp | 3 - 8 files changed, 82 insertions(+), 488 deletions(-) delete mode 100644 src/mongo/client/connpool_integration_test.cpp (limited to 'src') diff --git a/src/mongo/client/SConscript b/src/mongo/client/SConscript index d034b9698aa..ffe65b7cc89 100644 --- a/src/mongo/client/SConscript +++ b/src/mongo/client/SConscript @@ -193,17 +193,6 @@ clientDriverEnv.Library( ], ) -env.CppIntegrationTest( - target='connpool_integration_test', - source=[ - 'connpool_integration_test.cpp', - ], - LIBDEPS=[ - 'clientdriver', - '$BUILD_DIR/mongo/util/version_impl', - ], -) - env.Library( target='connection_pool', source=[ diff --git a/src/mongo/client/connpool.cpp b/src/mongo/client/connpool.cpp index 9f36cfccb1c..6c5a3d9cdfa 100644 --- a/src/mongo/client/connpool.cpp +++ b/src/mongo/client/connpool.cpp @@ -36,25 +36,18 @@ #include "mongo/client/connpool.h" -#include #include #include "mongo/client/connection_string.h" #include "mongo/client/global_conn_pool.h" #include "mongo/client/replica_set_monitor.h" #include "mongo/executor/connection_pool_stats.h" -#include "mongo/stdx/chrono.h" #include "mongo/util/exit.h" #include "mongo/util/log.h" #include "mongo/util/net/socket_exception.h" namespace mongo { -namespace { -const int kDefaultIdleTimeout = std::numeric_limits::max(); -const int kDefaultMaxInUse = std::numeric_limits::max(); -} // namespace - using std::endl; using std::list; using std::map; @@ -64,17 +57,6 @@ using std::vector; // ------ PoolForHost ------ -PoolForHost::PoolForHost() - : _created(0), - _minValidCreationTimeMicroSec(0), - _type(ConnectionString::INVALID), - _maxPoolSize(kPoolSizeUnlimited), - _maxInUse(kDefaultMaxInUse), - _checkedOut(0), - _badConns(0), - _parentDestroyed(false), - _inShutdown(false) {} - PoolForHost::~PoolForHost() { clear(); } @@ -82,7 +64,7 @@ PoolForHost::~PoolForHost() { void PoolForHost::clear() { if (!_parentDestroyed) { logNoCache() << "Dropping all pooled connections to " << _hostName << "(with timeout of " - << _socketTimeoutSecs << " seconds)"; + << _socketTimeout << " seconds)"; } _pool = decltype(_pool){}; @@ -104,14 +86,14 @@ void PoolForHost::done(DBConnectionPool* pool, DBClientBase* c_raw) { if (isFailed || isBroken) { _badConns++; logNoCache() << "Ending connection to host " << _hostName << "(with timeout of " - << _socketTimeoutSecs << " seconds)" + << _socketTimeout << " seconds)" << " due to bad connection status; " << openConnections() << " connections to that host remain open"; pool->onDestroy(c.get()); } else if (_maxPoolSize >= 0 && static_cast(_pool.size()) >= _maxPoolSize) { // We have a pool size that we need to enforce logNoCache() << "Ending idle connection to host " << _hostName << "(with timeout of " - << _socketTimeoutSecs << " seconds)" + << _socketTimeout << " seconds)" << " because the pool meets constraints; " << openConnections() << " connections to that host remain open"; pool->onDestroy(c.get()); @@ -161,13 +143,13 @@ void PoolForHost::flush() { clear(); } -void PoolForHost::getStaleConnections(Date_t idleThreshold, vector& stale) { +void PoolForHost::getStaleConnections(vector& stale) { vector all; while (!_pool.empty()) { StoredConnection c = std::move(_pool.top()); _pool.pop(); - if (c.ok() && !c.addedBefore(idleThreshold)) { + if (c.ok()) { all.push_back(std::move(c)); } else { _badConns++; @@ -182,17 +164,13 @@ void PoolForHost::getStaleConnections(Date_t idleThreshold, vector c) - : conn(std::move(c)), added(Date_t::now()) {} + : conn(std::move(c)), when(time(nullptr)) {} bool PoolForHost::StoredConnection::ok() { // Poke the connection to see if we're still ok return conn->isStillConnected(); } -bool PoolForHost::StoredConnection::addedBefore(Date_t time) { - return added < time; -} - void PoolForHost::createdOne(DBClientBase* base) { if (_created == 0) _type = base->type(); @@ -208,80 +186,6 @@ void PoolForHost::initializeHostName(const std::string& hostName) { } } -void PoolForHost::waitForFreeConnection(int timeout, stdx::unique_lock& lk) { - auto condition = [&] { return (numInUse() < _maxInUse || _inShutdown.load()); }; - - if (timeout > 0) { - stdx::chrono::seconds timeoutSeconds{timeout}; - - // If we timed out waiting without getting a new connection, throw. - uassert(ErrorCodes::ExceededTimeLimit, - str::stream() << "too many connections to " << _hostName << ":" << timeout, - !_cv.wait_for(lk, timeoutSeconds, condition)); - } else { - _cv.wait(lk, condition); - } -} - -void PoolForHost::notifyWaiters() { - _cv.notify_one(); -} - -void PoolForHost::shutdown() { - _inShutdown.store(true); - _cv.notify_all(); -} - -// ------ DBConnectionPool::Detail ------ - -class DBConnectionPool::Detail { -public: - template - static DBClientBase* get(DBConnectionPool* _this, - const std::string& host, - double timeout, - Connect connect) { - while (!(_this->_inShutdown.load())) { - // Get a connection from the pool, if there is one. - std::unique_ptr c(_this->_get(host, timeout)); - if (c) { - // This call may throw. - _this->onHandedOut(c.get()); - return c.release(); - } - - // If there are no pooled connections for this host, create a new connection. If - // there are too many connections in this pool to make a new one, block until a - // connection is released. - { - stdx::unique_lock lk(_this->_mutex); - PoolForHost& p = _this->_pools[PoolKey(host, timeout)]; - - if (p.openConnections() >= _this->_maxInUse) { - log() << "Too many in-use connections; waiting until there are fewer than " - << _this->_maxInUse; - p.waitForFreeConnection(timeout, lk); - } else { - // Drop the lock here, so we can connect without holding it. - // _finishCreate will take the lock again. - lk.unlock(); - - // Create a new connection and return. All Connect functions - // should throw if they cannot create a connection. - auto c = connect(); - invariant(c); - return _this->_finishCreate(host, timeout, c); - } - } - } - - // If we get here, we are in shutdown, and it does not matter what we return. - invariant(_this->_inShutdown.load()); - uassert(ErrorCodes::ShutdownInProgress, "connection pool is in shutdown", false); - MONGO_UNREACHABLE; - } -}; - // ------ DBConnectionPool ------ const int PoolForHost::kPoolSizeUnlimited(-1); @@ -289,22 +193,7 @@ const int PoolForHost::kPoolSizeUnlimited(-1); DBConnectionPool::DBConnectionPool() : _name("dbconnectionpool"), _maxPoolSize(PoolForHost::kPoolSizeUnlimited), - _maxInUse(kDefaultMaxInUse), - _idleTimeout(kDefaultIdleTimeout), - _inShutdown(false), - _hooks(new list()) - -{} - -void DBConnectionPool::shutdown() { - if (!_inShutdown.swap(true)) { - stdx::lock_guard L(_mutex); - for (auto i = _pools.begin(); i != _pools.end(); i++) { - PoolForHost& p = i->second; - p.shutdown(); - } - } -} + _hooks(new list()) {} DBClientBase* DBConnectionPool::_get(const string& ident, double socketTimeout) { uassert(ErrorCodes::ShutdownInProgress, @@ -351,44 +240,65 @@ DBClientBase* DBConnectionPool::_finishCreate(const string& ident, } DBClientBase* DBConnectionPool::get(const ConnectionString& url, double socketTimeout) { - auto connect = [&]() { - string errmsg; - auto c = url.connect(StringData(), errmsg, socketTimeout).release(); - uassert(13328, _name + ": connect failed " + url.toString() + " : " + errmsg, c); + // If a connection for this host is available from the underlying PoolForHost, use the + // connection in the pool. + DBClientBase* c = _get(url.toString(), socketTimeout); + if (c) { + try { + onHandedOut(c); + } catch (std::exception&) { + delete c; + throw; + } return c; - }; + } - return Detail::get(this, url.toString(), socketTimeout, connect); + // If no connections for this host are available in the PoolForHost (that is, all the + // connections have been checked out, or none have been created yet), create a new connection. + string errmsg; + c = url.connect(StringData(), errmsg, socketTimeout).release(); + uassert(13328, _name + ": connect failed " + url.toString() + " : " + errmsg, c); + + return _finishCreate(url.toString(), socketTimeout, c); } DBClientBase* DBConnectionPool::get(const string& host, double socketTimeout) { - auto connect = [&] { - const ConnectionString cs(uassertStatusOK(ConnectionString::parse(host))); - - string errmsg; - auto c = cs.connect(StringData(), errmsg, socketTimeout).release(); - if (!c) { - throw SocketException(SocketException::CONNECT_ERROR, - host, - 11002, - str::stream() << _name << " error: " << errmsg); + DBClientBase* c = _get(host, socketTimeout); + if (c) { + try { + onHandedOut(c); + } catch (std::exception&) { + delete c; + throw; } - return c; - }; + } + + const ConnectionString cs(uassertStatusOK(ConnectionString::parse(host))); - return Detail::get(this, host, socketTimeout, connect); + string errmsg; + c = cs.connect(StringData(), errmsg, socketTimeout).release(); + if (!c) + throw SocketException(SocketException::CONNECT_ERROR, + host, + 11002, + str::stream() << _name << " error: " << errmsg); + + return _finishCreate(host, socketTimeout, c); } DBClientBase* DBConnectionPool::get(const MongoURI& uri, double socketTimeout) { - auto connect = [&] { - string errmsg; - std::unique_ptr c(uri.connect(StringData(), errmsg, socketTimeout)); - uassert(40356, _name + ": connect failed " + uri.toString() + " : " + errmsg, c); + std::unique_ptr c(_get(uri.toString(), socketTimeout)); + if (c) { + onHandedOut(c.get()); return c.release(); - }; + } + + string errmsg; + c = std::unique_ptr(uri.connect(StringData(), errmsg, socketTimeout)); + uassert(40356, _name + ": connect failed " + uri.toString() + " : " + errmsg, c); - return Detail::get(this, uri.toString(), socketTimeout, connect); + return _finishCreate(uri.toString(), socketTimeout, c.release()); } int DBConnectionPool::getNumAvailableConns(const string& host, double socketTimeout) const { @@ -416,14 +326,11 @@ void DBConnectionPool::onRelease(DBClientBase* conn) { void DBConnectionPool::release(const string& host, DBClientBase* c) { onRelease(c); - stdx::unique_lock lk(_mutex); - PoolForHost& p = _pools[PoolKey(host, c->getSoTimeout())]; - p.done(this, c); - - lk.unlock(); - p.notifyWaiters(); + stdx::lock_guard L(_mutex); + _pools[PoolKey(host, c->getSoTimeout())].done(this, c); } + DBConnectionPool::~DBConnectionPool() { // Do not log in destruction, because global connection pools get // destroyed after the logging framework. @@ -575,13 +482,13 @@ bool DBConnectionPool::isConnectionGood(const string& hostName, DBClientBase* co void DBConnectionPool::taskDoWork() { vector toDelete; - auto idleThreshold = Date_t::now() - _idleTimeout; + { // we need to get the connections inside the lock // but we can actually delete them outside stdx::lock_guard lk(_mutex); for (PoolMap::iterator i = _pools.begin(); i != _pools.end(); ++i) { - i->second.getStaleConnections(idleThreshold, toDelete); + i->second.getStaleConnections(toDelete); } } @@ -598,23 +505,21 @@ void DBConnectionPool::taskDoWork() { // ------ ScopedDbConnection ------ ScopedDbConnection::ScopedDbConnection(const std::string& host, double socketTimeout) - : _host(host), - _conn(globalConnPool.get(host, socketTimeout)), - _socketTimeoutSecs(socketTimeout) { + : _host(host), _conn(globalConnPool.get(host, socketTimeout)), _socketTimeout(socketTimeout) { _setSocketTimeout(); } ScopedDbConnection::ScopedDbConnection(const ConnectionString& host, double socketTimeout) : _host(host.toString()), _conn(globalConnPool.get(host, socketTimeout)), - _socketTimeoutSecs(socketTimeout) { + _socketTimeout(socketTimeout) { _setSocketTimeout(); } ScopedDbConnection::ScopedDbConnection(const MongoURI& uri, double socketTimeout) : _host(uri.toString()), _conn(globalConnPool.get(uri, socketTimeout)), - _socketTimeoutSecs(socketTimeout) { + _socketTimeout(socketTimeout) { _setSocketTimeout(); } @@ -632,7 +537,7 @@ void ScopedDbConnection::_setSocketTimeout() { return; if (_conn->type() == ConnectionString::MASTER) - static_cast(_conn)->setSoTimeout(_socketTimeoutSecs); + static_cast(_conn)->setSoTimeout(_socketTimeout); } ScopedDbConnection::~ScopedDbConnection() { diff --git a/src/mongo/client/connpool.h b/src/mongo/client/connpool.h index 9d428dcab36..68af31a5225 100644 --- a/src/mongo/client/connpool.h +++ b/src/mongo/client/connpool.h @@ -37,7 +37,6 @@ #include "mongo/platform/atomic_word.h" #include "mongo/util/background.h" #include "mongo/util/concurrency/mutex.h" -#include "mongo/util/time_support.h" namespace mongo { @@ -53,9 +52,7 @@ struct ConnectionPoolStats; * host. It is not responsible for creating new connections; instead, when DBConnectionPool is asked * for a connection to a particular host, DBConnectionPool will check if any connections are * available in the PoolForHost for that host. If so, DBConnectionPool will check out a connection - * from PoolForHost, and if not, DBConnectionPool will create a new connection itself, if we are - * below the maximum allowed number of connections. If we have already created _maxPoolSize - * connections, the calling thread will block until a new connection can be made for it. + * from PoolForHost, and if not, DBConnectionPool will create a new connection itself. * * Once the connection is released back to DBConnectionPool, DBConnectionPool will attempt to * release the connection to PoolForHost. This is how connections enter PoolForHost for the first @@ -77,7 +74,15 @@ public: friend class DBConnectionPool; - PoolForHost(); + PoolForHost() + : _created(0), + _minValidCreationTimeMicroSec(0), + _type(ConnectionString::INVALID), + _maxPoolSize(kPoolSizeUnlimited), + _checkedOut(0), + _badConns(0), + _parentDestroyed(false) {} + ~PoolForHost(); /** @@ -102,17 +107,10 @@ public: } /** - * Sets the maximum number of in-use connections for this pool. - */ - void setMaxInUse(int maxInUse) { - _maxInUse = maxInUse; - } - - /** - * Sets the socket timeout on this host, in seconds, for reporting purposes only. + * Sets the socket timeout on this host, for reporting purposes only. */ void setSocketTimeout(double socketTimeout) { - _socketTimeoutSecs = socketTimeout; + _socketTimeout = socketTimeout; } int numAvailable() const { @@ -152,7 +150,7 @@ public: void flush(); - void getStaleConnections(Date_t idleThreshold, std::vector& stale); + void getStaleConnections(std::vector& stale); /** * Sets the lower bound for creation times that can be considered as @@ -171,45 +169,18 @@ public: */ void initializeHostName(const std::string& hostName); - /** - * If this pool has more than _maxPoolSize connections in use, blocks - * the calling thread until a connection is returned to the pool or - * is destroyed. If a non-zero timeout is given, this method will - * throw if a free connection cannot be acquired within that amount of - * time. Timeout is in seconds. - */ - void waitForFreeConnection(int timeout, stdx::unique_lock& lk); - - /** - * Notifies any waiters that there are new connections available. - */ - void notifyWaiters(); - - /** - * Shuts down this pool, notifying all waiters. - */ - void shutdown(); - private: struct StoredConnection { StoredConnection(std::unique_ptr c); bool ok(); - /** - * Returns true if this connection was added before the given time. - */ - bool addedBefore(Date_t time); - std::unique_ptr conn; - - // The time when this connection was added to the pool. Will - // be reset if the connection is checked out and re-added. - Date_t added; + time_t when; }; std::string _hostName; - double _socketTimeoutSecs; + double _socketTimeout; std::stack _pool; int64_t _created; @@ -219,9 +190,6 @@ private: // The maximum number of connections we'll save in the pool int _maxPoolSize; - // The maximum number of connections allowed to be in-use in this pool - int _maxInUse; - // The number of currently active connections from this pool int _checkedOut; @@ -230,10 +198,6 @@ private: // Whether our parent DBConnectionPool object is in destruction bool _parentDestroyed; - - stdx::condition_variable _cv; - - AtomicWord _inShutdown; }; class DBConnectionHook { @@ -295,21 +259,6 @@ public: _maxPoolSize = maxPoolSize; } - /** - * Sets the maximum number of in-use connections per host. - */ - void setMaxInUse(int maxInUse) { - _maxInUse = maxInUse; - } - - /** - * Sets the timeout value for idle connections, after which we will remove them - * from the pool. This value is in minutes. - */ - void setIdleTimeout(int timeout) { - _idleTimeout = Minutes(timeout); - } - void onCreate(DBClientBase* conn); void onHandedOut(DBClientBase* conn); void onDestroy(DBClientBase* conn); @@ -317,9 +266,6 @@ public: void flush(); - /** - * Gets a connection to the given host with the given timeout, in seconds. - */ DBClientBase* get(const std::string& host, double socketTimeout = 0); DBClientBase* get(const ConnectionString& host, double socketTimeout = 0); DBClientBase* get(const MongoURI& uri, double socketTimeout = 0); @@ -364,14 +310,7 @@ public: } virtual void taskDoWork(); - /** - * Shuts down the connection pool, unblocking any waiters on connections. - */ - void shutdown(); - private: - class Detail; - DBConnectionPool(DBConnectionPool& p); DBClientBase* _get(const std::string& ident, double socketTimeout); @@ -398,13 +337,8 @@ private: // 0 effectively disables the pool int _maxPoolSize; - int _maxInUse; - Minutes _idleTimeout; - PoolMap _pools; - AtomicWord _inShutdown; - // pointers owned by me, right now they leak on shutdown // _hooks itself also leaks because it creates a shutdown race condition std::list* _hooks; @@ -454,11 +388,11 @@ public: explicit ScopedDbConnection(const ConnectionString& host, double socketTimeout = 0); explicit ScopedDbConnection(const MongoURI& host, double socketTimeout = 0); - ScopedDbConnection() : _host(""), _conn(0), _socketTimeoutSecs(0) {} + ScopedDbConnection() : _host(""), _conn(0), _socketTimeout(0) {} /* @param conn - bind to an existing connection */ ScopedDbConnection(const std::string& host, DBClientBase* conn, double socketTimeout = 0) - : _host(host), _conn(conn), _socketTimeoutSecs(socketTimeout) { + : _host(host), _conn(conn), _socketTimeout(socketTimeout) { _setSocketTimeout(); } @@ -513,7 +447,7 @@ private: const std::string _host; DBClientBase* _conn; - const double _socketTimeoutSecs; + const double _socketTimeout; }; } // namespace mongo diff --git a/src/mongo/client/connpool_integration_test.cpp b/src/mongo/client/connpool_integration_test.cpp deleted file mode 100644 index 758b3e99665..00000000000 --- a/src/mongo/client/connpool_integration_test.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/** - * Copyright (C) 2017 MongoDB Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - * As a special exception, the copyright holders give permission to link the - * code of portions of this program with the OpenSSL library under certain - * conditions as described in each individual source file and distribute - * linked combinations including the program with the OpenSSL library. You - * must comply with the GNU Affero General Public License in all respects for - * all of the code used other than as permitted herein. If you modify file(s) - * with this exception, you may extend this exception to your version of the - * file(s), but you are not obligated to do so. If you do not wish to do so, - * delete this exception statement from your version. If you delete this - * exception statement from all source files in the program, then also delete - * it in the license file. - */ - -#include "mongo/platform/basic.h" - -#include "mongo/client/connpool.h" -#include "mongo/client/global_conn_pool.h" -#include "mongo/stdx/condition_variable.h" -#include "mongo/stdx/mutex.h" -#include "mongo/unittest/integration_test.h" -#include "mongo/unittest/unittest.h" - -namespace mongo { -namespace { - -TEST(ConnectionPoolTest, ConnectionPoolMaxInUseConnectionsTest) { - DBConnectionPool pool; - - auto fixture = unittest::getFixtureConnectionString(); - auto host = fixture.getServers()[0].toString(); - - stdx::condition_variable cv; - stdx::mutex mutex; - int counter = 0; - - pool.setMaxInUse(2); - - // Check out maxInUse connections. - auto conn1 = pool.get(host); - ASSERT(conn1); - auto conn2 = pool.get(host); - ASSERT(conn2); - - // Try creating a new one, should block until we release one. - stdx::thread t([&] { - { - stdx::lock_guard lk(mutex); - counter++; - } - - cv.notify_one(); - - auto conn3 = pool.get(host); - - { - stdx::lock_guard lk(mutex); - counter++; - } - - cv.notify_one(); - pool.release(host, conn3); - }); - - // First thread should be blocked. - { - stdx::unique_lock lk(mutex); - cv.wait(lk, [&] { return counter == 1; }); - } - - // Return one to the pool, thread should be un-blocked. - pool.release(host, conn2); - - { - stdx::unique_lock lk(mutex); - cv.wait(lk, [&] { return counter == 2; }); - } - - t.join(); -} - -TEST(ConnectionPoolTest, ConnectionPoolMaxInUseTimeoutTest) { - DBConnectionPool pool; - - auto fixture = unittest::getFixtureConnectionString(); - auto host = fixture.getServers()[0].toString(); - - pool.setMaxInUse(2); - - // Check out maxInUse connections. - auto conn1 = pool.get(host, 1); - ASSERT(conn1); - auto conn2 = pool.get(host, 1); - ASSERT(conn2); - - // Try creating a new connection with a 1-second timeout, should block, - // then should time out. - ASSERT_THROWS(pool.get(host, 1), AssertionException); -} - -TEST(ConnectionPoolTest, ConnectionPoolShutdownLogicTest) { - DBConnectionPool pool; - - auto fixture = unittest::getFixtureConnectionString(); - auto host = fixture.getServers()[0].toString(); - - stdx::condition_variable cv; - stdx::mutex mutex; - int counter = 0; - - pool.setMaxInUse(2); - - // Check out maxInUse connections. - auto conn1 = pool.get(host); - ASSERT(conn1); - auto conn2 = pool.get(host); - ASSERT(conn2); - - // Attempt to open a new connection, should block. - stdx::thread t([&] { - { - stdx::lock_guard lk(mutex); - counter++; - } - - cv.notify_one(); - - ASSERT_THROWS(pool.get(host), AssertionException); - - { - stdx::lock_guard lk(mutex); - counter++; - } - - cv.notify_one(); - }); - - // Wait for new thread to block. - { - stdx::unique_lock lk(mutex); - cv.wait(lk, [&] { return counter == 1; }); - } - - // Shut down the pool, this should unblock our waiting connection. - pool.shutdown(); - { - stdx::unique_lock lk(mutex); - cv.wait(lk, [&] { return counter == 2; }); - } - - // Attempt to open a new connection, should fail. - ASSERT_THROWS(pool.get(host), AssertionException); - - t.join(); -} - -} // namespace - -} // namespace mongo diff --git a/src/mongo/db/conn_pool_options.cpp b/src/mongo/db/conn_pool_options.cpp index 851687fc7ff..988d31efb5d 100644 --- a/src/mongo/db/conn_pool_options.cpp +++ b/src/mongo/db/conn_pool_options.cpp @@ -30,8 +30,6 @@ #include "mongo/db/conn_pool_options.h" -#include - #include "mongo/base/init.h" #include "mongo/client/connpool.h" #include "mongo/client/global_conn_pool.h" @@ -43,12 +41,6 @@ namespace mongo { int ConnPoolOptions::maxConnsPerHost(200); int ConnPoolOptions::maxShardedConnsPerHost(200); -int ConnPoolOptions::maxInUseConnsPerHost(std::numeric_limits::max()); -int ConnPoolOptions::maxShardedInUseConnsPerHost(std::numeric_limits::max()); - -int ConnPoolOptions::globalConnPoolIdleTimeout(std::numeric_limits::max()); -int ConnPoolOptions::shardedConnPoolIdleTimeout(std::numeric_limits::max()); - namespace { ExportedServerParameter // @@ -61,26 +53,6 @@ ExportedServerParameter // "connPoolMaxShardedConnsPerHost", &ConnPoolOptions::maxShardedConnsPerHost); -ExportedServerParameter // - maxInUseConnsPerHostParameter(ServerParameterSet::getGlobal(), - "connPoolMaxInUseConnsPerHost", - &ConnPoolOptions::maxInUseConnsPerHost); - -ExportedServerParameter // - maxShardedInUseConnsPerHostParameter(ServerParameterSet::getGlobal(), - "connPoolMaxShardedInUseConnsPerHost", - &ConnPoolOptions::maxShardedInUseConnsPerHost); - -ExportedServerParameter // - globalConnPoolIdleTimeoutParameter(ServerParameterSet::getGlobal(), - "globalConnPoolIdleTimeoutMinutes", - &ConnPoolOptions::globalConnPoolIdleTimeout); - -ExportedServerParameter // - shardedConnPoolIdleTimeoutParameter(ServerParameterSet::getGlobal(), - "shardedConnPoolIdleTimeoutMinutes", - &ConnPoolOptions::shardedConnPoolIdleTimeout); - MONGO_INITIALIZER(InitializeConnectionPools)(InitializerContext* context) { // Initialize the sharded and unsharded outgoing connection pools // NOTES: @@ -90,13 +62,9 @@ MONGO_INITIALIZER(InitializeConnectionPools)(InitializerContext* context) { globalConnPool.setName("connection pool"); globalConnPool.setMaxPoolSize(ConnPoolOptions::maxConnsPerHost); - globalConnPool.setMaxInUse(ConnPoolOptions::maxInUseConnsPerHost); - globalConnPool.setIdleTimeout(ConnPoolOptions::globalConnPoolIdleTimeout); shardConnectionPool.setName("sharded connection pool"); shardConnectionPool.setMaxPoolSize(ConnPoolOptions::maxShardedConnsPerHost); - shardConnectionPool.setMaxInUse(ConnPoolOptions::maxShardedInUseConnsPerHost); - shardConnectionPool.setIdleTimeout(ConnPoolOptions::shardedConnPoolIdleTimeout); return Status::OK(); } diff --git a/src/mongo/db/conn_pool_options.h b/src/mongo/db/conn_pool_options.h index 9394a156d6a..faf10c0842c 100644 --- a/src/mongo/db/conn_pool_options.h +++ b/src/mongo/db/conn_pool_options.h @@ -28,8 +28,6 @@ #pragma once -#include "mongo/util/duration.h" - namespace mongo { // NOTE: @@ -42,33 +40,13 @@ namespace mongo { */ struct ConnPoolOptions { /** - * Maximum connections per host the connection pool should store. + * Maximum connections per host the connection pool should use */ static int maxConnsPerHost; /** - * Maximum connections per host the sharded conn pool should store. + * Maximum connections per host the sharded conn pool should use */ static int maxShardedConnsPerHost; - - /** - * Maximum in-use connections per host in the global connection pool. - */ - static int maxInUseConnsPerHost; - - /** - * Maximum in-use connections per host in the sharded connection pool. - */ - static int maxShardedInUseConnsPerHost; - - /** - * Amount of time, in minutes, to keep idle connections in the global connection pool. - */ - static int globalConnPoolIdleTimeout; - - /** - * Amount of time, in minutes, to keep idle connections in the sharded connection pool. - */ - static int shardedConnPoolIdleTimeout; }; } diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp index 5d369cd38ba..bee07ae783a 100644 --- a/src/mongo/db/db.cpp +++ b/src/mongo/db/db.cpp @@ -44,7 +44,6 @@ #include "mongo/base/init.h" #include "mongo/base/initializer.h" #include "mongo/base/status.h" -#include "mongo/client/global_conn_pool.h" #include "mongo/client/replica_set_monitor.h" #include "mongo/config.h" #include "mongo/db/audit.h" @@ -1236,9 +1235,6 @@ void shutdownTask() { tl->shutdown(); } - // Shut down the global dbclient pool so callers stop waiting for connections. - globalConnPool.shutdown(); - if (serviceContext->getGlobalStorageEngine()) { ServiceContext::UniqueOperationContext uniqueOpCtx; OperationContext* opCtx = client->getOperationContext(); diff --git a/src/mongo/s/server.cpp b/src/mongo/s/server.cpp index 82e3ceb438b..e0a629c36e2 100644 --- a/src/mongo/s/server.cpp +++ b/src/mongo/s/server.cpp @@ -238,9 +238,6 @@ static void cleanupTask() { tl->shutdown(); } - // Shut down the global dbclient pool so callers stop waiting for connections. - shardConnectionPool.shutdown(); - // Shutdown the Service Entry Point and its sessions and give it a grace period to complete. if (auto sep = serviceContext->getServiceEntryPoint()) { if (!sep->shutdown(Seconds(10))) { -- cgit v1.2.1