Phased restart stops Puma when the plugin is on and workers take a moment to boot
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
まず、plugin の stop_litestream メソッドと、"Detected Litestream has gone away" をログに記録する monitor のチェックを読みます。issue には、それらのファイルやテストは記載されていません。before_restart と after_booted の間に @litestream_pid がどのように変化するかを追い、2 つの worker と遅延する config.ru を使って再現します。1 秒および 4 秒の worker 起動でも段階的な再起動が完了し、Litestream が強制終了されたときに Puma が停止すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
With plugin :litestream in cluster mode, a phased restart (pumactl phased-restart / USR1) stops Puma if the workers take a second or more to boot, which a Rails app always does.
before_restart stops Litestream at the start of the phased restart, but after_booted, which starts it again, fires only once every worker has rebooted (Cluster#run, in_phased_restart && workers_not_booted.zero?). Until then the monitor, which checks every 2 seconds, finds the old pid gone, logs "Detected Litestream has gone away, stopping Puma..." and sends INT to Puma.
- Worker 1 (PID: 3706119) booted in 1.0s, phase: 0
Stopping Litestream...
- Starting phased worker restart, phase: 1
- Worker 0 (PID: 3706319) booted in 1.0s, phase: 1
- Stopping 3706119 for phased upgrade...
Detected Litestream has gone away, stopping Puma...
- Goodbye!
To reproduce on 0.16.1 with 2 workers, preload_app! false and a config.ru that sleeps before run:
| Worker boot time | Puma 8.0.2 | Puma 6.6.1 |
|---|---|---|
| 0 s | survives, Litestream restarts | survives |
| 1 s | stops | stops |
| 4 s | stops | stops |
Hot restarts aren't affected: exec replaces the process before the monitor runs again. Single mode has no phased restart.
A small fix that works on both Puma versions: have stop_litestream clear @litestream_pid before stopping it, so the monitor skips its check until after_booted starts the next one. With that, Puma survives a phased restart at 1 s and 4 s boot times, and still stops when Litestream is killed. Happy to send it as a PR.
- 主要言語
- Ruby
- スター
- 280
- フォーク
- 32
- 平均マージ
- 9時間 13分
- マージ済み PR(30日)
- 7
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
fractaledmind/litestream-ruby のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
fractaledmind/litestream-ruby#84 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
fractaledmind/litestream-ruby の issue をすべて見る
似ている issue
-
account: profile
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 5 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
bug good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
ysb3996-blip/oops#24 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信