What would you like to be added:
Due to issue https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/issues/617 the command to test MongoDBs availability was changed to a db.runCommand({ping: 1}) when a database is specified which resolves that problem, but introduces a condition that could cause intermittent unhealthy statuses.
I work for MongoDB and would be happy to put you in contact with the MongoDB C#/.Net driver team to work on a solution.
Why is this needed:
The issue is related to retryable operations (retryable reads and retryable writes ). Essentially for most operations where it is possible, the MongoDB driver itself will retry exactly once to cover switches in the primary and temporary short term network outages.
Due to the RunCommand being a lower level function, according to the spec for it, it is not retryable and this extends to the ping.
This means that in some cases, the check can return a temporary not-ok status, while actually operations would still succeed without errors.
What would you like to be added: Due to issue https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/issues/617 the command to test MongoDBs availability was changed to a db.runCommand({ping: 1}) when a database is specified which resolves that problem, but introduces a condition that could cause intermittent unhealthy statuses.
I work for MongoDB and would be happy to put you in contact with the MongoDB C#/.Net driver team to work on a solution.
Why is this needed: The issue is related to retryable operations (retryable reads and retryable writes ). Essentially for most operations where it is possible, the MongoDB driver itself will retry exactly once to cover switches in the primary and temporary short term network outages. Due to the RunCommand being a lower level function, according to the spec for it, it is not retryable and this extends to the ping.
This means that in some cases, the check can return a temporary not-ok status, while actually operations would still succeed without errors.