A reaper retry decision can overwrite a task that someone else already handled
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 64/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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).
- Lenguaje dominante
- Python
- Estrellas
- 19
- Forks
- 1
- Merge medio
- 9 h 46 min
- PR fusionados (30 d)
- 17
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de codingjoe/threadmill
-
bug real side quest
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
codingjoe/threadmill#78 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug real
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
codingjoe/threadmill#73 ·
Los mantenedores suelen responder en 1 día
-
perf real
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
codingjoe/threadmill#74 ·
Los mantenedores suelen responder en 1 día
-
bug real
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
codingjoe/threadmill#75 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
perf real
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
codingjoe/threadmill#67 ·
Los mantenedores suelen responder en 1 día
Todos los issues de codingjoe/threadmill
Issues similares
-
Link Checker ReportAbiertoautomated issue report
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
RapidAI/RapidOCRDocs#119 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
btclib-org/btclib-node#1833 ·
Los mantenedores suelen responder en 1 día
-
IRIS reader: no-data velocity bins (DB_VEL, DB_VELC) returned as 0.0 m/s instead of NaNPosiblemente ocupada @syedhamidali la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 2 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 80/100
elodin-sys/elodin#890 ·
Los mantenedores suelen responder en 1 día