limits_concurrency on_conflict: :discard looking only into running jobs and not blocked jobs

Open
#804 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
ruby
Domain
backend

Research direction

Start at the concurrency handling for limits_concurrency with on_conflict: :discard, and trace how jobs in Running, Ready, and Blocked are considered while a semaphore remains active. Reproduce the ProcessPrunedError-style state with frequent scheduling; done means conflicting jobs are discarded rather than accumulating in Blocked until the semaphore expires.

Written by the indexing model from the issue text.

Description

In the uncommon case that (because of whatever error, possibly ProcessPrunedError), a job is not running anymore but the Semaphore hasn't expired yet, SolidQueue is piling up new jobs in "Blocked", thus not fulfilling the on_conflict: discard promise.

I see two possible solutions:

  1. Consider checking if a semaphore is blocking for the key
  2. Check if a job is "running" not only by looking if there is a job in running or ready but also possibly in blocked

It's slightly an edge case, but if the cron is set up to a quite high frequency, it can pile up quite a bit in the few hours the semaphore hasn't expired.

NB: this happened on SolidQueue 1.3.1. We want to update soon and I have not seen in the changelog what could have fixed it "en passant"

Dominant language
Ruby
Stars
2.5k
Forks
250
Avg merge
8h 31m
Merged PRs (30d)
5

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rails/solid_queue

All issues in rails/solid_queue

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.