You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MongoMetricsCommandListener is not thread safe because it uses a shared instance of Timer.Builder. This means that concurrent calls to commandSucceeded() or commandFailed() can generate incorrect metrics.
This test creates 4 threads that execute different Mongo operations, then checks that the metric corresponding to each command has been incremented by 1. The test fails when the threads are run concurrently (concurrent = true), but passes when the threads are run in serial (concurrent = false).
Example concurrent output:
[mongod output] iterationsCompleted=1, insertCommandCount=1, updateCommandCount=2, deleteCommandCount=0, dropIndexesCommandCount=1
org.opentest4j.AssertionFailedError:
Expecting:
<2L>
to be equal to:
<1L>
but was not.
MongoMetricsCommandListener
is not thread safe because it uses a shared instance ofTimer.Builder
. This means that concurrent calls tocommandSucceeded()
orcommandFailed()
can generate incorrect metrics.I've created a unit test here that reproduces the issue: jshields-squarespace@80d0fd6
This test creates 4 threads that execute different Mongo operations, then checks that the metric corresponding to each command has been incremented by 1. The test fails when the threads are run concurrently (
concurrent = true
), but passes when the threads are run in serial (concurrent = false
).Example concurrent output:
Example serial output:
The text was updated successfully, but these errors were encountered: