Skip to content

feat(solid-queue): integrate upstream 1.7.2 with fork parity - #17

Merged
jpcamara merged 131 commits into
mainfrom
jpcamara/Integrate-upstream-Solid-Queue
Dec 1, 2026
Merged

jpcamara merged 131 commits into
mainfrom
jpcamara/Integrate-upstream-Solid-Queue

Conversation

@jpcamara

@jpcamara jpcamara commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Why

Update the fork to Solid Queue 1.7.2. Keep Starburst Labs' queue behavior where the fork differs from Rails, including recovery for confirmed-dead workers.

What changed

  • Merge the upstream v1.7.2 tag. Keep per-key max_blocked alongside upstream's per-job semaphore ownership.
  • On async shutdown timeout, requeue work from tracked workers and leave pending dead-worker claims for pruning.
  • Retain the fork's batch API, optional schema, thread worker metadata, and configuration warnings. Include upstream's batch recovery and bulk-discard fixes.

Scope

This updates the fork gem and its tests. The 1.7.2 semaphore changes need no schema migration.

Blast Radius

Concurrency-limited jobs retain the semaphore ID and limit in their job payload. Pre-upgrade jobs use the upstream fallback. If async shutdown times out during pending dead-worker cleanup, those claims recover after their registrations go stale.

Verification

  • SQLite, PostgreSQL 15.1, and Linux/MySQL 8.0.31 each ran 421 tests with zero failures or errors. Each adapter skipped tests outside its coverage.
  • The async shutdown regression failed before the fix because the dead worker's job was requeued. It passes all seven assertions with the fix.
  • Compared the historical fork-main suite on the same source. Two old bulk-discard expectations are superseded by upstream tests. Historical cases that used changed internal APIs passed with their test drivers aligned.
  • RuboCop passed. Independent review covered both fork-specific integration changes.

thoughtless and others added 30 commits July 9, 2026 18:36
Rails commit 6d1c401dc7 ("Pass job instance to stopping?") changed
ActiveJob::Continuable#checkpoint! to call queue_adapter.stopping?(self),
passing the running job so adapters can decide whether to checkpoint
based on it.

This caused errors such as:

    ArgumentError: wrong number of arguments (given 1, expected 0)

The new argument is ignored. Solid Queue still relies solely on the
worker shutdown flag. But the signature is now compatible with both
the new and old Rails calling conventions.
The Puma plugin tests bind to a hardcoded port (9222). When a test
teardown completes and the next test setup starts, the OS may still
hold the port in TCP TIME_WAIT state, causing EADDRINUSE failures
that cascade into nil process lookups and false test failures.

Replace the hardcoded port with a dynamically allocated one via
TCPServer, so each test gets a guaranteed available port.
…thread pool

Solid Queue refused to boot when the Active Record connection pool was
smaller than the worker thread pool. This blocked legitimate setups, such
as I/O-bound queues that run many threads against a deliberately small pool.

Per the discussion in rails#736, downgrade the check from a validation error to
a SolidQueue.logger warning emitted once on the boot path in
Supervisor.start, so undersized configurations boot while still surfacing
the advisory. valid? stays purely about whether we can boot.

Closes rails#736
Lets you catch broken recurring.yml etc before the supervisor
boots and silently exits. Works as `bin/jobs check` or the
`solid_queue:check` rake task.
Skips the DB-pool check when DB creds aren't around (for isntance on
CI).

See rails#722 for more info

PS: 🐶 <- this is mochi!
We had two different warnings being surfaced in totally different ways,
and at the same time, warnings being totally independent and different
from errors. Unify everything and make them consistent.

This is a follow-up to rails#661, rails#753 and rails#745
…r poll

Before 960694e (Dec 2023, "Extract Supervised concern from Runnable"),
the mode was set once in #start as `@mode = mode.to_s.inquiry` and read
back via `attr_reader :mode`. After that commit, the reader was
replaced with a method that re-runs `(@mode || DEFAULT_MODE).to_s.inquiry`
on every call.

