Skip to content

Commit

Permalink
fix(jobsdb): race - repeat job count calculation after acquiring migr…
Browse files Browse the repository at this point in the history
…ation lock (#2583)
  • Loading branch information
atzoum committed Oct 19, 2022
1 parent 49f196a commit 87f9768
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions jobsdb/jobsdb.go
Expand Up @@ -3090,6 +3090,11 @@ func (jd *HandleT) doMigrateDS(ctx context.Context) error {
return fmt.Errorf("failed to acquire lock: %w", ctx.Err())
}
defer jd.dsMigrationLock.Unlock()
// repeat the check after the dsMigrationLock is acquired to get correct pending jobs count.
// the pending jobs count cannot change after the dsMigrationLock is acquired
if migrateFrom, pendingJobsCount, insertBeforeDS = jd.getMigrationList(dsList); len(migrateFrom) == 0 {
return nil
}

if pendingJobsCount > 0 { // migrate incomplete jobs
var destination dataSetT
Expand Down

0 comments on commit 87f9768

Please sign in to comment.