File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -442,6 +442,20 @@ workers will sleep for 5 seconds.
442442
443443``` ruby
444444# The max number of jobs a worker may lock at a time (also the size of the thread pool):
445+ # NOTE: This should be less than your ActiveRecord connection pool size. The worker process
446+ # itself needs one connection for polling and locking, so if max_claims >= pool_size, a job
447+ # thread that cannot check out a connection within the checkout timeout may raise
448+ # ActiveRecord::ConnectionTimeoutError. The worker will log a warning at startup if this
449+ # is detected.
450+ #
451+ # The general rule is: if each job thread needs N connections and max_claims is M,
452+ # your pool should have at least N * (M + 1) connections. The most common case is N=1
453+ # (one connection per thread), so pool_size should be at least max_claims + 1.
454+ #
455+ # For example, if your pool size is 5, set max_claims to 4:
456+ #
457+ # # config/initializers/delayed_job.rb
458+ # Delayed::Worker.max_claims = ActiveRecord::Base.connection_pool.size - 1
445459Delayed ::Worker .max_claims = 5
446460
447461# The number of jobs to which a worker may "read ahead" when locking jobs (mysql only!):
You can’t perform that action at this time.
0 commit comments