`#mode` is invoked in the poll-loop hot path via `running_async?` /
`running_as_fork?` / `running_inline?`, themselves called from
`shutting_down?` on every iteration of the dispatcher, worker, and
scheduler loops. With the default `queue.yml` (1s dispatcher, 0.1s
worker), this is ~3600 redundant allocations per hour per process — a
String and an ActiveSupport::StringInquirer for a value that doesn't
change after the supervisor sets it once.

Restoring the original "compute the inquiry at write time, cache it
afterwards" semantic via a custom `mode=` writer eliminates the
allocations with no behaviour change. The default-mode fallback (used
when `mode=` was never called) memoizes on first read of `#mode`.

Reproduction harness and validation:
https://github.com/<TODO>/solid-queue-idle-memory-repro

heapy diff with `GC.start(full_mark: true, immediate_sweep: true)`
before each `ObjectSpace.dump_all` confirms the `runnable.rb` line
disappears from retained-allocation reports after this change. Full
test suite (227 runs, 1299 assertions) passes with no regressions.

Refs rails#262, rails#330, rails#405.
In `Job.dispatch_all` and `Job.schedule_all` (the hot path of
`enqueue_all` / `ActiveJob.perform_all_later`), the post-insert step
rebuilt the returned set with:

  where(id: <Execution>.where(job_id: jobs.map(&:id)).pluck(:job_id))

which always issues two statements per execution table -- a `pluck`
on the execution table and a follow-up `SELECT ... FROM
solid_queue_jobs WHERE id IN (...)` -- to re-read rows we already
hold in memory. The `Job` instances passed in are the ones just
returned by `create_all_from_active_jobs`, so they are persisted and
have ids.

Filter `jobs` in memory against the plucked execution ids instead.

Per `enqueue_all` batch:

  * dispatch_all:  4 queries -> 2 (drops the two job-table reloads)
  * schedule_all:  2 queries -> 1 (drops the job-table reload)

The avoided `SELECT` is the most expensive of the four: it scans the
wide `solid_queue_jobs` row including the serialized `arguments`
payload, so the saving is bytes-over-the-wire and not just a round
trip.

Semantic equivalence:

  * Each job is inserted into at most one of ready_executions /
    blocked_executions / scheduled_executions in this code path, so
    the in-memory filter selects exactly the same job ids the prior
    `where(id: ...)` would have returned.
  * Both call sites (`prepare_all_for_execution` which concatenates
    with `+`, and `Execution::Dispatching#dispatch_jobs` which calls
    `.map(&:id)`) already coerce the result to an Array and do not
    depend on it being an `ActiveRecord::Relation` or on row order.
  * `jobs` is the same collection that was just queried back in
    `create_all_from_active_jobs`, so attribute freshness is
    unchanged versus the previous reload.

Verified against the existing `job_test`, `ready_execution_test`,
`dispatcher_test`, and `concurrency_controls_test` suites on SQLite
(55 runs, 0 failures).
Rather than have SolidQueue act on the server configured time, this
change allows you to use either the Rails application's current timezone
or a specified default.
Replace fixed sleeps with deterministic waits in the
"don't block claimed executions that get released" test.

The test was using sleep(0.2) to wait for claiming and
sleep(shutdown_timeout + 0.6) to wait for shutdown, both of
which are timing sensitive and unreliable on slow CI. Instead,
use wait_for to wait for the job to be claimed, and
terminate_process to wait for the supervisor to actually exit.
Forked processes write to both the queue tables (SolidQueue::Record, on the
queue database) and the app's JobResult rows (ApplicationRecord, on the primary
database). skip_active_record_query_cache only bypassed the queue connection's
query cache, so JobResult COUNT/find reads stayed cached and stale across forks
— a source of intermittent integration-test failures.

Nest JobResult.uncached so both connections' caches are bypassed. wait_for and
wait_while_with_timeout use this helper, so they're covered too.
Harden integration tests that fail intermittently on CI:
- Wait for prior supervisors to deregister and clear leftover records before
  creating JobResult rows, avoiding recycled-PK overwrites from orphaned writers.
