Suggested API: on_conflict: :replace
Maintainer antworten meist innerhalb von 4 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 25/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- Ruby
- Sterne
- 2.5k
- Forks
- 271
- Ø Merge
- 5 T. 6 Std.
- Gemergte PRs (30 T.)
- 5
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Kein Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus rails/solid_queue
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
rails/solid_queue#838 ·
Maintainer antworten meist innerhalb von 4 Tagen
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 45/100
rails/solid_queue#836 ·
Maintainer antworten meist innerhalb von 4 Tagen
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
rails/solid_queue#834 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 4 Tagen
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 42/100
rails/solid_queue#808 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 4 Tagen
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
rails/solid_queue#806 ·
Maintainer antworten meist innerhalb von 4 Tagen
Alle Issues in rails/solid_queue
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
jenkins-infra/jenkins.io#9615 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
fix(ocr): compile the Tesseract-free pipeline with Tokio runtimeEvtl. vergeben @Goldziher hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
WhatsApp Cloud template sync saves a partial template list when one page of the Graph API response failsEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 60/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 91/100
simp/pupmod-simp-ssh#270 ·