Suggested API: on_conflict: :replace
維護者通常 4 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
The payload names no files or tests. Start from the existing on_conflict: :discard path used by limits_concurrency, then trace how a pending job is stored and identified by its concurrency key. Decide the semantics for :replace and whether payload batching is included, then add coverage for first-wins versus last-wins behavior. Done means the new option is implemented, documented, and tested for duplicate enqueues while a matching job is still waiting.
由索引模型根據 Issue 內容生成。
描述
Description
Currently, Solid Queue provides an on_conflict: :discard option to enforce uniqueness. This follows a "first wins" behavior, where subsequent duplicate jobs are dropped if a matching job is already pending in the queue.
However, many use cases (such as syncing the latest user state or syncing inventory) require a "last value wins" strategy. If a new job with the exact same concurrency key is enqueued while a previous one is still waiting, the queue should ensure that only the latest job (carrying the freshest payload) is processed. This can be achieved either by replacing the pending job entirely or updating its payload.
Introducing this strategy would also significantly boost performance under high-frequency updates, as it prevents the system from wasting database and worker cycles processing outdated intermediate payloads.
Examples from other queue managers
• Sidekiq Enterprise / Sidekiq Unique Jobs: Supports options like on_conflict: :replace or rescheduling to overwrite the payload of an un-executed job with the freshest data.
• Lowkiq: Passes an array of all enqueued payloads directly to the perform method, allowing the developer to decide how to process or batch them.
Suggested API
It would be useful to introduce a configuration option to define how concurrency conflicts are handled:
Option A: Pure :replace strategy
class UpdateInventoryJob < ApplicationJob
limits_concurrency to: 1, key: ->(payload) { payload.id }, on_conflict: :replace
def perform(payload)
# ...
end
end
Option B: Custom conflict hook with payload batching
class UpdateInventoryJob < ApplicationJob
limits_concurrency to: 1, key: ->(product) { product.id }, on_conflict: :replace
def perform_on_conflict(payloads)
# Allows manually processing the final state
perform(payloads.last)
end
end
- 主要語言
- Ruby
- 星號
- 2.5k
- 分支
- 271
- 平均合併
- 5 天 6 小時
- 30 天內合併 PR
- 5
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 提供 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 沒有貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
rails/solid_queue 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
rails/solid_queue#838 ·
維護者通常 4 天內回覆
-
難度 5/5 一週以上 新手友好度 45/100
rails/solid_queue#836 ·
維護者通常 4 天內回覆
-
難度 5/5 一週以上 新手友好度 25/100
rails/solid_queue#834 · 1 則留言 ·
維護者通常 4 天內回覆
-
難度 5/5 一週以上 新手友好度 42/100
rails/solid_queue#808 · 3 則留言 ·
維護者通常 4 天內回覆
-
難度 4/5 3-5 天 新手友好度 45/100
rails/solid_queue#806 ·
維護者通常 4 天內回覆
查看 rails/solid_queue 的全部 Issue
相似的 Issue
-
開発用DockerイメージにPlaywrightのシステム依存を追加する可能已有人在做 @momocus 今天認領。 未關閉
難度 1/5 1 小時以內 新手友好度 85/100
sakazuki-org/sakazuki#1453 ·
維護者通常 3 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
jenkins-infra/jenkins.io#9615 · 1 則留言 ·
維護者通常 1 天內回覆
-
fix(ocr): compile the Tesseract-free pipeline with Tokio runtime可能已有人在做 @Goldziher 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
Metric tooltips that contradict how the metric is calculated可能已有人在做 @aniadeadu 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
WikiEducationFoundation/WikiEduDashboard#7303 · 1 則留言 ·
維護者通常 1 天內回覆
-
WhatsApp Cloud template sync saves a partial template list when one page of the Graph API response fails可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 2 天內回覆