- Replace fixed sleeps with wait_* conditions and lengthen timeouts.
- Scope recurring-task assertions to the task's own results.
- Retune the timing-sensitive tests so their intended results hold
  deterministically rather than relaxing the assertions: the "000" overwrite and
  the limiting-concurrency "C"-wins cases (widened pause margins), and "process a
  job that exits" (enqueue all "no exit" jobs before the exiting one so they
  always complete first).
Apps that set `config.active_record.strict_loading_by_default = true` hit
StrictLoadingViolationError when Solid Queue accesses its own associations
internally. Turn strict loading off for Solid Queue's models by setting it on
the shared SolidQueue::Record base class, so every model — and any future
association — is covered in one place.

Enable strict_loading_by_default in the dummy app so the suite guards against
regressions.
RecurringTask#enqueue rescues Job::EnqueueError (and other-adapter enqueue
failures) but forwarded only the message string to the notification payload,
never calling Rails.error.report. Reporters subscribed via
ActiveSupport::ErrorReporter (Sentry, etc.) therefore never saw recurring
enqueue failures — only a log line — so DB write failures during recurring
enqueue produced missed ticks with no alerting.

Report the rescued exception via Rails.error.report(handled: true) from both the
Solid Queue and other-adapter paths, keeping the non-bubbling behavior and the
notification payload. This aligns the recurring path with the gem's default
on_thread_error reporting.

Fixes rails#746.
Ruby 3.1 reached end-of-life in March 2025. Raise the minimum
required Ruby version to 3.2 and remove 3.1 from the CI matrix,
together with the exclusions that kept it off Rails >= 8.0.

This also lets us unpin rdoc in the Rails 7.1 and 7.2 appraisals,
which was held at 6.13 only because rdoc 6.14 dropped Ruby 3.1
compatibility.

Apps running Ruby 3.1 will continue to resolve solid_queue 1.4.x,
as the resolver honors required_ruby_version.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
`Semaphore#signal` (the single-job path) already caps its increment with
`value < limit`, but the batch `signal_all` path — used when releasing
concurrency locks in bulk, e.g. when discarding ready jobs — did not. That
let a semaphore's value climb above the concurrency limit, effectively
leaking permits and admitting more concurrent executions than allowed.

Group the jobs by their concurrency limit and cap each group's increment
with `value < limit`, matching the single-job path.
Ported from #11, a production-diagnosed fix for a
concurrency-limited job whose semaphore count could be permanently
corrupted, letting it run well past its configured limit.

The problem: a worker stays alive on a long-running job but its database
heartbeat fails transiently. Another supervisor prunes it as dead, fails its
claimed execution, releases its concurrency lock, and unblocks a replacement
— but the original execution keeps running. When it finally returns, its
stale `ClaimedExecution`, which exists only in memory, because the DB record
was deleted by the supervisor prune, also goes through the semaphore and
blocked execution release, potentially violating the limit and allowing
more concurrent jobs.

With this change, we take a lock on the claimed execution row so that
it's required that it still exists and we're the only ones acting over
it, before running the finalization code: deleting the claimed execution
row, signaling the semaphore and unblocking blocked jobs. In the
scenario described above, we'd see the claimed execution record as gone
and would do nothing.

Note that the semaphore signal + blocked jobs release is still done
after the transaction that marks the job as finished/failed, so that
these two actions can't rollback a job that finished/failed (see
873760d). Because this can only happen for the ones who got to clear the
claimed execution row, we still guarantee the lock is released just
once.

Co-Authored-By: Brice Burgess <[email protected]>
Co-Authored-By: Tom Blais <[email protected]>
The tests only waited for jobs to be claimed before signaling, so on a
slow runner the signal's exit! could land after the instant job was
claimed, or even after it had written its result, but before its
finished_at was committed, leaving it unfinished and failing the test.

Wait until the instant job has actually finished and the paused job has
actually started before signaling, so the signal always arrives while
only the paused job is in-flight, which is the scenario these tests
exist to check. The async QUIT test's pause also becomes 60 seconds
like the forked variant's: with only 1 second, a slow QUIT could land
after the paused job finished, breaking the assertion that it remains
claimed. Nothing waits for the pause, so test runtime is unaffected.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
A worker stopped while a job is running gives up on its pool after
SolidQueue.shutdown_timeout and releases the claim, but it can't stop
the thread running the job. A forked worker exits right after, killing
the thread; a worker running in-process in a test leaks it instead,
sleeping until the job's pause is over, long after its test finished.

