* Fixed backup loss issue during graceful shutdown.

* Improved replica sync retry process.
* Refactored partitioning code.