set_timeout() fails to terminate execution when IO Latency is high
まだ誰も着手していません。
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.2k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
I'm not sure if this is a bug or not and I haven't found the proper channel to ask (shall I raise a discussion in Internals?).
We faced a problem in our production cluster. Our setup is following:
SAPI: fpm
max_execution_time: 28
hard_timeout: 2
When Opcache is reloading, we're having excessive IO pressure, which is expected - PHP starts reading everything from disk, etc... However, scripts started executing for 5+ minutes - that wasn't expected.
Further investigation showed that zend_set_timeout_ex uses setitimer(ITIMER_PROF) by default, which means the time the process spends in IOWait doesn't seem to count.
So, basically, even though our gateway cannot wait for such long - it expects that application will finish earlier, PHP still performs the request. One more backside of such behaviour - the restart of Opcache takes longer - it waits until all the workers finish execution (or become killed by opcache when opcache.force_restart_timeout is reached).
This problem doesn't seem to appear when we use ITIMER_REAL. I can provide how we tested this.
I can see a couple of solutions here:
- Switch to
ITIMER_REAL(it looks like there are some concerns about the Apache module) - Choose one over another for some SAPIs when we are sure that there shouldn't be a conflict (e.g. FPM, CLI)
- Make this behaviour configurable (either at runtime or compile time)
- Something else?
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
zend_set_timeout_ex から開始し、FPM および I/O レイテンシが高い状況での ITIMER_PROF と ITIMER_REAL の報告された挙動を比較します。Apache モジュールに関する懸念と提案された代替案を確認します。数分間にわたってリクエストが実行され続けることを防ぐタイマーの挙動または設定方法が決定されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, php
- 領域
- operating-systems
- issue の種類
- バグ
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100