@@ -62,6 +62,10 @@ namespace mongo {
6262namespace {
6363const int kDefaultIdleTimeout = std::numeric_limits<int >::max();
6464const int kDefaultMaxInUse = std::numeric_limits<int >::max();
65+
66+ auto makeDuration (double secs) {
67+ return Milliseconds (static_cast <Milliseconds::rep>(1000 * secs));
68+ }
6569} // namespace
6670
6771using std::endl;
@@ -91,10 +95,11 @@ PoolForHost::~PoolForHost() {
9195void PoolForHost::clear () {
9296 if (!_parentDestroyed) {
9397 LOGV2 (24124 ,
94- " Dropping all pooled connections to {hostName}(with timeout of {socketTimeoutSecs} "
95- " seconds)" ,
96- " hostName" _attr = _hostName,
97- " socketTimeoutSecs" _attr = _socketTimeoutSecs);
98+ " Dropping all pooled connections to {connString} "
99+ " (with timeout of {timeoutSecs} seconds)" ,
100+ " Dropping all pooled connections to a host" ,
101+ " connString" _attr = _hostName,
102+ " socketTimeout" _attr = makeDuration (_socketTimeoutSecs));
98103 }
99104
100105 _pool = decltype (_pool){};
@@ -114,23 +119,24 @@ auto PoolForHost::done(DBConnectionPool* pool, DBClientBase* c) -> ConnectionHea
114119 bool isBroken = c->getSockCreationMicroSec () < _minValidCreationTimeMicroSec;
115120 if (isFailed || isBroken) {
116121 _badConns++;
117- LOGV2 (
118- 24125 ,
119- " Ending connection to host {hostName}(with timeout of {socketTimeoutSecs} seconds) due "
120- " to bad connection status; {openConnections} connections to that host remain open " ,
121- " hostName " _attr = _hostName,
122- " socketTimeoutSecs " _attr = _socketTimeoutSecs,
123- " openConnections " _attr = openConnections ());
122+ LOGV2 (24125 ,
123+ " Ending connection to {connString} (with timeout of {socketTimeout}) "
124+ " due to bad connection status; {numOpenConns} connections to that host remain open " ,
125+ " Ending connection to a host due to a bad connection status " ,
126+ " connString " _attr = _hostName,
127+ " socketTimeout " _attr = makeDuration ( _socketTimeoutSecs) ,
128+ " numOpenConns " _attr = openConnections ());
124129 return ConnectionHealth::kFailed ;
125130 } else if (_maxPoolSize >= 0 && static_cast <int >(_pool.size ()) >= _maxPoolSize) {
126131 // We have a pool size that we need to enforce
127132 LOGV2 (24126 ,
128- " Ending idle connection to host {hostName}(with timeout of {socketTimeoutSecs} "
129- " seconds) because the pool meets constraints; {openConnections} connections to that "
130- " host remain open" ,
131- " hostName" _attr = _hostName,
132- " socketTimeoutSecs" _attr = _socketTimeoutSecs,
133- " openConnections" _attr = openConnections ());
133+ " Ending idle connection to {connString} (with timeout of {socketTimeout}) "
134+ " because its pool meets constraints; "
135+ " {numOpenConns} connections to that host remain open" ,
136+ " Ending idle connection to a host because its pool mees constraints" ,
137+ " connString" _attr = _hostName,
138+ " socketTimeout" _attr = makeDuration (_socketTimeoutSecs),
139+ " numOpenConns" _attr = openConnections ());
134140 return ConnectionHealth::kTooMany ;
135141 }
136142
@@ -144,11 +150,13 @@ void PoolForHost::reportBadConnectionAt(uint64_t microSec) {
144150 microSec > _minValidCreationTimeMicroSec) {
145151 _minValidCreationTimeMicroSec = microSec;
146152 LOGV2 (24127 ,
147- " Detected bad connection created at {minValidCreationTimeMicroSec} microSec, "
148- " clearing pool for {hostName} of {openConnections} connections" ,
149- " minValidCreationTimeMicroSec" _attr = _minValidCreationTimeMicroSec,
150- " hostName" _attr = _hostName,
151- " openConnections" _attr = openConnections ());
153+ " Detected bad connection created at {currentTime}, "
154+ " clearing pool for {connString} of {numOpenConns} connections" ,
155+ " Detected bad connection, clearing pool for host" ,
156+ " currentTime" _attr =
157+ Microseconds (static_cast <Microseconds::rep>(_minValidCreationTimeMicroSec)),
158+ " connString" _attr = _hostName,
159+ " numOpenConns" _attr = openConnections ());
152160 clear ();
153161 }
154162}
@@ -280,9 +288,10 @@ class DBConnectionPool::Detail {
280288
281289 if (p.openConnections () >= _this->_maxInUse ) {
282290 LOGV2 (20112 ,
283- " Too many in-use connections; waiting until there are fewer than "
284- " {this_maxInUse}" ,
285- " this_maxInUse" _attr = _this->_maxInUse );
291+ " Too many in-use connections; "
292+ " waiting until there are fewer than {maxInUseConns}" ,
293+ " Too many in-use connections; waiting until there are fewer than maximum" ,
294+ " maxInUseConns" _attr = _this->_maxInUse );
286295 p.waitForFreeConnection (timeout, lk);
287296 } else {
288297 // Drop the lock here, so we can connect without holding it.
@@ -367,12 +376,13 @@ DBClientBase* DBConnectionPool::_finishCreate(const string& ident,
367376 }
368377
369378 LOGV2 (20113 ,
370- " Successfully connected to {ident} ({openConnections_ident_socketTimeout} connections "
371- " now open to {ident2} with a {socketTimeout} second timeout)" ,
372- " ident" _attr = ident,
373- " openConnections_ident_socketTimeout" _attr = openConnections (ident, socketTimeout),
374- " ident2" _attr = ident,
375- " socketTimeout" _attr = socketTimeout);
379+ " Successfully connected to {connString} "
380+ " ({numOpenConns} connections now open to that host "
381+ " with a {socketTimeoutSecs} second timeout)" ,
382+ " Successfully connected to host" ,
383+ " connString" _attr = ident,
384+ " numOpenConns" _attr = openConnections (ident, socketTimeout),
385+ " socketTimeoutSecs" _attr = socketTimeout);
376386
377387 return conn;
378388}
@@ -490,16 +500,23 @@ void DBConnectionPool::flush() {
490500
491501void DBConnectionPool::clear () {
492502 stdx::lock_guard<Latch> L (_mutex);
493- LOGV2_DEBUG (20114 , 2 , " Removing connections on all pools owned by {name}" , " name" _attr = _name);
503+ LOGV2_DEBUG (20114 ,
504+ 2 ,
505+ " Removing connections on all pools owned by {poolName}" ,
506+ " Removing all connectionns associated with this set of pools" ,
507+ " poolName" _attr = _name);
494508 for (PoolMap::iterator iter = _pools.begin (); iter != _pools.end (); ++iter) {
495509 iter->second .clear ();
496510 }
497511}
498512
499513void DBConnectionPool::removeHost (const string& host) {
500514 stdx::lock_guard<Latch> L (_mutex);
501- LOGV2_DEBUG (
502- 20115 , 2 , " Removing connections from all pools for host: {host}" , " host" _attr = host);
515+ LOGV2_DEBUG (20115 ,
516+ 2 ,
517+ " Removing connections from all pools to {connString}" ,
518+ " Removing connections from all pools to a host" ,
519+ " connString" _attr = host);
503520 for (PoolMap::iterator i = _pools.begin (); i != _pools.end (); ++i) {
504521 const string& poolHost = i->first .ident ;
505522 if (!serverNameCompare ()(host, poolHost) && !serverNameCompare ()(poolHost, host)) {
@@ -701,8 +718,9 @@ ScopedDbConnection::~ScopedDbConnection() {
701718 } else {
702719 /* see done() comments above for why we log this line */
703720 LOGV2 (24128 ,
704- " scoped connection to {conn_getServerAddress} not being returned to the pool" ,
705- " conn_getServerAddress" _attr = _conn->getServerAddress ());
721+ " Scoped connection to {connString} not being returned to the pool" ,
722+ " Scoped connection not being returned to the pool" ,
723+ " connString" _attr = _conn->getServerAddress ());
706724 kill ();
707725 }
708726 }
0 commit comments