Various fixes related to analysis sync-ing
Created by: muffato
I found those when reviewing the changes I've made around the scheduler. Technically there is only 1 bug, so the other commits probably should be put on master instead.
Changes are about sync-ing an analysis, or waiting for the sync to complete (when being performed by another agent). I think there are a few cases where we don't need to sync again, and a case where we need to report that the sync failed.
The Scheduler can also be simplified and use safe_synchronize_AnalysisStats
.