Fix long-standing bug where `/sync` could tightloop after restart when using SQLite.