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

未关闭
#5,152 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
postgresql, typescript

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.
主要语言
TypeScript
星标
2.5k
派生
401
平均合并
1 天 21 小时
30 天内合并 PR
201

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

vercel/workflow 的其他 Issue

查看 vercel/workflow 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。