Inside a transactional test this corrupts later tests: the leaked
job's inserts roll back with the test, and on SQLite the AUTOINCREMENT
sequence bump rolls back too, so later tests' rows get the same ids
and the leaked thread writes over them when it wakes up. This was
behind several flaky failures on SQLite: a job result overwritten with
"completed" mid-assertion, and a claimed execution stolen by a leaked
finalize call on a recycled claim id, leaving a job neither finished
nor ready. It can't happen in production: ids are only re-issued when
the insert rolls back, and a real worker's threads die with its
process.

Kill the leaked threads in the tests that create them, like a forked
worker's exit would, and fix the explanation of SQLite id reuse in the
concurrency controls test setup: with AUTOINCREMENT, committed deletes
never free ids; it's the transactional rollback that recycles them.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Future schema changes will ship as regular migrations, optional at
first and required in the next major version. `rails solid_queue:update`
(or the solid_queue:update generator directly) copies any new migration
files from the gem to the application, honoring the database the app
uses for Solid Queue via the --database option.

Together with this, add a deprecator for Solid Queue, registered with
the application so it follows the app's deprecation behavior settings,
and a warning helper that features guarded behind pending migrations
can use to instruct users to update.

Extracted from earlier work on linking claimed executions to processes
by name, which ended up not being needed.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The test slept a fixed 0.2 seconds after enqueuing and then signaled
TERM, assuming the job would be mid-step by then. On a slow runner the
signal could arrive before any worker had even claimed the job, and
the wait for released jobs would return immediately, unable to tell
"released" from "never claimed", so the test asserted against a job
result that hadn't been touched yet.

Have the job write a "started" marker at the top of its first step and
wait for it before signaling, so the interruption always lands while
the job is paused inside step one, which is the scenario the test
exists to check: interrupt between steps, resume, complete.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Makes isolating the scheduler on its own process explicit, matching
the existing --skip-recurring option and the workaround of an empty
workers/dispatchers config.

Fixes rails#484

