Restart the sync when we detect we need to redo a sync

Fixes #1968
Relates #2038