FPM delayed process restarting
还没有人认领这个 Issue。
- 主要语言
- C
- 星标
- 40.4k
- 派生
- 8.2k
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 96
描述
Description
There is an issue in FPM happening when a child crashes shortly after the start. That might cause a loop of child restarts which might result in unresponsive master process because it is overloaded with handling restarts - signal events. One such case was described in bug #61558. Although that particular issue got fixed, this should be addressed as it might still happen due to the crash in extension or similar problem.
The solution could be to introduce an increased delay between process restarts. The idea is that we would measure how many restarts were done in the last second or some sensible time. If it goes over lets say 2 x pm.max_children, then we would set delay before starting a new child. If that happens in such short interval + current delay again, we increase the delay. If there are no restarts, then we would decrease the delay so we can recover in case it was just a temporary problem however unlikely this is.
Unfortunately it brings various challenges:
- The scoreboard would need to be extended with some extra data (probably just one field counting number of children created from the beginning) and some sort of scoreboard history would need to be introduced to compare data between specific intervals. It could be done using some sort of scoreboard snapshots during server maintenance or managed using its own periodic events. It should be easily selectable so some optimal structure might need to be introduced.
- The current delay might need to be also stored in scoreboard as it's a shared value. With the above check, it means it will increase amount of reads and writes to scoreboard and we might need to do some smarter locking before that.
- Starting of the child would need to move to a separate event so the delay can be performed. It might be a good thing in general but it's not clear if it could potentially introduce some regression if used for all starts so we might need some abstraction so we can still trigger immediate starts directly without going through even loop. It might need some experimenting as well.
- Consideration of ondemand pm where we can have natural starts when scaling up. Surely we don't want to delay those.
- Configuration for the specific params so users can tweak it if it's too strict or lax for their workload. We should have good enough defaults but we cannot obviously make it optimal for all workloads.
- Finding the right defaults which will require some comprehensive testing with different sort of configurations.
- Possibly prevent infinite
waitloop - it should be enough to limit it to the sum of max children in all pools. Or might be worth to give another try to https://github.com/php/php-src/pull/9027 which catches primarily a pid of the terminated child. Although this might need some extra checking on Mac as it was failing there and it's not clear as there is much benefit in it.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先追踪 issue 中描述的 FPM 子进程启动、崩溃重启处理、scoreboard 访问以及事件循环。在决定延迟重启应如何与自然扩缩容交互之前,查看 ondemand 进程管理器路径和 pull request #9027。完成的标准是防止重启风暴,同时不阻塞正常启动,为所描述的所有配置提供合适的默认值和覆盖。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100