Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jobs list on Busy page can leak #6227

Closed
mperham opened this issue Mar 13, 2024 · 2 comments
Closed

Jobs list on Busy page can leak #6227

mperham opened this issue Mar 13, 2024 · 2 comments

Comments

@mperham
Copy link
Collaborator

mperham commented Mar 13, 2024

If you kill -9 Sidekiq while it is updating the in-progress job data (as displayed on the Busy page), there's a possibility to leak the data by losing the expiry for the data. This will result in rows in the Jobs table which never disappear.

Original discovery and example script to fix data here.

@mperham
Copy link
Collaborator Author

mperham commented Mar 13, 2024

Here's the results of tuning the operation. Mainly I've restructured the code to take advantage of the fact that HSET can accept multiple key/value pairs. Today the code only pushes one at a time which leads to a lot of time waiting on network latency. By restructuring, we greatly reduce the amount of time spent setting the hash data and so we greatly reduce the window of time where data can be orphaned.

Original / Tuned has 25 jobs in progress. The small variant only has one job in progress.

Calculating -------------------------------------
            original      6.899k (± 0.8%) i/s -     35.100k in   5.087657s
               tuned      9.970k (± 1.0%) i/s -     50.745k in   5.090055s
      original/small     21.431k (± 1.4%) i/s -    107.250k in   5.005571s
         tuned/small     21.542k (± 0.7%) i/s -    109.140k in   5.066537s

Time constructing hash (and thus the size of the race condition window)

Before: 2.37965
After: 0.20298

That's a 90% drop, a fantastic result.

@mperham
Copy link
Collaborator Author

mperham commented Mar 13, 2024

And with that optimization, I think we can move back to use MULTI, removing the race condition completely.

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

No branches or pull requests

1 participant