fix(GODT-2951): Negative WaitGroup Counter

Do not defer call to `wg.Done()` in `job.onJobFinished`. If there is an
error it will also call `wg.Done()`.
This commit is contained in:
Leander Beernaert 2023-09-26 09:45:27 +02:00
parent 236c958703
commit bfe25e3a46
1 changed files with 3 additions and 2 deletions

View File

@ -113,13 +113,14 @@ func (j *Job) onStageCompleted(ctx context.Context, count int64) {
}
func (j *Job) onJobFinished(ctx context.Context, lastMessageID string, count int64) {
defer j.wg.Done()
if err := j.state.SetLastMessageID(ctx, lastMessageID, count); err != nil {
j.log.WithError(err).Error("Failed to store last synced message id")
j.onError(err)
return
}
// j.onError() also calls j.wg.Done().
j.wg.Done()
j.syncReporter.OnProgress(ctx, count)
}