Skip to content

Puma::Cluster#run': undefined method 'wait_readable' for nil #3620

@vladimirtcats

Description

@vladimirtcats

Describe the bug

Puma::Cluster#run': undefined method 'wait_readable' for nil
/usr/local/bundle/gems/puma-6.6.0/lib/puma/cluster.rb:459:in 'Puma::Cluster#run': undefined method 'wait_readable' for nil (NoMethodError)

            if read.wait_readable([0, @next_check - Time.now].max)
                   ^^^^^^^^^^^^^^
	from /usr/local/bundle/gems/puma-6.6.0/lib/puma/launcher.rb:203:in 'Puma::Launcher#run'
	from /usr/local/bundle/gems/puma-6.6.0/lib/puma/cli.rb:75:in 'Puma::CLI#run'
	from /usr/local/bundle/gems/puma-6.6.0/bin/puma:10:in '<top (required)>'
	from /usr/local/bundle/bin/puma:25:in 'Kernel#load'
	from /usr/local/bundle/bin/puma:25:in '<top (required)>'
	from /usr/local/bundle/gems/bundler-2.5.23/lib/bundler/cli/exec.rb:58:in 'Kernel.load'
	from /usr/local/bundle/gems/bundler-2.5.23/lib/bundler/cli/exec.rb:58:in 'Bundler::CLI::Exec#kernel_load'
	from /usr/local/bundle/gems/bundler-2.5.23/lib/bundler/cli/exec.rb:23:in 'Bundler::CLI::Exec#run'
	from /usr/local/bundle/gems/bundler-2.5.23/lib/bundler/cli.rb:456:in 'Bundler::CLI#exec'
	from /usr/local/bundle/gems/bundler-2.5.23/lib/bundler/vendor/thor/lib/thor/command.rb:28:in 'Bundler::Thor::Command#run'
	from /usr/local/bundle/gems/bundler-2.5.23/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in 'Bundler::Thor::Invocation#invoke_command'
	from /usr/local/bundle/gems/bundler-2.5.23/lib/bundler/vendor/thor/lib/thor.rb:527:in 'Bundler::Thor.dispatch'
	from /usr/local/bundle/gems/bundler-2.5.23/lib/bundler/cli.rb:35:in 'Bundler::CLI.dispatch'
	from /usr/local/bundle/gems/bundler-2.5.23/lib/bundler/vendor/thor/lib/thor/base.rb:584:in 'Bundler::Thor::Base::ClassMethods#start'
	from /usr/local/bundle/gems/bundler-2.5.23/lib/bundler/cli.rb:29:in 'Bundler::CLI.start'
	from /usr/local/bundle/gems/bundler-2.5.23/exe/bundle:28:in 'block in <top (required)>'
	from /usr/local/bundle/gems/bundler-2.5.23/lib/bundler/friendly_errors.rb:117:in 'Bundler.with_friendly_errors'
	from /usr/local/bundle/gems/bundler-2.5.23/exe/bundle:20:in '<top (required)>'
	from /usr/local/bundle/bin/bundle:25:in 'Kernel#load'
	from /usr/local/bundle/bin/bundle:25:in '<main>'

Puma config:

# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count

# Specifies the `worker_timeout` threshold that Puma will use to wait before
# terminating a worker in development environments.
#
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"

# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch("PORT") { 3000 }

# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" }

# Specifies the `pidfile` that Puma will use.
# pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }

# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked web server processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
workers ENV.fetch("WEB_CONCURRENCY") { 1 }

# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory.
#
# preload_app!

# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart

Dockerfile:

FROM ruby:3.4.1-slim

ENV RAILS_ENV production

RUN mkdir -p /app \
  && apt-get update -qq \
  && apt-get install -yq apt-utils build-essential libpq-dev postgresql-client tzdata screen git curl shared-mime-info libjemalloc2\
  && apt-get clean \
  && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
  && truncate -s 0 /var/log/*log

ENV LD_PRELOAD="libjemalloc.so.2"
WORKDIR /app

COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
RUN gem install bundler:2.6.2

COPY . .

EXPOSE 3000
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]

Gemfile

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.4.1'


gem 'rails', '~> 8'

gem 'pg', '~> 1.5', '>= 1.5.9'

gem 'puma', '~> 6.6'
gem 'jbuilder', '~> 2.13'

gem 'oj', '~> 3.16'
gem 'active_interaction', '~> 5.5'

# disable warnings
gem 'mutex_m'
gem 'bigdecimal'
gem 'drb'
gem 'base64'
gem 'observer'
gem 'benchmark'
gem 'reline'

# Kafka
gem 'ruby-kafka', '~> 1.5'
gem 'avro', '~> 1.9'
gem 'avro_turf'
gem 'extlz4', '~> 0.3.2', require: false
gem 'karafka', '~> 2.2.7'

# Monitoring
gem 'elastic-apm', '~> 4.7'
gem 'lograge'

gem 'vernier', '~> 1.5'
gem 'stackprof', '0.2.27'
gem 'sentry-ruby', '~> 5.22'
gem 'sentry-rails', '~> 5.22'

gem 'concurrent-ruby'

gem 'faraday', '~> 2.12.2'

# Storages
gem 'redis', '~> 5.3'

group :development, :test do
  gem 'bundler-audit', '~> 0.9.2'
  gem 'brakeman', '~> 7', require: false
  gem 'pry-byebug'
end

group :test do
  gem 'rspec-rails', '~> 7.1'  
  gem 'database_cleaner-active_record', '~> 2.2'
  gem 'webmock', '~> 3.24'
  gem 'bullet', '~> 8'
end

Desktop (please complete the following information):

  • OS: [ Linux]
  • Puma Version 6.6

As I understand the reason in IO.pipe

IO.pipe
read, @wakeup = Puma::Util.pipe

I get correct result in console:

read, @wakeup = Puma::Util.pipe
=> [#<IO:fd 6>, #<IO:fd 7>]

I could not reproduce situation whem read is nil

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions