My mongodb version is 3.2.4. I have a replicaSet with 2 database nodes and 1 arbitor. All db are running fine for a long time at my customer site. One day, the primary db was brought down for maintenance. After about 2 hours, the-was-primary was brought back up, and becomes primary again, and secondary db is in Rollback state. I have a few questions regarding above mentioned scenarios: when the primary db was brought down the first time, if there are db entries haven't synced to the secondary db, what would happen? when the failed primary brought back up again, does it become primary right the way? Does it sync with now-primary-was-secondary db before becoming primary db again? how do I recover the lost data in rollback folder given my latest primary and secondary db state? Thanks and regards.
When you want to bring down a primary for maintenance, you'd have to do a rs.stepDown() command on the primary. This will elect the other DB node to become the primary:
The rollback state you're in doesn't seem normal if you do a proper stepDown. Here's a good link to apply your rollback: https://scalegrid.io/blog/how-to-recover-from-a-mongodb-rollback/