summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Carey <jcarey@argv.me>2018-05-22 18:18:45 -0400
committerJason Carey <jcarey@argv.me>2018-06-08 15:08:52 -0400
commitafe78b2fd058c09a754653bf024744ee97392bc4 (patch)
tree2422581b55a32d5ad134d198b58413d9c360a99e
parent2baf303830538053d3bfedaa99fec0c4b5e83cd8 (diff)
downloadmongo-afe78b2fd058c09a754653bf024744ee97392bc4.tar.gz
SERVER-35179 Make NiTL actually refresh
-rw-r--r--src/mongo/executor/connection_pool.cpp4
-rw-r--r--src/mongo/executor/connection_pool.h17
-rw-r--r--src/mongo/executor/connection_pool_test_fixture.cpp4
-rw-r--r--src/mongo/executor/connection_pool_tl.cpp1
-rw-r--r--src/mongo/executor/connection_pool_tl.h2
-rw-r--r--src/mongo/executor/network_interface_tl.cpp1
6 files changed, 17 insertions, 12 deletions
diff --git a/src/mongo/executor/connection_pool.cpp b/src/mongo/executor/connection_pool.cpp
index 9be881fd3a5..a0d7c452c02 100644
--- a/src/mongo/executor/connection_pool.cpp
+++ b/src/mongo/executor/connection_pool.cpp
@@ -553,8 +553,6 @@ void ConnectionPool::SpecificPool::returnConnection(ConnectionInterface* connPtr
lk.unlock();
connPtr->refresh(
_parent->_options.refreshTimeout, [this](ConnectionInterface* connPtr, Status status) {
- connPtr->indicateUsed();
-
runWithActiveClient([&](stdx::unique_lock<stdx::mutex> lk) {
auto conn = takeFromProcessingPool(connPtr);
@@ -775,8 +773,6 @@ void ConnectionPool::SpecificPool::spawnConnections(stdx::unique_lock<stdx::mute
lk.unlock();
connPtr->setup(
_parent->_options.refreshTimeout, [this](ConnectionInterface* connPtr, Status status) {
- connPtr->indicateUsed();
-
runWithActiveClient([&](stdx::unique_lock<stdx::mutex> lk) {
auto conn = takeFromProcessingPool(connPtr);
diff --git a/src/mongo/executor/connection_pool.h b/src/mongo/executor/connection_pool.h
index 87833953e5f..118f734920d 100644
--- a/src/mongo/executor/connection_pool.h
+++ b/src/mongo/executor/connection_pool.h
@@ -245,6 +245,17 @@ public:
virtual void indicateFailure(Status status) = 0;
/**
+ * This method updates a 'liveness' timestamp to avoid unnecessarily refreshing
+ * the connection.
+ *
+ * This method should be invoked whenever we perform an operation on the connection that must
+ * have done work. I.e. actual networking was performed. If a connection was checked out, then
+ * back in without use, one would expect an indicateSuccess without an indicateUsed. Only if we
+ * checked it out and did work would we call indicateUsed.
+ */
+ virtual void indicateUsed() = 0;
+
+ /**
* The HostAndPort for the connection. This should be the same as the
* HostAndPort passed to DependentTypeFactoryInterface::makeConnection.
*/
@@ -265,12 +276,6 @@ protected:
private:
/**
- * This method updates a 'liveness' timestamp to avoid unnecessarily refreshing
- * the connection.
- */
- virtual void indicateUsed() = 0;
-
- /**
* Returns the last used time point for the connection
*/
virtual Date_t getLastUsed() const = 0;
diff --git a/src/mongo/executor/connection_pool_test_fixture.cpp b/src/mongo/executor/connection_pool_test_fixture.cpp
index 1d42d0445d1..560f184a025 100644
--- a/src/mongo/executor/connection_pool_test_fixture.cpp
+++ b/src/mongo/executor/connection_pool_test_fixture.cpp
@@ -122,6 +122,7 @@ void ConnectionImpl::pushSetup(PushSetupCallback status) {
_pushSetupQueue.pop_front();
auto cb = connPtr->_setupCallback;
+ connPtr->indicateUsed();
cb(connPtr, callback());
}
}
@@ -145,6 +146,7 @@ void ConnectionImpl::pushRefresh(PushRefreshCallback status) {
_pushRefreshQueue.pop_front();
auto cb = connPtr->_refreshCallback;
+ connPtr->indicateUsed();
cb(connPtr, callback());
}
}
@@ -189,6 +191,7 @@ void ConnectionImpl::setup(Milliseconds timeout, SetupCallback cb) {
_pushSetupQueue.pop_front();
auto refreshCb = connPtr->_setupCallback;
+ connPtr->indicateUsed();
refreshCb(connPtr, callback());
}
}
@@ -210,6 +213,7 @@ void ConnectionImpl::refresh(Milliseconds timeout, RefreshCallback cb) {
_pushRefreshQueue.pop_front();
auto refreshCb = connPtr->_refreshCallback;
+ connPtr->indicateUsed();
refreshCb(connPtr, callback());
}
}
diff --git a/src/mongo/executor/connection_pool_tl.cpp b/src/mongo/executor/connection_pool_tl.cpp
index 08e5c29ffa9..63fff489e6b 100644
--- a/src/mongo/executor/connection_pool_tl.cpp
+++ b/src/mongo/executor/connection_pool_tl.cpp
@@ -68,7 +68,6 @@ void TLTimer::cancelTimeout() {
void TLConnection::indicateSuccess() {
_status = Status::OK();
- _lastUsed = _reactor->now();
}
void TLConnection::indicateFailure(Status status) {
diff --git a/src/mongo/executor/connection_pool_tl.h b/src/mongo/executor/connection_pool_tl.h
index 4c57945cc97..1e9e1c98604 100644
--- a/src/mongo/executor/connection_pool_tl.h
+++ b/src/mongo/executor/connection_pool_tl.h
@@ -87,12 +87,12 @@ public:
void indicateSuccess() override;
void indicateFailure(Status status) override;
+ void indicateUsed() override;
const HostAndPort& getHostAndPort() const override;
bool isHealthy() override;
AsyncDBClient* client();
private:
- void indicateUsed() override;
Date_t getLastUsed() const override;
const Status& getStatus() const override;
diff --git a/src/mongo/executor/network_interface_tl.cpp b/src/mongo/executor/network_interface_tl.cpp
index 51654359052..2bb57e38678 100644
--- a/src/mongo/executor/network_interface_tl.cpp
+++ b/src/mongo/executor/network_interface_tl.cpp
@@ -343,6 +343,7 @@ Future<RemoteCommandResponse> NetworkInterfaceTL::_onAcquireConn(
} else if (!swr.getValue().isOK()) {
state->conn->indicateFailure(swr.getValue().status);
} else {
+ state->conn->indicateUsed();
state->conn->indicateSuccess();
}