Write operation fail on primary node after replica failover

Hi Team, I have done the replica setup where I do have (1 primary node, 1 secondary node and 1 arbiter node). During my test, when I stop my primary node, then it auto failover happen and my secondary auto become primary node, but I am unable to perform write operation on new primary node.
Need your help to understand, why write operation is not working after successful failover on primary node?
Other question I do have, If I setup (1 primary node and 2 secondary node), in this case do I still need arbiter node?

You should have majority data bearing nodes up. But arbiter being non data bearing node your majority is not met and write fails
PSA is not a recommended configuration
PSS is a valid configuration and you will not face this issue
If you have PSS no need of arbiter
You should have odd number of nodes

Thank you @Ramachandra_Tummala. This work for for, so now if primary fail, then one of secondary become primary and I able to perform write and read operation both. But with failed primary, when it again become available as secondary, then I am unable to perform read operation. Even I have removed the server from replication group and added again, still when I try run read query, I get below error:

“not primary and secondaryOk=false”

I tried below commands to enable read like:

And while I was running above commands, I got error, it has been deprecated, and then I used below query:


But it still having same error when I try run read query “NotPrimaryNoSecondaryOk”.

Please help to suggest, how I can fix this error?

Hi @Ramachandra_Tummala and team, please help to understand and fix my problem as mentioned above.

It should work
Are you checking rs.status() before running those commands
They wont work on primary if by mistake you are running them on primary
When you are removing/adding election may be taking place and new primary elected
Are you running these commands manually or expecting driver to read from secondary’s
You have to use appropriate connect string