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

Sidekiq::Queues[queue_name].clear causes surprising behavior #6075

Closed
tiendo1011 opened this issue Oct 13, 2023 · 1 comment
Closed

Sidekiq::Queues[queue_name].clear causes surprising behavior #6075

tiendo1011 opened this issue Oct 13, 2023 · 1 comment

Comments

@tiendo1011
Copy link

tiendo1011 commented Oct 13, 2023

Ruby version: 3.2.2
Rails version: 7.0.4.2
Sidekiq / Pro / Enterprise version(s): No

In the testing guide, section Queue API, there is this guide to clear the queue:

# Clear an individual queue
Sidekiq::Queues["other"].clear

However, if we look at the implementation, following the guide will lead to only jobs_by_queue being cleared, not jobs_by_class, so when we query the queue using class style (SomeJob.jobs), the job is still there. I find this behavior very surprising.

@tiendo1011 tiendo1011 changed the title Sidekiq::Queues[queue_name].clear causes bug Sidekiq::Queues[queue_name].clear causes surprising behavior Oct 13, 2023
@mperham
Copy link
Collaborator

mperham commented Oct 13, 2023

Doc bug, that documentation wasn't written by me. There is a Sidekiq::Queues.clear_for(queue, klass) API to clear in a more complete manner:

def clear_for(queue, klass)

@mperham mperham closed this as completed Oct 23, 2023
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

2 participants