Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error reached top of thread-pool: EOFError (EOFError) #1502

Closed
vincentwoo opened this issue Jan 10, 2018 · 18 comments · Fixed by fsek/web#744, bustikiller/raffle-bee#27 or sumyapp/basecamp3_slack_notify#29

Comments

@vincentwoo
Copy link

vincentwoo commented Jan 10, 2018

Frequently for us in dev, puma hits an error in its thread pool, grinding the web server to a halt. This happens on page refreshes on our Rails app. I'm making an issue out of desperation, but I have not a lot to go on.

It appears this block catches some kind of internal error, but no backtrace is attached for us:

https://github.com/puma/puma/blob/master/lib/puma/thread_pool.rb#L121

          begin
            block.call(work, *extra)
          rescue Exception => e
            STDERR.puts "Error reached top of thread-pool: #{e.message} (#{e.class})"
          end

After a few of those in the logs, we also sometimes see:

16:51:09 web.1 | Error in reactor loop escaped: undefined method join' for nil:NilClass (NoMethodError)`

Does anyone have a hunch about where this might be coming from?

System configuration

Ruby version: 2.5.0
Rails version: 5.1.4
Puma version: 3.11.0

@vincentwoo
Copy link
Author

This is probably related to #1483, since we also run SSL in dev.

@vincentwoo
Copy link
Author

If relevant, this is our puma config:

workers Integer(ENV['WEB_CONCURRENCY'] || 1) # 1 worker 5 threads in dev
threads_count = Integer(ENV['MAX_THREADS'] || 5)
threads threads_count, threads_count

preload_app!

_port = ENV['PORT'] || 8080
_environment = ENV['RACK_ENV'] || 'development'

if _environment == 'development' && File.exists?('/etc/ssl/localhost.ssl.key')
  ssl_bind '0.0.0.0', _port, {
    key: '/etc/ssl/localhost.ssl.key',
    cert: '/etc/ssl/localhost.ssl.crt',
    verify_mode: 'none'
  }
else
  port _port
end

rackup DefaultRackup
environment _environment

on_worker_boot do
  # Worker specific setup for Rails 4.1+
  # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
  ActiveRecord::Base.establish_connection
end

plugin :tmp_restart

@vincentwoo
Copy link
Author

vincentwoo commented Jan 10, 2018

After a lot of print debugging, I believe the exception-throwing line is: https://github.com/puma/puma/blob/master/lib/puma/minissl.rb#L66

@engine.inject(data)

when data is nil. This seems to happen pretty reliably once I added a bunch of print debugging, suggesting the problem is timing-related. The exception happens after the server has hung for many seconds, suggesting that the root cause is deeper.

@vincentwoo
Copy link
Author

This is about as far as I am liable to get on my own, I fear. Help is desperately appreciated!

@vincentwoo
Copy link
Author

vincentwoo commented Jan 10, 2018

Oh, in case this is related: I'm running OSX. It's possible that the issues outlined in https://blog.phusion.nl/2017/10/13/why-ruby-app-servers-break-on-macos-high-sierra-and-what-can-be-done-about-it/ matter.

edit: the manual fix in the article didn't seem to do it

@jtzero
Copy link

jtzero commented Jan 11, 2018

another data point,
I have the same issue but on
ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-darwin16]
and Sierra (not high sierra)

lgebhardt added a commit to lgebhardt/publishers that referenced this issue Jan 22, 2018
Temporary work around for “no implicit conversion of nil into String”
See puma/puma#1483 and puma/puma#1502
@rrevi
Copy link

rrevi commented Feb 1, 2018

So I updated to 3.11.2 to fix this issue. While the issue log errors mentioned here no longer show up, I am now getting the following errors in the puma.log file with most HTTP requests (over SSL of course):

