Skip to content

Refector StatusHistoryRescalerJob transactions to prevent deadlocks#19539

Open
rubhanazeem wants to merge 1 commit intoopenSUSE:masterfrom
rubhanazeem:remove-transaction-history-rescaler-job
Open

Refector StatusHistoryRescalerJob transactions to prevent deadlocks#19539
rubhanazeem wants to merge 1 commit intoopenSUSE:masterfrom
rubhanazeem:remove-transaction-history-rescaler-job

Conversation

@rubhanazeem
Copy link
Copy Markdown
Member

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.

@github-actions github-actions bot added the Frontend Things related to the OBS RoR app label Apr 7, 2026
@rubhanazeem rubhanazeem force-pushed the remove-transaction-history-rescaler-job branch from 369db46 to a7b8812 Compare April 7, 2026 15:50
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.
@rubhanazeem rubhanazeem force-pushed the remove-transaction-history-rescaler-job branch from a7b8812 to e2ab425 Compare April 7, 2026 15:54
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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what replaces the functionality of the transaction?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Frontend Things related to the OBS RoR app

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants