The ReplicationCoordinatorImpl currently uses a unique pointer to hold onto the DataReplicator. When we call doInitialSync, the pointer is not locked, so another thread could reset the pointer before the call, like resync.
Using a shared pointer will fix this and make it so we no longer needed to synchronize on the pointer use, only when replaced/swapped. Each user of the current DataReplicator would make a copy of the shared_ptr which will stay valid. The sequence of events
A test to prove correctness will be concurrent resync requests during initial sync, or at all. Each resync will stop an existing initial-sync/resync and start a new initial sync, optionally waiting till completion.