PeriodicJobEnqueuer logs ERROR "Error starting transaction: context canceled" when the client stops during the leader's staggered start
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 66/100
Direzione di ricerca
L'ERROR proviene da insertBatch in internal/maintenance/periodic_job_enqueuer.go, che chiama s.exec.Begin(ctx) dopo che StaggerStart restituisce un contesto annullato. Inizia leggendo l'attesa dello stagger e il percorso di inserimento dei job di avvio, poi verifica come Client.Stop annulla i servizi di manutenzione. È completato quando uno stop durante lo stagger del leader non registra alcun ERROR, mentre un vero errore del database continua a registrarlo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
### What happens
When a client that has just become the leader is stopped (SIGTERM → Client.Stop or the cancellation of the context passed to Client.Start) within the first ~0.1–2.5 s, the log gets an ERROR line even though the stop is a normal, requested shutdown:
{"level":"ERROR","msg":"maintenance.PeriodicJobEnqueuer: Error starting transaction","error":"context canceled"}
Outside that window the shutdown log is clean.
Why (as far as we can tell from the source)
The maintenance services start with StaggerStart, a cancellable sleep of a random 0–1 s per service, in sequence.
Client.Stop (and the cancellation of the start context) cancels the context of the maintenance services at once.
PeriodicJobEnqueuer wakes up from the stagger with the cancelled context and still goes on to insert the start jobs (RunOnStart periodic jobs): insertBatch calls s.exec.Begin(ctx), which fails with context.Canceled, and the error is logged at ERROR (internal/maintenance/periodic_job_enqueuer.go, insertBatch, "Error starting transaction").
Seen on v0.49.0; the same code is in v0.51.0.
Reproduction
A client with at least one PeriodicJob with RunOnStart: true, alone in the database so it becomes the leader at once.
Start it and stop it about 100 ms after it reports it is the leader (e.g. a process that gets SIGTERM right after its readiness probe).
Repeat a few times: most runs log the ERROR line above.
Expected
A requested stop does not log an error. For example, the enqueuer could return without inserting when ctx.Err() != nil after the stagger (or before Begin), or log a context cancellation during stop at a lower level, as other maintenance services do on shutdown.
Workaround we use
Our runner starts the client on a context that is not cancelled by the process shutdown and, before calling Stop, waits (bounded, a few seconds) until the leader's start jobs are in river_job or another client leads. It works, but it couples the shutdown to a database poll and delays a SIGTERM that arrives right after start.
Environment: River v0.49.0, riverpgxv5, PostgreSQL 18, Go 1.27.
Claude find it, he's always finding
- Lingua principale
- Go
- Stelle
- 5.9k
- Fork
- 197
- Merge medio
- 1g 4h
- PR unite (30g)
- 120
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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di riverqueue/river
-
River job stuck at runningAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
riverqueue/river#1258 · 7 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
riverqueue/river#1225 · 14 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
riverqueue/river#1185 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
riverqueue/river#1183 · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
riverqueue/river#1167 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di riverqueue/river
Issue simili
-
area:sampler tech-debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
jmbarzee/temporal-architect#302 ·
I maintainer di solito rispondono entro 1 giorno
-
NFS StorageProvider renders a missing nfsSubDir as "<no value>"Forse già presa @ldming l’ha presa oggi. Apertakind/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
apecloud/kubeblocks#11067 ·
I maintainer di solito rispondono entro 1 giorno
-
area:ui bug priority:low
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
RTX payload type is not found when the RTX fmtp line has rtx-timeForse già presa @RaphaelFakhri l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
emersion/go-msgauth#87 ·