world-postgres: let close() give running deliveries more than graphile's fixed 5 s before aborting them

Abierto
#5,152 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
postgresql, typescript

Línea de trabajo

Start by reading PostgresWorldConfig and createQueue, which builds Graphile's run() options; then check how close() calls runner.stop() and how the existing shutdown tests cover running deliveries. Done when the configured grace period reaches Graphile's shutdown timeout, defaults remain compatible, and tests verify deliveries finish within the grace period or are aborted afterward.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Summary

An application-managed shutdown (applicationManagedShutdown: true, then await world.close()) still cuts off any step that has been running for more than 5 seconds when the process is told to stop.

close() calls runner.stop(), which runs graphile-worker's workerPool.gracefulShutdown(). That aborts every running job's abortSignal after gracefulShutdownAbortTimeout, which graphile-worker 0.16.6 fixes at 5 s in its defaults (dist/config.js). world-postgres passes that signal to the loopback delivery (dist/queue.js: "Queue shutdown aborts the delivery through Graphile's signal"), so the delivery is cancelled, the job is failed for a retry, and close() goes on to close the streamer and the pool. Once the process exits, the step that was running is replayed only after the inline ownership lease (WORKFLOW_INLINE_OWNERSHIP_LEASE_SECONDS, 860 s by default) runs out.

On Kubernetes a terminating pod gets a grace period, often 30 to 120 s. Most agent steps (one model call and its tools) finish inside that, but few finish inside 5 s, so every rolling deploy stalls each in-flight step for a lease length.

Environment

  • @workflow/world-postgres 5.0.5, graphile-worker 0.16.6 (transitive)
  • An agent served with eve start (eve 0.90), Node 24, Kubernetes with a 120 s termination grace period

Ask

A way to set how long close() lets running deliveries finish before it aborts them, for example a shutdownGraceMs option on PostgresWorldConfig (and a WORKFLOW_POSTGRES_SHUTDOWN_GRACE_MS default), passed to graphile-worker as preset.worker.gracefulShutdownAbortTimeout. Today createQueue builds graphile's run() options itself (concurrency, logger, noHandleSignals, pollInterval, taskList), so an application can't pass a preset.

With that, and a server that waits for close() before exiting (vercel/eve#1981, draft vercel/eve#1983), a rolling deploy could stop claiming jobs, let in-flight steps finish inside the platform's grace period, and release only what is still running at the end.

Related

  • #4244: close() resolving while a job is still running, fixed on the 5.x line.
Lenguaje dominante
TypeScript
Estrellas
2.5k
Forks
401
Merge medio
1 d 21 h
PR fusionados (30 d)
201

Preparar el entorno

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de vercel/workflow

Todos los issues de vercel/workflow

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.