Refector StatusHistoryRescalerJob transactions to prevent deadlocks#19539
Open
rubhanazeem wants to merge 1 commit intoopenSUSE:masterfrom
Open
Refector StatusHistoryRescalerJob transactions to prevent deadlocks#19539rubhanazeem wants to merge 1 commit intoopenSUSE:masterfrom
rubhanazeem wants to merge 1 commit intoopenSUSE:masterfrom
Conversation
369db46 to
a7b8812
Compare
The StatusHistoryRescalerJob was wrapping multiple cleanup calls into a single large database transaction. This held locks on the status_histories table for the entire duration of the job.
a7b8812 to
e2ab425
Compare
hennevogel
reviewed
Apr 8, 2026
Comment on lines
+7
to
+12
| if maxtime | ||
| StatusHistory.where(time: ...(maxtime - (365 * 24 * 3600))).find_in_batches do |batch| | ||
| ids = batch.map(&:id) | ||
| StatusHistory.where(id: ids).delete_all | ||
| end | ||
| end |
Member
There was a problem hiding this comment.
hennevogel
reviewed
Apr 8, 2026
Comment on lines
+16
to
+23
| # first rescale a month old | ||
| cleanup(key, 3600 * 12, 24 * 3600 * 30) | ||
| # now a week old | ||
| cleanup(key, 3600 * 6, 24 * 3600 * 7) | ||
| # now rescale yesterday | ||
| cleanup(key, 3600, 24 * 3600) | ||
| # 2h stuff | ||
| cleanup(key, 200, 3600 * 2) |
Member
There was a problem hiding this comment.
So what replaces the functionality of the transaction?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
StatusHistoryRescalerJobwas wrapping multiple cleanup calls into a single large database transaction. This held locks on thestatus_historiestable for the entire duration of the job.