=== puma startup: 2018-02-01 08:00:55 -0500 ===
=== puma startup: 2018-02-01 08:00:55 -0500 ===
Error reached top of thread-pool: EOFError (EOFError)
Error reached top of thread-pool: EOFError (EOFError)
Error reached top of thread-pool: EOFError (EOFError)
Error reached top of thread-pool: EOFError (EOFError)
Error reached top of thread-pool: EOFError (EOFError)
Error reached top of thread-pool: EOFError (EOFError)Error reached top of thread-pool: EOFError (EOFError)
Error reached top of thread-pool: EOFError (EOFError)

anyone have any idea what could be going on? I haven't noticed any bad user experience yet (e.g. puma crash or http request hang)

Thanks,
Rafael

@chytreg
Copy link

chytreg commented Feb 1, 2018

I have exactly the same issue and cannot track down the cause either.

@rssluca
Copy link

rssluca commented Feb 1, 2018

Same issue here although non disruptive.

@MarkMurphy
Copy link

Also having the same problem

@gcoderre
Copy link

I'm seeing the same issue after updating to 3.11.2 while using SSL:

Puma: 3.11.2
Ruby: 2.4.3p205
Rails: 5.1.5
OS: macOS 10.13.1

@kylekyle
Copy link

kylekyle commented Mar 1, 2018

Also getting this with the exact same setup and versions as @gcoderre but on Rack/Roda not Rails.

@kylekyle
Copy link

kylekyle commented Mar 2, 2018

Can we reopen this? I'm seeing it on both OS X and RHEL7 ....

@dbpqdb
Copy link

dbpqdb commented Mar 4, 2018

+1

Seeing same issue as @rrevi on Puma 3.11.2, Ubuntu 16.04, Ruby 2.4.3p205, Rails 5.1.4

@tuwukee
Copy link

tuwukee commented Mar 6, 2018

hey @evanphx,
Error reached top of thread-pool: EOFError (EOFError) is fixed with your commit b9ff900

but I'm still getting EOFErrors with puma server

2018-03-06 14:24:05 +0300: Read error: #<EOFError: EOFError>

/Users/july/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/puma-3.11.3/lib/puma/client.rb:292:in `try_to_finish'
/Users/july/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/puma-3.11.3/lib/puma/client.rb:106:in `reset'
/Users/july/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/puma-3.11.3/lib/puma/server.rb:450:in `process_client'
/Users/july/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/puma-3.11.3/lib/puma/server.rb:302:in `block in run'
/Users/july/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/puma-3.11.3/lib/puma/thread_pool.rb:120:in `block in spawn_thread'

Your change adds exception handling for client.eagerly_finish method call https://github.com/puma/puma/blob/master/lib/puma/server.rb#L280

The EOFError is also can be thrown by client.reset method https://github.com/puma/puma/blob/master/lib/puma/server.rb#L450

Can you fix this one as well please?
Thanks!

@nateberkopec
Copy link
Member

Reopening until @tuwukee's comment is addressed.

@bruno-campos
Copy link

I'm also seeing the same error reported by tuwukee on 3.11.4

2018-06-01 12:55:57 +0000: Read error: #<EOFError: EOFError>
/usr/local/bundle/gems/puma-3.11.3/lib/puma/client.rb:292:in `try_to_finish'
/usr/local/bundle/gems/puma-3.11.3/lib/puma/client.rb:106:in `reset'
/usr/local/bundle/gems/puma-3.11.3/lib/puma/server.rb:450:in `process_client'
/usr/local/bundle/gems/puma-3.11.3/lib/puma/server.rb:302:in `block in run'

Ruby 2.5.0
Rails 5.2.0

@nateberkopec nateberkopec changed the title Error reached top of thread-pool: no implicit conversion of nil into String (TypeError) Error reached top of thread-pool: EOFError (EOFError) Oct 20, 2019
@andrykonchin
Copy link
Contributor

andrykonchin commented Mar 9, 2020

Looks like the issue with EOFError is already fixed.

The code version where the EOFError error was reported to happen - source code. Currently any IO error is rescued and swallowed here source code.

This change was introduce in #1728 and released in v4.0.0 (Changelog)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet