globalsign / mgo

The MongoDB driver for Go
Other
1.97k stars 231 forks source link

Fix meaning of MasterConns metric #329

Closed KJTsanaktsidis closed 5 years ago

KJTsanaktsidis commented 5 years ago

While exploring some of the mgo metrics around connections opening/closing, I noticed that the MasterConns metric, which I assume is supposed to be an always-incrementing counter, actually gets decremented in the connection pool shrinking logic.

I assume that this is a mistake because other places that can reduce the count of open master connections, such as kill() in abend error scenarios, don't also decrease this number.

To replace the change in MasterConns metric that the pool shrinker was previously doing, I added its own counter to measure what's happening there (ShrunkConns).

I also added a counter for connections that failed abnormally (FailedConns). This is data that I'm quite curious to get my hands on to debug our Mongo deployment because we're seeing a scenario where there are a lot of connection failures in our setup and a huge churn in connections getting opened/closed.

eminano commented 5 years ago

@KJTsanaktsidis, thanks for taking the time to open this PR and sorry for the delay!

Cheers, Esther