|
During the PR discussion of SERVER-59673 it was discovered that currently there's no easy way of knowing if we are a primary/standalone/secondary.
One way is to use ReplicationCoordinator::getMemberState() but it is discouraged due to the internal mutex it locks, causing possible high contention. SERVER-71400 has been created to see if this can be alleviated.
As a workaround for that a lot of times we end up using ReplicationCoordinator::canAcceptWritesForDatabase with an arbitrary database name that is known to require replication (i.e. not the local database).
To ease readability it would be best if there were a method that does precisely what we want instead so future improvements are centralized there.
|