From dbc751f6e956131b5b02acefe4b6c5e6114c740b Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Fri, 28 Apr 2023 23:15:20 -0700 Subject: [PATCH] Make it possible to run Puma v6 Puma v6.0 dropped `nakayoshi_fork` in https://github.com/puma/puma/issues/2925 since "it has very minimal gain and can trigger nasty bugs in c-extensions due to usage of GC.compact." If the call to `nakayoshi_fork` is made with Puma 6, the Web server will crash and fail to start up. To avoid this, conditionally enable it only if Puma v5 is loaded. Changelog: fixed --- config/puma.example.development.rb | 6 +++++- config/puma.rb.example | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/config/puma.example.development.rb b/config/puma.example.development.rb index 71a4e9b36f1e21..1b75238112f0cf 100644 --- a/config/puma.example.development.rb +++ b/config/puma.example.development.rb @@ -88,8 +88,12 @@ # https://github.com/puma/puma/blob/master/5.0-Upgrade.md#lower-latency-better-throughput wait_for_less_busy_worker ENV.fetch('PUMA_WAIT_FOR_LESS_BUSY_WORKER', 0.001).to_f +# nakayoshi_fork was removed in Puma 6.0: https://github.com/puma/puma/issues/2258 # https://github.com/puma/puma/blob/master/5.0-Upgrade.md#nakayoshi_fork -nakayoshi_fork unless ENV['DISABLE_PUMA_NAKAYOSHI_FORK'] == 'true' +if Gem::Version.new(Puma::Const::PUMA_VERSION).canonical_segments.first == 5 && + ENV['DISABLE_PUMA_NAKAYOSHI_FORK'] != 'true' + nakayoshi_fork +end # Use json formatter require_relative "/home/git/gitlab/lib/gitlab/puma_logging/json_formatter" diff --git a/config/puma.rb.example b/config/puma.rb.example index 59844b4aecffe1..d474fc70500085 100644 --- a/config/puma.rb.example +++ b/config/puma.rb.example @@ -77,8 +77,12 @@ worker_timeout 60 # https://github.com/puma/puma/blob/master/5.0-Upgrade.md#lower-latency-better-throughput wait_for_less_busy_worker ENV.fetch('PUMA_WAIT_FOR_LESS_BUSY_WORKER', 0.001).to_f +# nakayoshi_fork was removed in Puma 6.0: https://github.com/puma/puma/issues/2258 # https://github.com/puma/puma/blob/master/5.0-Upgrade.md#nakayoshi_fork -nakayoshi_fork unless ENV['DISABLE_PUMA_NAKAYOSHI_FORK'] == 'true' +if Gem::Version.new(Puma::Const::PUMA_VERSION).canonical_segments.first == 5 && + ENV['DISABLE_PUMA_NAKAYOSHI_FORK'] != 'true' + nakayoshi_fork +end # Use json formatter require_relative "/home/git/gitlab/lib/gitlab/puma_logging/json_formatter" -- GitLab