Skip to content

feat(jobsdb): migration optimizations for large number of datasets - #6786

Merged
atzoum merged 3 commits into
masterfrom
feat.jobsdbMigrateFrom
Mar 23, 2026
Merged

atzoum merged 3 commits into
masterfrom
feat.jobsdbMigrateFrom

Conversation

@atzoum

@atzoum atzoum commented Mar 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

Problem

doMigrateDS calls getMigrationList twice: once optimistically before acquiring dsMigrationLock, and once authoritatively under the lock. Each call iterates datasets left-to-right, running a SQL query per dataset via checkIfMigrateDS. With many datasets, the second call is expensive because it holds the write lock — blocking all readers (GetJobs, UpdateJobStatus).

Additionally, across migration loop iterations, scanning always restarts from dataset 0 even if the previous iteration already probed those datasets and found them ineligible.

Solution

Intra-invocation skip: The first (optimistic) call records the firstEligible dataset it finds. The second call under the lock skips all datasets before that point using dsindex.Less comparisons, avoiding redundant checkIfMigrateDS queries while holding the write lock.

Cross-invocation resume: When getMigrationList exhausts the maxMigrateDSProbe limit without finding eligible datasets, it saves the last probed dataset index. The next migration loop iteration resumes from there instead of re-scanning from the beginning. The resume point is reset unless the probe hits the limit with no eligible datasets again.

Linear Ticket

resolves PIPE-2853

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@codecov

codecov Bot commented Mar 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.69%. Comparing base (fa4d1c4) to head (c7016af).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
jobsdb/migration.go 85.00% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6786      +/-   ##
==========================================
- Coverage   80.08%   79.69%   -0.39%     
==========================================
  Files         565      565              
  Lines       63274    63293      +19     
==========================================
- Hits        50670    50439     -231     
- Misses       9610     9875     +265     
+ Partials     2994     2979      -15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

atzoum added 3 commits March 23, 2026 10:50
🔒 Scanned for secrets using gitleaks 8.30.0
🔒 Scanned for secrets using gitleaks 8.30.0
🔒 Scanned for secrets using gitleaks 8.30.0
@atzoum
atzoum force-pushed the feat.jobsdbMigrateFrom branch from 8c28711 to c7016af Compare March 23, 2026 08:50
Comment thread jobsdb/migration.go Resolved
@atzoum
atzoum requested a review from ktgowtham March 23, 2026 09:31
@atzoum
atzoum merged commit 641f9fd into master Mar 23, 2026
70 checks passed
@atzoum
atzoum deleted the feat.jobsdbMigrateFrom branch March 23, 2026 13:41
This was referenced Mar 30, 2026
itsmihir pushed a commit that referenced this pull request Mar 30, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.72.0-rc.1](v1.71.0...v1.72.0-rc.1)
(2026-03-30)


### Features

* **jobsdb:** migration optimizations for large number of datasets
([#6786](#6786))
([641f9fd](641f9fd))


### Bug Fixes

* language label
([#6809](#6809))
([ac501c8](ac501c8))
* mirroring round trip comparison
([#6813](#6813))
([57a079b](57a079b))


### Miscellaneous

* partition migration stress test and improvements
([#6802](#6802))
([419818a](419818a))
* sync release v1.71.0 to main branch
([#6801](#6801))
([6a6ee90](6a6ee90))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
This was referenced Mar 30, 2026
itsmihir pushed a commit that referenced this pull request Mar 30, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.72.0-rc.2](v1.71.0...v1.72.0-rc.2)
(2026-03-30)


### Features

* **jobsdb:** migration optimizations for large number of datasets
([#6786](#6786))
([641f9fd](641f9fd))


### Bug Fixes

* language label
([#6809](#6809))
([ac501c8](ac501c8))
* mirroring round trip comparison
([#6813](#6813))
([57a079b](57a079b))
* sanity checks
([#6817](#6817))
([2969e3e](2969e3e))


### Miscellaneous

* partition migration stress test and improvements
([#6802](#6802))
([419818a](419818a))
* sync release v1.71.0 to main branch
([#6801](#6801))
([6a6ee90](6a6ee90))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
itsmihir pushed a commit that referenced this pull request Mar 31, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.72.0](v1.71.0...v1.72.0)
(2026-03-30)


### Features

* **jobsdb:** migration optimizations for large number of datasets
([#6786](#6786))
([641f9fd](641f9fd))


### Bug Fixes

* language label
([#6809](#6809))
([ac501c8](ac501c8))
* mirroring round trip comparison
([#6813](#6813))
([57a079b](57a079b))
* sanity checks
([#6817](#6817))
([2969e3e](2969e3e))


### Miscellaneous

* partition migration stress test and improvements
([#6802](#6802))
([419818a](419818a))
* sync release v1.71.0 to main branch
([#6801](#6801))
([6a6ee90](6a6ee90))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants