Geoduck
(G Godfrey)
6
I have implemented the connectionCheckedOut`` and connectionCheckedIn` handlers exactly as in the example in the documentation, which alexbevi posted above, and I ran a load test.
I am consistently getting checkedOut becoming a negative value. I added some code to just count the number of each events, and the connectionCheckedIn is emitted more often than connectionCheckedOut!
By load, I mean I have 50 asynchronous functions all reading and writing to the same collection constantly (10ms gaps).
This is with node.js 6.6.2 driver, and mongoose 8.4.5
I compared to the internals on the pool, deep under the topology on the MongoClient, and the values on the pool make sense. The db I am running is NOT loadBalanced, so the driver code looks pretty straight forward in that case and I cannot see how that is possible. To ensure I wasn’t just adding the handlers too late, my test clears the pools and the checkedOut value properly resets to NaN, then seems to match the internals for a while, but eventually goes negative.
I added a connectionCheckOutStart handler. These match the connectionCheckedOut calls exactly, except for the occasional connectionCheckOutFailed (which is either due to clearing the pool or network error)
To me, this makes this technique pretty useless.