Bound the web-push delivery queue (max_queue, not the ignored queue_size)

Concurrent::ThreadPoolExecutor takes :max_queue; :queue_size was silently
ignored, leaving the delivery backlog unbounded (max_queue: 0). A flood of
valid push subscriptions could accumulate queued deliveries without limit --
more acute now that each delivery task also resolves DNS. Using max_queue: 10000
activates the intended cap; overflow raises RejectedExecutionError under the
default :abort policy, which deliver_later already rescues (push is best-effort,
retried on the next message).
This commit is contained in:
Jeremy Daer
2026-08-26 00:19:29 -07:00
parent 7d5bb50b9b
commit a001ddd8aa
+6 -1
View File
@@ -3,7 +3,12 @@ class WebPush::Pool
attr_reader :delivery_pool, :invalidation_pool, :connection, :invalid_subscription_handler
def initialize(invalid_subscription_handler:)
@delivery_pool = Concurrent::ThreadPoolExecutor.new(max_threads: 50, queue_size: 10000)
# max_queue (not queue_size, which ThreadPoolExecutor silently ignores) caps
# the delivery backlog: an unbounded queue lets a flood of subscriptions
# accumulate without limit, more so now that each task also resolves DNS.
# Overflow raises RejectedExecutionError under the default :abort policy,
# which deliver_later rescues -- push is best-effort and retried next message.
@delivery_pool = Concurrent::ThreadPoolExecutor.new(max_threads: 50, max_queue: 10000)
@invalidation_pool = Concurrent::FixedThreadPool.new(1)
@connection = Net::HTTP::Persistent.new(name: "web_push", pool_size: 150)
@invalid_subscription_handler = invalid_subscription_handler