Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does Early termination of worker puma log mean and why is it happening?

For my Elastic Beanstalk instance, I am getting a 504 status code response whenever I visit it. When I tail the logs I see the following log on the puma app server:

==> /var/log/puma/puma.log <==
[27240] Early termination of worker
[27245] Early termination of worker
[27249] Early termination of worker
[27253] Early termination of worker
[27257] Early termination of worker
[27261] Early termination of worker
[27265] Early termination of worker
[27269] Early termination of worker
[27273] Early termination of worker
[27277] Early termination of worker

What does Early termination of worker mean and why is it happening? Moreover, could the log be indicating the cause of my timeout error I am facing in my remote environment? The rails app and puma run perfectly on my local machine (Mac OS Catalina 10.15). However, in my remote Elastic beanstalk environment as stated above I am getting a timeout 504 error and the only thing I see in the logs is the above puma log.

This is my gemfile:

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

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.1'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.4.4'
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 4.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use haml view syntax
gem 'haml-rails'

# the main komponent gem is broken for Rails 6, see:
# https://github.com/komposable/komponent/issues/133
gem 'komponent', github: '0x2C6/komponent'
gem 'elasticsearch', '~> 6.2'
gem 'redis'

# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'pry-rails'
  gem 'rspec-rails', '~> 3.9'
  gem 'dotenv-rails'
  gem 'awesome_print'
end

group :beta, :production do
  gem 'puma_worker_killer'
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  gem 'spring-commands-rspec'
   # Avoid polling for changes (Windows)
  gem 'wdm', '>= 0.1.0', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
end

group :test do
  gem 'webmock'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
like image 995
robskrob Avatar asked Apr 19 '20 17:04

robskrob


2 Answers

The problem for my case was a difference in the patch version of the puma that was used.

Gist of it was AWS Elastic Beanstalk was using puma 4.3.3 while I was using puma 4.3.5.

Had to fix the version of puma used in my Gemfile to exactly 4.3.3 to match the stack used by AWS Elastic Beanstalk as of today prevent this error.

More details in this answer of mine here for a similar question.

like image 130
Vic Avatar answered Oct 15 '22 08:10

Vic


Ok so this took a lot of debugging and going down a lot of different rabbit holes. The problem was very painfully simple. I created a class which I misspelled and called, GetLitsingsResponse. After changing the class back to GetListingsResponse Puma works just fine in my remote AWS Elastic beanstalk environment. It's very strange out locally on my Mac OS Puma had no problem. But in the 64bit Amazon Linux 2018.03 v2.11.4 running Ruby 2.6 (Puma) platform Puma would not function normally.

like image 26
robskrob Avatar answered Oct 15 '22 06:10

robskrob