OutboxProcessorListener events are emitted before the transaction commits; metrics over-count on commit failure

Aperta
#137 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@rawo ci sta già lavorando.

Dal 6/11/2026.

  • #147 di @rawo — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
kafka, kotlin, mysql, postgresql, spring-boot
Ambito
backend

Direzione di ricerca

Start in OutboxProcessor.processNext, where listener.onEntryProcessed runs right after store.updateAfterProcessingBatch and before the transaction commits. Then read OutboxScheduler and the TransactionRunner used around runInTransaction to see where an after-commit notification could go. Done means listener callbacks fire only after a successful commit, or the pre-commit behaviour is documented; the design choice needs maintainer input first.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

breaking-change bug

Severity: Low · Area: okapi-core OutboxProcessor listener notifications · Found in: code review of main @ e5630a1

Problem

OutboxProcessor.processNext calls listener.onEntryProcessed(...) (Delivered / RetryScheduled / Failed) right after store.updateAfterProcessingBatch, while still inside the scheduler's transaction, before it commits. If the commit then fails (connection loss, serialization failure, server-side timeout), the DB rolls back to PENDING, but okapi.entries.delivered and okapi.entries.failed have already been incremented. The rows are delivered again next tick and counted again.

Metrics therefore over-report successful deliveries in exactly the failure scenarios where operators rely on them. A custom listener that does something non-idempotent (e.g. notifying another system) would act on a state that was never persisted.

Suggested fix

Defer listener callbacks until after the transaction commits: for example, return the processed entries from the transactional block and notify in OutboxScheduler after runInTransaction returns, or register an after-commit hook through TransactionRunner. At minimum, document that events are pre-commit.

Lingua principale
Kotlin
Stelle
14
Fork
0
Merge medio
9h 54m
PR unite (30g)
11

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di softwaremill/okapi

Tutte le issue di softwaremill/okapi

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.