Race condition when closing LDS
还没有人认领这个 Issue。
- #756 来自 @ab-pm —— 已关闭,未合并
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 32/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- typescript
- 领域
- backend, testing-qa
调研方向
从 packages/lds/src/index.ts 中 getChanges 调用附近的循环开始,检查调用 schema.__pgLdsSource?.close() 的集成测试 teardown。在负载下或使用最小的 sleepDuration 运行集成测试套件。完成的标准是关闭 source 能可靠地停止后续 polling,并且套件退出时不会反复出现“Pool has been closed”错误。
由索引模型根据 Issue 内容生成。
描述
Summary
In our integration test suite, we do teardown the LDS Live Source by calling schema.__pgLdsSource?.close(). This does however not work consistently, and from time to time (apparently when the server - that also runs the db in a docker container - is under higher load) it fails to stop the LDS loop and the test job (github action) is only stopped by timing out, failing the build step.
In the meantime, it does keep logging
Error during LDS loop: Pool has been closed
I believe I tracked this down to a bug in https://github.com/graphile/graphile-engine/blob/6692c2a65f406c55c3d1edfff51c8f7cc2296956/packages/lds/src/index.ts#L96-L101
async function loop() {
try {
const rows = await client.getChanges(null, 500);
…
} catch (e) {
console.error("Error during LDS loop:", e.message);
// Recovery time...
loopTimeout = setTimeout(loop, sleepDuration * 10);
return;
}
loopTimeout = setTimeout(loop, sleepDuration);
}
loop();
While the client.getChanges query is awaited, no timeout is scheduled and the clearTimeout will be ineffective, so the loop will start over even after .close() has been called.
Steps to reproduce
By setting the sleepDuration to a minimum value, the loop spends much more time in the query so a close() will hit the sleep much less likely.
Possible Solution
I can see a few approaches:
- just set a
closedflag and check this before callingsetTimeoutagain .unref()each timer? I think this might have worked in my case, but probably not a generic solution- check whether the
client.poolis closed before callinggetChanges(), and breaking out of the loop - check whether the
client.poolis closed in thecatchhandler of the loop, breaking out from there - a specific "client closed" exception that is handled differently in the
catchof the loop, breaking out from there
- 主要语言
- JavaScript
- 星标
- 764
- 派生
- 128
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
graphile/graphile-engine 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 35/100
graphile/graphile-engine#869 · 1 条评论 · 1 个 reaction ·
-
Provide a type guard to distinguish between ResolveTree and FieldsByTypeName可能重新可做 关联的 PR 已关闭且未合并。 未关闭enhancement
难度 2/5 1-3 小时 新手友好度 45/100
graphile/graphile-engine#849 · 2 条评论 · 1 个 reaction ·
-
🐛 bug help wanted
难度 3/5 1-2 天 新手友好度 35/100
graphile/graphile-engine#818 ·
-
难度 5/5 一周以上 新手友好度 15/100
graphile/graphile-engine#725 · 17 条评论 · 5 个 reaction ·
-
bug
难度 3/5 1-2 天 新手友好度 35/100
graphile/graphile-engine#723 ·
查看 graphile/graphile-engine 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
directus/directus#28558 · 1 条评论 ·
维护者通常 2 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
cloudflare/workers-sdk#17189 ·
维护者通常 1 天内回复
-
AWS Lambda Waiting for: Product Owner
难度 1/5 1 小时以内 新手友好度 82/100
getsentry/sentry-javascript#26910 · 1 条评论 ·
维护者通常 1 天内回复
-
[🐛 Bug]: @wdio/reporter drops the function name of a string script in command output可能已有人在做 @dhananjay6561 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 80/100
webdriverio/webdriverio#16507 · 1 条评论 ·
维护者通常 1 天内回复