diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f15d25684..20efa0be31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [1.2.2](https://github.com/rudderlabs/rudder-server/compare/v1.2.1...v1.2.2) (2022-10-19) + + +### Bug Fixes + +* **jobsdb:** race - repeat job count calculation after acquiring migration lock ([#2583](https://github.com/rudderlabs/rudder-server/issues/2583)) ([87f9768](https://github.com/rudderlabs/rudder-server/commit/87f9768b2edac095cba6fcc21ea320ef2d56cde4)) + ## [1.2.1](https://github.com/rudderlabs/rudder-server/compare/v1.2.0...v1.2.1) (2022-10-14) diff --git a/jobsdb/jobsdb.go b/jobsdb/jobsdb.go index c12532b065..b0aa852efd 100644 --- a/jobsdb/jobsdb.go +++ b/jobsdb/jobsdb.go @@ -3058,6 +3058,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