Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rails/solid_queue
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.5.1
Choose a base ref
...
head repository: rails/solid_queue
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.6.0
Choose a head ref
  • 16 commits
  • 18 files changed
  • 4 contributors

Commits on Jul 30, 2026

  1. Add fiber execution mode for workers

    Workers can now be configured with `fibers: N` as an alternative to
    `threads: N` (specifying both is invalid). In fiber mode, claimed jobs
    execute as fibers on a single Async reactor thread, bounded by the
    configured fiber count. This suits mostly I/O-bound jobs, where
    cooperative scheduling allows much higher in-flight capacity with
    fewer database connections than a thread pool.
    
    The existing pool was extracted into ExecutionPools::ThreadPool
    (SolidQueue::Pool remains as an alias), with the new
    ExecutionPools::FiberPool sharing the same interface. Pools are built
    on worker boot, after forking, since a reactor thread wouldn't survive
    a fork.
    
    Fiber mode requires the async gem (>= 2.24), which is not a runtime
    dependency: workers configured with `fibers` raise a clear error if it
    isn't available. It also requires fiber-scoped isolated execution
    state (ActiveSupport::IsolatedExecutionState.isolation_level = :fiber),
    validated at boot and configuration-check time. The database pool size
    guidance is fiber-aware and Rails-version aware: on Rails 7.2+, fibers
    release connections between queries, so a fiber worker needs far fewer
    connections than its fiber count.
    crmne authored and rosa committed Jul 30, 2026
    Configuration menu
    Copy the full SHA
    222df7a View commit details
    Browse the repository at this point in the history
  2. Remove IO timeout compatibility shim for Ruby 3.1

    Now that the minimum supported Ruby version is 3.2, IO#timeout,
    IO#timeout= and IO::TimeoutError, which async expects, are always
    available natively, and we no longer need to patch them in.
    
    Co-Authored-By: Claude Opus 4.8 <[email protected]>
    rosa and claude committed Jul 30, 2026
    Configuration menu
    Copy the full SHA
    3ba5e30 View commit details
    Browse the repository at this point in the history
  3. Block on the pending executions queue instead of polling the reactor

    The fiber pool's reactor looped with a 10ms sleep to check for newly
    posted work, and again while waiting for in-flight executions to finish
    during shutdown, on the assumption that the async gem can't reliably
    wake the reactor from another thread.
    
    It can: Thread::Queue#pop is fiber-scheduler-aware, so a fiber blocking
    on it suspends properly while other fibers run, and a push from the
    poller thread wakes the reactor through the scheduler (via
    Scheduler#unblock and the selector's cross-thread wakeup, reliable
    since io-event 1.3, which all supported async versions require). This
    removes the idle CPU cost of the busy-poll and the up-to-10ms latency
    between claiming a job and executing it.
    
    Shutdown now closes the queue, which wakes the blocked pop, drains any
    already-queued executions and then returns nil, ending the loop. The
    separate wait for in-flight executions is unnecessary: they run in
    fibers that are children of the reactor's top-level task, which already
    waits for all its children before exiting.
    
    Co-Authored-By: Claude Opus 4.8 <[email protected]>
    rosa and claude committed Jul 30, 2026
    Configuration menu
    Copy the full SHA
    1bf083f View commit details
    Browse the repository at this point in the history
  4. Add integration test for fiber workers and clarify their docs

    Cover the full lifecycle of a supervised, forked fiber worker: jobs
    executing in fibers, graceful termination draining in-flight jobs, and
    abrupt termination releasing claimed jobs. The unit tests exercise the
    fiber pool in-process only, which wouldn't catch a pool built before
    forking, whose reactor thread wouldn't survive the fork.
    
    Also restore the generic first worker in the configuration example,
    adding the fiber worker as an extra entry instead of replacing it, and
    note that the fiber isolation level is an application-wide setting,
    not scoped to Solid Queue's processes.
    
    Co-Authored-By: Claude Opus 4.8 <[email protected]>
    rosa and claude committed Jul 30, 2026
    Configuration menu
    Copy the full SHA
    710be37 View commit details
    Browse the repository at this point in the history
  5. Store only the pool type and size in worker metadata

    The in-flight gauge was refreshed on heartbeats only, so it could show
    counts that were stale by up to a heartbeat interval; better not to
    show it than to show stale information, especially given the exact
    count is always available from claimed executions. The pool type and
    size are constant, and the pool knows both, so the worker can store
    them directly when registering, as it did before, and the pools don't
    need to provide changing metadata at all.
    
    Co-Authored-By: Claude Opus 4.8 <[email protected]>
    rosa and claude committed Jul 30, 2026
    Configuration menu
    Copy the full SHA
    944aa72 View commit details
    Browse the repository at this point in the history
  6. Rely on configuration validation for worker execution options

    The configuration already validates that workers specify either
    threads or fibers but not both, and that's where option validation
    belongs; the worker doesn't validate any of its other options.
    
    Co-Authored-By: Claude Opus 4.8 <[email protected]>
    rosa and claude committed Jul 30, 2026
    Configuration menu
    Copy the full SHA
    5048cd7 View commit details
    Browse the repository at this point in the history
  7. Start the fiber pool's reactor lazily on first use

    In the default fork supervisor mode, workers are instantiated by the
    supervisor before forking, so a reactor thread started when the pool
    is built wouldn't survive the fork. Starting it when the first
    execution is posted makes the fiber pool safe to build at any point,
    matching the thread pool, which already builds its executor lazily on
    first use.
    
    Co-Authored-By: Claude Opus 4.8 <[email protected]>
    rosa and claude committed Jul 30, 2026
    Configuration menu
    Copy the full SHA
    50468fa View commit details
    Browse the repository at this point in the history
  8. Simplify worker initialization

    Build the execution pool directly when the worker is initialized,
    which is safe now that both pools start their threads lazily. Merge
    the worker defaults unconditionally and choose the pool type with a
    single check on the fibers option, relying on the configuration's
    validation to prevent threads and fibers from being combined.
    
    If a worker is instantiated directly with no pool options, it defaults
    to a thread pool; if it somehow gets both options, fibers win.
    
    Co-Authored-By: Claude Opus 4.8 <[email protected]>
    rosa and claude committed Jul 30, 2026
    Configuration menu
    Copy the full SHA
    5270cc8 View commit details
    Browse the repository at this point in the history
  9. Report errors escaping the execution future

    The rescue inside the future covers job execution, but an error raised
    when restoring capacity or waking up the worker would escape it and
    reject the future with nobody watching. Attach the on_rejection
    callback the old pool had as a backstop, so those errors are also
    reported via handle_thread_error.
    
    Co-Authored-By: Claude Opus 4.8 <[email protected]>
    rosa and claude committed Jul 30, 2026
    Configuration menu
    Copy the full SHA
    000e8ba View commit details
    Browse the repository at this point in the history
  10. Rescue only the code that runs with capacity reserved when posting

    Instead of tracking whether capacity had been reserved with a local
    flag, scope the rescue to the code that runs after the reservation,
    which is the only part that needs to restore it on failure.
    
    Co-Authored-By: Claude Opus 4.8 <[email protected]>
    rosa and claude committed Jul 30, 2026
    Configuration menu
    Copy the full SHA
    08e6098 View commit details
    Browse the repository at this point in the history
  11. Extract a base class for the execution pools

    Both pools share the capacity ledger: the reserve/restore accounting,
    the idle notification, and the reserve-then-schedule shape of post.
    Move all of that to ExecutionPools::Base, leaving each pool with just
    its scheduling mechanism: the thread pool schedules executions on a
    Concurrent::ThreadPoolExecutor via schedule, and the fiber pool hands
    them to its reactor, adding its fatal-error and shutdown guards on
    top of the base's post.
    
    The default way of performing an execution, wrapped in the app
    executor, reporting errors and restoring capacity, also lives in the
    base class; the fiber pool overrides it to treat Async::Stop as fatal.
    
    The pool type is derived from the class name, and the factory performs
    the lookup in reverse, trusting the type it receives: the worker only
    ever passes :thread or :fiber.
    
    Co-Authored-By: Claude Opus 4.8 <[email protected]>
    rosa and claude committed Jul 30, 2026
    Configuration menu
    Copy the full SHA
    6e27144 View commit details
    Browse the repository at this point in the history
  12. Move the fiber worker checks to Configuration

    The async dependency and isolation level checks were surfaced through
    Configuration's validations but implemented in the fiber pool, which
    also ran them when built. Configuration is where these belong: it
    validates every supervised path before any process is instantiated,
    and reports through valid? and check. The pool now just requires the
    async gem lazily when starting its reactor, keeping setups without
    fiber workers from ever loading it, and otherwise trusts its caller,
    like the rest of the internal classes.
    
    Co-Authored-By: Claude Opus 4.8 <[email protected]>
    rosa and claude committed Jul 30, 2026
    Configuration menu
    Copy the full SHA
    30b92ca View commit details
    Browse the repository at this point in the history
  13. Reorganize the execution pools under SolidQueue::Pool

    Replace the ExecutionPools module with a Pool abstract class that the
    thread and fiber pools inherit from, and that builds the right pool
    for a worker, mirroring how Supervisor relates to ForkSupervisor and
    AsyncSupervisor.
    
    Co-Authored-By: Claude Opus 4.8 <[email protected]>
    rosa and claude committed Jul 30, 2026
    Configuration menu
    Copy the full SHA
    9c0d5d3 View commit details
    Browse the repository at this point in the history
  14. Roll back transactions leaked by killed job threads in tests

    Killing the job threads leaked by in-process workers can interrupt a
    thread in the middle of a database write, skipping the rollback in the
    transaction's ensure block while still returning the connection to the
    pool. The open transaction then locks SQLite for every other writer
    until the pool reaper flushes the idle connection minutes later,
    cascading "database is locked" errors through the rest of the suite.
    
    Wait for the killed threads to die and drop all pool connections,
    rolling back anything they left open. Transactional tests don't need
    it: they pin every thread to the test's own connection.
    
    Co-Authored-By: Claude Fable 5 <[email protected]>
    rosa and claude committed Jul 30, 2026
    Configuration menu
    Copy the full SHA
    7f59932 View commit details
    Browse the repository at this point in the history
  15. Document how to update dynamic recurring tasks

    The scheduler only detects dynamic tasks being created and deleted, so
    updating a SolidQueue::RecurringTask record in place isn't picked up
    until a restart. This is by design: the documented way to update a task
    is to unschedule it and schedule it again.
    
    This wasn't stated in the README and has caused some confusion (#738,
    and the closed #739 and #774), so spell it out in the dynamic tasks
    section.
    wintan1418 authored and rosa committed Jul 30, 2026
    Configuration menu
    Copy the full SHA
    2a479f6 View commit details
    Browse the repository at this point in the history

Commits on Jul 31, 2026

  1. Bump solid_queue to 1.6.0

    rosa committed Jul 31, 2026
    Configuration menu
    Copy the full SHA
    86f3d92 View commit details
    Browse the repository at this point in the history
Loading