Task identifier cache keeps a rejected lookup forever, wedging the runner after a connection drop
@agustin18 ya está trabajando en esto.
Desde el 23/11/2026.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 72/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- node.js, postgresql, typescript
- Área
- backend
Línea de trabajo
Empieza en src/taskIdentifiers.ts: cache.lastStr y cache.lastDigest se establecen antes del lookup asíncrono y nunca se limpian cuando este rechaza, así que getJobs espera el mismo rechazo en cada poll. Lee esa lógica de caché junto con la llamada withPgClient.withRetries (que solo reintenta 40001/40P01/57P03/EHOSTUNREACH/ETIMEDOUT) y el logging de getJob a nivel debug en worker.js. Reproduce terminando el backend del lookup con pg_terminate_backend y añadiendo un job; done significa que el runner se recupera en el siguiente poll, idealmente con fallos repetidos registrados por encima de debug.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Version: graphile-worker 0.18.0 (the same code is on main)
What happens
If the task-identifier lookup fails once (for example the Postgres backend is terminated with pg_terminate_backend, a failover, "Connection terminated unexpectedly", or a pool checkout timeout during the first poll after start), the runner never recovers. It keeps polling every pollInterval, each poll fails with the same error logged only at debug level, and jobs added afterwards never run. The runner promise never settles, so a supervisor has nothing to restart.
Cause
src/taskIdentifiers.ts sets cache.lastStr before the async lookup and stores the lookup's promise in cache.lastDigest. Nothing clears them when that promise rejects, so every later call returns the same rejected promise. The lookup runs through withPgClient.withRetries, which retries only 40001, 40P01, 57P03, EHOSTUNREACH and ETIMEDOUT; a 57P01 (admin shutdown) or a dropped connection fails once and is then cached. getJobs awaits that cached rejection on every poll, and worker.js logs it at debug.
Reproduce
- Start a worker pool with a few task identifiers.
- Terminate the backend running the lookup's
insert into graphile_worker._private_tasks(select pg_terminate_backend(pid) ...) while it runs. - Add a job. It stays
locked_by = null, attempts = 0and due; the log shows only debug-level getJob errors (about 170 in 10 s).
Adding 0–40 ms of random delay to pool checkout makes this happen in roughly 1 in 4 starts under a terminated connection.
Suggested fix
Clear the cache when the lookup rejects, so the next poll retries it:
cache.lastDigest.catch(() => {
if (cache.lastStr === str) cache.lastStr = '';
});
We run this as a local patch and the runner recovers on the next poll. It may also be worth logging repeated getJob failures above debug level.
- Lenguaje dominante
- TypeScript
- Estrellas
- 2.5k
- Forks
- 134
- Merge medio
- 16 h 24 min
- PR fusionados (30 d)
- 3
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Sin 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 graphile/worker
-
Memory leak: `taskIdentifiers` cache keeps every `run()`'s options for the life of the processAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
Batched `completeJobs`/`failJobs` are never retried: the retry loop in `batch()` exits after the first failurePosiblemente ocupada @ujjawal-yadav la tomó hace 42 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
`runner.promise` resolves when the worker pool exits with an errorPosiblemente ocupada @Krrishkumar125 la tomó hace 35 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
Write docs for local queue!Posiblemente ocupada @Krrishkumar125 la tomó hace 34 días. Abiertodocs
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Unhandled rejection when recording a job's outcome fails with unbatched completeJob/failJobPosiblemente ocupada @cpruijsen la tomó hace 44 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 62/100
Todos los issues de graphile/worker
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
abhigyanpatwari/GitNexus#4124 ·
Los mantenedores suelen responder en 1 día
-
good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
laaielichter/Godotwright#250 ·
Los mantenedores suelen responder en 1 día
-
An Antigravity tab can quote an old Assist message as the owner's words in a resumed conversationAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Retry an empty final answer when Gemini reports MALFORMED_RESPONSE (gemini-4-hydrogen)Posiblemente ocupada @waleedkadous la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
iaser-ai/ansari#444 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Bug]: Manager UI logo fails to load — broken external URLPosiblemente ocupada @kavindu-udara la tomó hoy. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100