my current setup is, I have a single replica set with a single master and two more replicas. Currently, it has a large collection and I need to add an unique index. I estimate this would take couple of hours and I will be following the instructions given here - https://docs.mongodb.com/v4.0/tutorial/build-indexes-on-replica-sets/
now my question is, lets say I add the unique index in follower 2 and add it back to the replica set. In the meantime, what if primary has added a document which conflicts with this index.
- can this replica added back to the replica set?
- will it sync with primary successfully?
- what happens when it encounters the document which violates the unique constraint?