Co-authored-by: Cursor <[email protected]>
…nnection`

Bare `connection` resolves to the deprecated ActiveRecord::Base.connection,
which raises under permanent_connection_checkout = :disallowed on Rails 8.1.
Follows the connection_pool.with_connection pattern from rails#652.
The tests killed the whole process group to clean up, but the
supervisor under test is actively replacing its stalled forks, and a
group KILL races that forking: a fork spawned concurrently with the
kill can escape it, wake up from its stalled boot long after the test
has finished, register itself and start polling, holding the test
database's write lock and cascading lock timeouts through unrelated
tests, as seen on CI with SQLite.

Terminating the supervisor gracefully instead lets it clean up its own
forks: it stops replacing them first, and a fork stuck in boot is
covered by the QUIT escalation, as its signal handlers are installed
before the boot callbacks where it stalls. This also lets go of the
replacement fork's liveness assertion: the replacement stalls too, so
whether it's alive depends on where its own boot timeout is.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
ceritium and others added 13 commits November 3, 2026 11:56
Dispatching a set of jobs with concurrency controls acquires each job's
semaphore one by one, inside the transaction that dispatches the whole
set, and in whatever order the jobs come in. Two dispatchers whose
batches share concurrency keys can then acquire them in opposite order
and deadlock, and so can bulk enqueues. The batch that's aborted stays
scheduled, so no job is lost and the limits hold, but the dispatcher
that hits the error is delayed.

Go through the jobs by concurrency key instead, so everyone acquires the
locks they share in the same order. Within a key, jobs keep their id
order, so the same job as before gets the lock first.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Acq8BRNz9v7w9mKYLYRdCi
… tests

It runs two dispatchers in threads against the same semaphores, like the
lock tests in semaphore_test.rb, so it belongs there rather than in its
own integration file. It still deadlocks on PostgreSQL and MySQL without
dispatching by concurrency key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A semaphore counts free slots but doesn't know which jobs hold them, so
any job that gave a slot back by key counted as a holder:

- A job that ran past its duration gave its slot back to the semaphore
  created after its own expired, letting another job start while the
  new holder was still running (rails#827).
- A job dispatched while its class was missing skipped its limits, but
  gave a slot back if it later ran where its class loads.
- A job whose class was missing when it ran couldn't give back the slot
  it got when it was dispatched (rails#825).

Now a job records the id of the semaphore it got a slot on, and its
limit, in its serialized Active Job data, and gives the slot back only
to that semaphore. A job that skips its limits records that it holds
no slot. Jobs that got their slot before this change have nothing
recorded and keep giving it back by key, until 2.0.

The first two tests come from the reproduction in rails#827.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On MySQL with REPEATABLE READ, a plain read after taking a slot uses the
transaction's snapshot, which can still include a semaphore that expired
and was deleted after the snapshot was taken, so the job could record
that one instead of the semaphore it just created. A locking read sees
the latest committed rows.

A job that keeps its concurrency key after its class drops
limits_concurrency takes its slot with a limit of 1, so record that
rather than nil, which failed to give the slot back if the class was
also missing when the job ran.

Also cover jobs sharing a semaphore, discarding ready jobs one by one
and in bulk, and retried jobs, and explain the change in UPGRADING.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t the upgrade note

A plain read inside a REPEATABLE READ transaction can still see a
semaphore deleted after the transaction's snapshot, so without the
locking read the job would record that one. The test fails without it.

A slot that isn't given back comes back only when its semaphore expires,
and every job taking or giving back a slot for the same key pushes that
out, so on a busy key with a limit above 1 it may not come back for a
long time. Say so in UPGRADING instead of promising it comes back after
duration.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
concurrency_limited? now just means the job has a concurrency key, as on
the Active Job side, and the code checks for a missing class where that
matters. The job exposes the semaphore it got its slot from and the
limit it got it with, so the semaphore asks for those instead of
reading the recorded data itself.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jpcamara jpcamara changed the title feat(solid-queue): integrate upstream 1.7 with fork parity feat(solid-queue): integrate upstream 1.7.2 with fork parity Nov 24, 2026
Comment thread test/unit/process_recovery_test.rb Outdated
# record was deleted above, so only the replacement worker remains registered.
wait_for_registered_processes(1, timeout: 5.seconds)
# Ensure supervisor replaces the worker (even though its own record was missing)
wait_for_registered_processes(2, timeout: 5.seconds)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Commit 968778d reverted wait_for_registered_processes(1, timeout: 5.seconds) (from main commit 8e9a6cf) back to 2.

After this test deletes the supervisor record (count becomes 1), reaps and deregisters the killed worker (0), and starts the replacement worker (1), the process count never reaches 2. Because wait_while_with_timeout rescues Timeout::Error without failing, line 87 blocks for the full 5 seconds on every run and does not verify that the dead worker deregistered.

Restore the expected count to 1:

wait_for_registered_processes(1, timeout: 5.seconds)

Posted by Cursor on behalf of Jon Hinson.

Comment on lines +68 to +72
def deregister
# Retain the stopped parent so pruning can fail pending claims once its
# heartbeat expires. Normal deregistration would release those claims.
super if pending_cleanup.empty?
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When pending_cleanup is non-empty and ForkSupervisor shuts down on QUIT or a TERM timeout, live forks exit via exit! without deregistering. Skipping super here also skips cascading deregistration of those live forks. Their SolidQueue::Process rows remain registered for up to 5 minutes until Process.prune runs and fails their claimed jobs with ProcessPrunedError, instead of returning them to :ready immediately.

AsyncSupervisor#attempt_to_deregister handles this case by deregistering still-tracked process_instances while retaining dead-worker rows in pending_cleanup.

Suggested fix: align ForkSupervisor (or Maintenance#deregister) with AsyncSupervisor#attempt_to_deregister when pending_cleanup.any?:

def deregister
  if pending_cleanup.empty?
    super
  else
    tracked_names = process_instances.values.map(&:name) - pending_cleanup.keys
    SolidQueue::Process.where(supervisor_id: process_id, name: tracked_names).find_each(&:deregister)
  end
end

Optional follow-up: calling a final retry_pending_cleanup before checking pending_cleanup.empty? during shutdown recovers dead-worker claims immediately if the DB error cleared before shutdown. (Note: 3 tests in test/unit/supervisor_maintenance_test.rb currently unstub DB errors before calling shutdown and would need updating if you add that retry.)

Posted by Cursor on behalf of Jon Hinson.

@cursor

cursor Bot commented Nov 30, 2026

Copy link
Copy Markdown

Optional test-hygiene nit (inherited from upstream): destroy_records in test/test_helper.rb (lines 49–59) does not clear SolidQueue::Pause, SolidQueue::BlockedExecution, SolidQueue::RecurringExecution, SolidQueue::BatchExecution, or SolidQueue::Batch.

Using delete_all in full-table test teardown is safe and cleaner than destroy_all: all 8 foreign keys across PostgreSQL, MySQL, and SQLite use indexed ON DELETE CASCADE, and those leaf tables have no destroy callbacks.

If you add cleanup for these tables, two details matter:

  1. Run SolidQueue::BatchExecution.delete_all and SolidQueue::Batch.delete_all before SolidQueue::Job.destroy_all. Otherwise, Job#before_destroy :destroy_batch_execution can trigger BatchExecution#after_commit :finish_batch and enqueue a new callback job after Job.destroy_all has already queried the table.
  2. Guard both batch deletes with if SolidQueue::Batch.migrated? so BatchPendingMigrationsTest (which drops the batch tables in setup) does not raise ActiveRecord::StatementInvalid.

Posted by Cursor on behalf of Jon Hinson.

has_one :blocked_execution

delegate :concurrency_limit, :concurrency_duration, :concurrency_max_blocked, to: :job_class
delegate :concurrency_max_blocked, to: :job_class

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Low / preventative: add allow_nil: true to this delegation:

delegate :concurrency_max_blocked, to: :job_class, allow_nil: true

On this PR alone, dispatch is guarded by acquire_concurrency_lock when job_class is nil, so dispatch does not crash today. However, direct calls to job.concurrency_max_blocked raise Module::DelegationError for missing job classes, and open PR #18 (max-blocked-skip-lock) calls blocked_queue_full? before acquire_concurrency_lock. Adding allow_nil: true here prevents a crash on missing job classes once PR #18 rebases.

Consider adding a unit test in JobTest covering concurrency_max_blocked when job_class is nil.

Posted by Cursor on behalf of Jon Hinson.

@cursor
cursor Bot force-pushed the jpcamara/Integrate-upstream-Solid-Queue branch 2 times, most recently from da93d28 to 6dfc5c0 Compare November 30, 2026 23:12
@cursor

cursor Bot commented Nov 30, 2026

Copy link
Copy Markdown

I pushed six commits on top of 2ade958 to address the four review items and two test-only CI races:

  • 95f3a33 / 6dfc5c0: Wait for killed worker deregistration and replacement in ProcessRecoveryTest.
  • 0c462d8: Deregister tracked supervisees and retry pending cleanup on shutdown.
  • 35084b6: Allow a nil job_class when delegating concurrency_max_blocked.
  • e4c2de5: Clear pause, blocked, recurring, and batch tables in test teardown.
  • bd7b986: Kill running jobs after the WorkerTest capacity sleep tests so leaked threads do not corrupt later PostgreSQL tests on Rails 7.1 (relates to Tests flaking on CI since mid-August, on main and on PRs rails/solid_queue#797).

All 121 CI checks pass on bd7b986.

Note on CI container flakes: earlier runs on this branch also failed in Initialize containers with address already in use on host ports 33066 and 55432 (which sit inside Linux's ephemeral port range 32768-60999) and one 30-second MySQL healthcheck timeout. Upstream rails/solid_queue sees the same container-startup flakes on GitHub-hosted ubuntu-latest runners. We are holding off on updating .github/workflows/main.yml and test/dummy/config/database.yml in this PR to avoid extra fork drift from upstream; if a container startup flake occurs, rerunning the failed job clears it, and we can address dynamic ports and the MySQL healthcheck window separately if needed.

Posted by Cursor on behalf of Jon Hinson.

…eryTest

After FailedExecution is committed, the killed worker's process row can briefly still exist before release_claimed_jobs_by deregisters it. Waiting on SolidQueue::Process.count == 1 can return early on that stale row and then assert while the replacement worker is still booting (count == 0). Wait explicitly until the killed worker row is gone and a replacement worker is registered.
When pending_cleanup is non-empty during shutdown, run a final retry_pending_cleanup first. If pending cleanup remains, retain the supervisor and dead-worker rows for pruning while deregistering still-tracked live supervisees so their claimed jobs return to ready immediately in both ForkSupervisor and AsyncSupervisor.
Add allow_nil: true to SolidQueue::Job::ConcurrencyControls' delegation of concurrency_max_blocked so jobs whose class cannot be constantized return nil instead of raising Module::DelegationError.
@cursor
cursor Bot force-pushed the jpcamara/Integrate-upstream-Solid-Queue branch from bd7b986 to 9bea2c3 Compare December 1, 2026 00:09
@cursor

cursor Bot commented Dec 1, 2026

Copy link
Copy Markdown

Update superseding the previous summary:

I squashed the two ProcessRecoveryTest commits into one and force-pushed five commits on top of 2ade958. The CI run on 9bea2c3 immediately hit the 0.0.0.0:55432/tcp: address already in use container-startup flake on Tests (3.4, sqlite, rails_8_1) (while all other 120 checks passed), so I added a sixth commit (31ddd95) to fix the CI port contention and MySQL healthcheck window.

Final six commits on top of 2ade958:

  • f7d0609: Wait for killed worker deregistration and replacement in ProcessRecoveryTest.
  • 068182f: Deregister tracked supervisees and retry pending cleanup on shutdown.
  • d3757c8: Allow a nil job_class when delegating concurrency_max_blocked.
  • df7a41f: Clear pause, blocked, recurring, and batch tables in test teardown.
  • 9bea2c3: Kill running jobs after the WorkerTest capacity sleep tests (relates to Tests flaking on CI since mid-August, on main and on PRs rails/solid_queue#797).
  • 31ddd95: Allocate dynamic CI service ports (3306 and 5432) and relax the MySQL healthcheck in .github/workflows/main.yml, and read POSTGRES_PORT and MYSQL_PORT with ENV.fetch fallbacks (55432 and 33066) in test/dummy/config/database.yml (docker-compose.yml is unchanged).

All 121 CI checks pass on 31ddd95.

Posted by Cursor on behalf of Jon Hinson.

@cursor
cursor Bot force-pushed the jpcamara/Integrate-upstream-Solid-Queue branch from 31ddd95 to d3757c8 Compare December 1, 2026 03:53
@cursor

cursor Bot commented Dec 1, 2026

Copy link
Copy Markdown

Update: we removed the three unrelated upstream test and CI commits from this PR and moved each commit to its own branch, then force-pushed this branch to d3757c8.

Remaining commits above 2ade958

  1. f7d0609: Wait for killed worker deregistration and replacement in ProcessRecoveryTest.
  2. 068182f: Deregister tracked supervisees and retry pending cleanup on shutdown.
  3. d3757c8: Allow nil job_class when delegating concurrency_max_blocked.

Moved to separate branches

  • test-helper-teardown-cleanup (3bf0642): Clear pause, blocked, recurring, and batch tables in test/test_helper.rb.
  • worker-test-capacity-sleep-cleanup (f8949e2): Kill running jobs after WorkerTest capacity sleep tests (relates to Tests flaking on CI since mid-August, on main and on PRs rails/solid_queue#797).
  • ci-dynamic-service-ports (8bb8f80): Allocate dynamic CI service ports and relax the MySQL healthcheck in .github/workflows/main.yml and test/dummy/config/database.yml.

All CI checks on d3757c8 pass.

Posted by Cursor on behalf of Jon Hinson.

@jpcamara
jpcamara merged commit 4897eb7 into main Dec 1, 2026
178 of 179 checks passed
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

Successfully merging this pull request may close these issues.