Notifier spins without backoff when the Start context ends by deadline
Los mantenedores suelen responder en 1 día
Ya se ha fusionado un pull request relacionado.
- #1495 de @brandur — fusionado
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 62/100
Línea de trabajo
Empieza en internal/notifier/notifier.go, en el bucle de reconexión que llama a n.listenAndWait(ctx) y comprueba errors.Is(err, context.Canceled). La corrección consiste en detener el bucle cuando ctx.Err() no sea nil, y en revisar las otras salidas con context.Canceled del mismo archivo. Está terminado cuando un context que alcanza su deadline hace que Start termine sin registros repetidos de Error running listener, demostrado con una prueba que usa un context.WithTimeout corto.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
If the context passed to Client.Start ends by deadline rather than cancellation, the notifier's reconnect loop spins with no backoff and logs Error running listener (will attempt reconnect after backoff) hundreds of thousands of times per second, forever.
Where
internal/notifier/notifier.go (v0.47.0, and unchanged on master at 2f6b27e):
for attempt := 0; ; attempt++ {
if err := n.listenAndWait(ctx); err != nil {
if errors.Is(err, context.Canceled) {
break
}
sleepDuration := serviceutil.ExponentialBackoff(attempt, serviceutil.MaxAttemptsBeforeResetDefault)
n.Logger.ErrorContext(ctx, n.Name+": Error running listener (will attempt reconnect after backoff)", ...)
...
serviceutil.CancellableSleep(ctx, sleepDuration)
}
}
Once ctx is done with context.DeadlineExceeded, listenAndWait fails immediately, the context.Canceled check doesn't match, and CancellableSleep returns immediately because ctx is already done. The loop never exits and never sleeps.
Reproduction
- Create a client against a healthy Postgres.
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second), thenclient.Start(ctx).- Wait past the deadline.
We measured 379,487 Error running listener lines in the 2 seconds after the deadline, and 0 when the same context is cancelled instead. Left running, it wrote a ~476 GB log in about 6 hours before we found it.
Suggested fix
Exit the loop when the context is done for any reason, e.g. if ctx.Err() != nil { break } (or check context.DeadlineExceeded too). The other errors.Is(err, context.Canceled) exits in the notifier may deserve the same treatment.
Workaround
Start River on a context that can only end by cancellation, e.g. runCtx, cancel := context.WithCancel(context.WithoutCancel(ctx)); context.AfterFunc(ctx, cancel).
- Lenguaje dominante
- Go
- Estrellas
- 5.8k
- Forks
- 188
- Merge medio
- 22 h 44 min
- PR fusionados (30 d)
- 95
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
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 riverqueue/river
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
riverqueue/river#1454 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
riverqueue/river#1411 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Remote JobCancel() can be silently lost while the notifier is reconnecting (no durable-poll fallback)Posiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 45/100
riverqueue/river#1358 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
River job stuck at runningAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
riverqueue/river#1258 · 7 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
riverqueue/river#1225 · 14 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de riverqueue/river
Issues similares
-
darwin zsh
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
carapace-sh/carapace-bin#3846 ·
Los mantenedores suelen responder en 1 día
-
appplication - is a typo?Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 70/100
golang-app/ecommerce#179 ·
Los mantenedores suelen responder en 1 día
-
Simulator process crashes (nil pointer panic) when the dataset returns an errorPosiblemente ocupada @EugeneVon la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
llm-d/llm-d-inference-sim#772 ·
Los mantenedores suelen responder en 1 día
-
refactor: decode numchildren with a lenient int type instead of a hand-written xProp.UnmarshalXMLAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
crazy-goat/xdbg#125 ·
Los mantenedores suelen responder en 1 día
-
150 points ci complexity:medium drips-wave help wanted medium
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
sorotrail/SoroBeacon#449 ·
Los mantenedores suelen responder en 1 día