prevent data loss while promoting from second replica to owner.

Fixes #2785
Yes, it is used as an atomic flag can be replaced by flag variable.