Conversation
… running The DLQ worker loads the failed event, replays it and then writes the result without reading it again. If an operator discarded the event through the API while the replay ran, a failed attempt wrote over the discard: the event went back to pending with a next_retry_at and the sweep kept retrying something the operator had taken out of the queue. The result is now written under a row lock. A failed attempt leaves the event alone if it is no longer processing, so the operator's decision wins. A successful attempt is still recorded: the sale or shipment already went through, and succeeded is as terminal as discarded while telling the truth. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Revisado. No lo mergearía para esta entrega. El bug existe: Pero hace falta que coincidan en el tiempo un reintento en vuelo y un descarte manual del mismo evento, y el daño es que un evento descartado se siga reintentando: no se pierde una venta, no se descuenta stock de más, no queda nada inconsistente en la base. Comparado con el resto de la tanda —500 en todos los listados, ventas que se pierden sin señal, stock que no vuelve— esto no entra en la misma categoría. Para el backlog. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket de Jira
https://proyectofinalfrlp.atlassian.net/browse/TESIS-999021
Descripción
Webhooks::RetryFailedEventcarga elFailedEvent, lo reproduce y al terminar escribe el resultado sin releerlo. Si mientras tanto un operador lo descartaba (POST /failed-events/:id/discard), un intento fallido escribía encima: el evento volvía apendingcon unnext_retry_aty el barrido lo seguía reintentando, aunque lo hubieran sacado de la cola. El spec existente («releases the claim of an event discarded while it was being processed») cubría el descarte, pero no la escritura del worker que seguía corriendo.mark_failedescribe bajowith_lock(relee la fila conFOR UPDATE) y sólo si el evento sigue enprocessing. Si lo descartaron o lo reencolaron, la decisión del operador gana y el worker no lo toca.mark_succeededtambién escribe bajo lock, pero se registra siempre: la venta o el envío ya se procesaron, ysucceededes tan terminal comodiscarded—no vuelve a la cola— y además dice la verdad.discarded, sinnext_retry_at) y durante uno que funciona (quedasucceeded).Evidencia visual
N/A
Cómo probar
El cruce se fija con el spec:
bundle exec rspec spec/poros/webhooks/retry_failed_event_spec.rb→ en verde.app/poros/webhooks/retry_failed_event.rbdemaster, falla «keeps it discarded when the attempt fails»: el evento quedapending.Verificación:
bundle exec rspec(1569 ejemplos, 0 fallas, cobertura 99.89% de línea),rubocopybrakemanlimpios.Impacto y consideraciones
¿Introduce breaking changes?
No
¿Requiere nuevas variables de entorno?
No
¿Afecta la arquitectura o genera un nuevo patrón?
No. Un lock de fila al persistir el resultado; el claim atómico del job no cambia.
🤖 Generated with Claude Code