A reaper retry decision can overwrite a task that someone else already handled
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 64/100
Rechercherichtung
Read reaper.lua, threadmill/backends/lua/acknowledge.lua, and the Redis backend in threadmill/backends/redis.py, then inspect commit 382880b and the TestRedisBrokerReap guard tests. Trace how the claim reaches acknowledge and requeue decisions. Done means stale decisions are dropped while matching-claim acknowledge and requeue paths pass, including the worker-ack, claim-takeover, and inspector-action race tests.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
After the lease-expiry retry change (commit 382880b), the reaper hands expired tasks to the retry callback:
reaper.luaclaims expired running entries. It renews their lease toRedisBroker.CLAIM_TTLand returns the IDs. It keeps the task data hash.RedisBroker._reap_taskdeserializes each claimed task, appends theAcknowledgementTimeouterror, and evaluates theretrycallback of the task. Then it callsbackend.requeue(...)to retry orbackend.acknowledge(...)to finalize.
The claim protects against two brokers that claim the same task in the same pass. The select-and-renew step in the script is atomic. But the decision does not make sure that the broker still holds the claim. A stale decision can act on a task that someone else already handled:
- Late worker acknowledgement (single node). A slow task finishes after its lease expires. The
acknowledge()call of the worker storesSUCCESSFULand removes the task hash. If the broker read the data before that, itsrequeue()removes the result and overwrites the task data. It also adds the task to the deferred set again. The task runs again although it succeeded. - Stalled broker, claim taken over. Broker A claims a task and then stalls past
CLAIM_TTL(a GC pause, a slow retry callback, or a network problem). Broker B claims the task again and completes the decision. When A starts again, its stale decision overwrites the outcome from B and can schedule the task twice. - Inspector action. A user requeues or removes the task between the claim and the decision. The decision of the broker undoes that action.
The finalize path is mostly protected by the ZREM guard in acknowledge.lua. A second acknowledgement is a no operation. The dangerous operation is mainly requeue, which returns the task to the queue. All paths can also overwrite the task data.
Proposed correction
Make the reap decision conditional on the claim that produced it:
- Let
reaper.luawrite a claim identity with the running entry. Use the claim deadline and compareZSCORE, or use a token in the task hash. - Give
acknowledge()andrequeue()an optional guard parameter. The Lua scripts must make sure that the parameter matches before they write. A mismatch discards the decision. The claim then lapses and the next pass decides again. The result is a delay, not a lost task. - Tests: the worker-ack race, claim takeover after
CLAIM_TTL, inspector dequeue between claim and decision, and the matching-claim path for bothacknowledgeandrequeue.
An implementation of this guard was written and then removed to keep the lease-expiry retry change small. The code can return from commit 382880b (files threadmill/backends/lua/acknowledge.lua, threadmill/backends/redis.py, and the TestRedisBrokerReap guard tests).
- Vorherrschende Sprache
- Python
- Sterne
- 19
- Forks
- 1
- Ø Merge
- 14 Std. 39 Min.
- Gemergte PRs (30 T.)
- 21
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
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 codingjoe/threadmill
-
Add worker pool telemetryEvtl. wieder frei @codingjoe hat das vor 100 Tagen übernommen, und es ist kein Pull Request offen. Offenenhancement
codingjoe/threadmill#18 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in codingjoe/threadmill
Ähnliche Issues
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
Deepak3699/Ai_Mentor#244 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
btclib-org/btclib-node#1880 ·
Maintainer antworten meist innerhalb von 1 Tag
-
CONTRIBUTING.md: say how ticketless bug fixes and feature PRs are handledEvtl. vergeben @khuisman hat das heute übernommen. Offenv0.9.2
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 84/100
khuisman/mcp-gee-sweet#941 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
pyjanitor-devs/pyjanitor#1758 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug ready for review
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
odysseus-dev/odysseus#6641 ·
Maintainer antworten meist innerhalb von 1 Tag