I wasn’t sure if this is the correct section to post this in, so apologies if it’s wrong here.
We run several application components which use the MongoDB Java Driver 3.12.1 to connect to a PSA replica set running MongoDB 4.2.6. In fact, we run one production environment and several similar staging environments.
Last night, on one of the staging environments, one of the application components threw the following exception and then hung:
com.mongodb.MongoQueryException: Query failed with error code 13435 and error message 'not master and slaveOk=false' on server [secondary]
We are fairly sure that the MongoDB Primary did not step down, so there was no failover. But it looks like this component tried to work on the Secondary and thus failed. All components have all MongoDB hosts configured, i.e. Primary, Secondary and Arbiter, for their DB connection. Also, the application is not written to ever read from the secondary, for example. It’s always supposed to talk to the Primary.
The application exists since MongoDB 3.2 or even 3.0, so it’s fairly old. And we have done stepDowns and failovers many times, for upgrades and so on. But we have never seen this effect before. Is there anything that could cause this? We’re not too concerned at this point, because it has only happened once and not on production, but we’re still curious what could cause this. So I’d be thankful for any ideas.