Errno :: EMFILE:升级到ruby 2.3时打开的文件太多

时间:2016-01-28 10:31:20

标签: ruby upgrade ruby-2.3

我只是升级到ruby 2.3以利用frozen_string_literal选项,但它在生产中产生错误Errno::EMFILE: Too many open files

当我降级到ruby 2.2.3时,不再有错误。

这是我遇到的ruby 2.3错误calltrace之一:

Errno::EMFILE: Too many open files - socket(2) for "XX.XXX.XX.XXX" port 9200 (XX.XXX.XX.XXX:9200)
/.../production/shared/bundle/ruby/2.3.0/gems/httpclient-2.7.1/lib/httpclient/session.rb:597:in `initialize'
/.../production/shared/bundle/ruby/2.3.0/gems/httpclient-2.7.1/lib/httpclient/session.rb:597:in `new'
/.../production/shared/bundle/ruby/2.3.0/gems/httpclient-2.7.1/lib/httpclient/session.rb:597:in `create_socket'
/.../production/shared/bundle/ruby/2.3.0/gems/httpclient-2.7.1/lib/httpclient/session.rb:742:in `block in connect'
/.../.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/timeout.rb:91:in `block in timeout'
/.../.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/timeout.rb:101:in `timeout'
/.../production/shared/bundle/ruby/2.3.0/gems/httpclient-2.7.1/lib/httpclient/session.rb:735:in `connect'
/.../production/shared/bundle/ruby/2.3.0/gems/httpclient-2.7.1/lib/httpclient/session.rb:497:in `query'
/.../production/shared/bundle/ruby/2.3.0/gems/httpclient-2.7.1/lib/httpclient/session.rb:170:in `query'
/.../production/shared/bundle/ruby/2.3.0/gems/httpclient-2.7.1/lib/httpclient.rb:1238:in `do_get_block'
/.../production/shared/bundle/ruby/2.3.0/gems/httpclient-2.7.1/lib/httpclient.rb:1021:in `block in do_request'
/.../production/shared/bundle/ruby/2.3.0/gems/httpclient-2.7.1/lib/httpclient.rb:1129:in `protect_keep_alive_disconnected'
/.../production/shared/bundle/ruby/2.3.0/gems/httpclient-2.7.1/lib/httpclient.rb:1016:in `do_request'
/.../production/shared/bundle/ruby/2.3.0/gems/httpclient-2.7.1/lib/httpclient.rb:858:in `request'
/.../production/shared/bundle/ruby/2.3.0/gems/faraday-0.9.2/lib/faraday/adapter/httpclient.rb:36:in `call'
/.../production/shared/bundle/ruby/2.3.0/gems/faraday-0.9.2/lib/faraday/rack_builder.rb:139:in `build_response'
/.../production/shared/bundle/ruby/2.3.0/gems/faraday-0.9.2/lib/faraday/connection.rb:377:in `run_request'
/.../production/shared/bundle/ruby/2.3.0/bundler/gems/elasticsearch-ruby-a5ed3f6aa679/elasticsearch-transport/lib/elasticsearch/transport/transport/http/faraday.rb:21:in `block in perform_request'
/.../production/shared/bundle/ruby/2.3.0/bundler/gems/elasticsearch-ruby-a5ed3f6aa679/elasticsearch-transport/lib/elasticsearch/transport/transport/base.rb:201:in `perform_request'
/.../production/shared/bundle/ruby/2.3.0/bundler/gems/elasticsearch-ruby-a5ed3f6aa679/elasticsearch-transport/lib/elasticsearch/transport/transport/http/faraday.rb:20:in `perform_request'
/.../production/shared/bundle/ruby/2.3.0/bundler/gems/elasticsearch-ruby-a5ed3f6aa679/elasticsearch-transport/lib/elasticsearch/transport/client.rb:125:in `perform_request'
/.../production/shared/bundle/ruby/2.3.0/bundler/gems/elasticsearch-ruby-a5ed3f6aa679/elasticsearch-api/lib/elasticsearch/api/actions/index.rb:99:in `index'
/.../production/shared/bundle/ruby/2.3.0/bundler/gems/elasticsearch-rails-489ab24998a8/elasticsearch-model/lib/elasticsearch/model/indexing.rb:336:in `index_document'
/.../production/releases/20160128001123/app/models/concerns/elastic_search/searchable.rb:12:in `block (3 levels) in '
/.../production/releases/20160128001123/app/jobs/elasticsearch_job.rb:9:in `perform'
/.../production/shared/bundle/ruby/2.3.0/gems/activejob-4.2.5.1/lib/active_job/execution.rb:32:in `block in perform_now'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:117:in `call'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:505:in `call'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:498:in `block (2 levels) in around'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:343:in `block (2 levels) in simple'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:441:in `instance_exec'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:441:in `block in make_lambda'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:342:in `block in simple'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:497:in `block in around'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:505:in `call'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:498:in `block (2 levels) in around'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:343:in `block (2 levels) in simple'
/.../production/shared/bundle/ruby/2.3.0/gems/i18n-0.7.0/lib/i18n.rb:257:in `with_locale'
/.../production/shared/bundle/ruby/2.3.0/gems/activejob-4.2.5.1/lib/active_job/translation.rb:7:in `block (2 levels) in '
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:441:in `instance_exec'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:441:in `block in make_lambda'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:342:in `block in simple'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:497:in `block in around'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:505:in `call'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:498:in `block (2 levels) in around'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:343:in `block (2 levels) in simple'
/.../production/shared/bundle/ruby/2.3.0/gems/activejob-4.2.5.1/lib/active_job/logging.rb:23:in `block (4 levels) in '
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/notifications.rb:164:in `block in instrument'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/notifications.rb:164:in `instrument'
/.../production/shared/bundle/ruby/2.3.0/gems/activejob-4.2.5.1/lib/active_job/logging.rb:22:in `block (3 levels) in '
/.../production/shared/bundle/ruby/2.3.0/gems/activejob-4.2.5.1/lib/active_job/logging.rb:43:in `block in tag_logger'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/tagged_logging.rb:68:in `block in tagged'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/tagged_logging.rb:26:in `tagged'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/tagged_logging.rb:68:in `tagged'
/.../production/shared/bundle/ruby/2.3.0/gems/activejob-4.2.5.1/lib/active_job/logging.rb:43:in `tag_logger'
/.../production/shared/bundle/ruby/2.3.0/gems/activejob-4.2.5.1/lib/active_job/logging.rb:19:in `block (2 levels) in '
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:441:in `instance_exec'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:441:in `block in make_lambda'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:342:in `block in simple'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:497:in `block in around'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:505:in `call'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:92:in `__run_callbacks__'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:778:in `_run_perform_callbacks'
/.../production/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
/.../production/shared/bundle/ruby/2.3.0/gems/activejob-4.2.5.1/lib/active_job/execution.rb:31:in `perform_now'
/.../production/shared/bundle/ruby/2.3.0/gems/activejob-4.2.5.1/lib/active_job/execution.rb:21:in `execute'
/.../production/shared/bundle/ruby/2.3.0/gems/activejob-4.2.5.1/lib/active_job/queue_adapters/sidekiq_adapter.rb:42:in `perform'
/.../production/shared/bundle/ruby/2.3.0/gems/sidekiq-3.5.4/lib/sidekiq/processor.rb:80:in `execute_job'
/.../production/shared/bundle/ruby/2.3.0/gems/sidekiq-3.5.4/lib/sidekiq/processor.rb:56:in `block (2 levels) in process'
/.../production/shared/bundle/ruby/2.3.0/gems/sidekiq-3.5.4/lib/sidekiq/middleware/chain.rb:127:in `block in invoke'
/.../production/shared/bundle/ruby/2.3.0/gems/sidekiq-3.5.4/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
/.../production/shared/bundle/ruby/2.3.0/gems/sidekiq-3.5.4/lib/sidekiq/middleware/server/active_record.rb:6:in `call'
/.../production/shared/bundle/ruby/2.3.0/gems/sidekiq-3.5.4/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
/.../production/shared/bundle/ruby/2.3.0/gems/sidekiq-3.5.4/lib/sidekiq/middleware/server/retry_jobs.rb:74:in `call'
/.../production/shared/bundle/ruby/2.3.0/gems/sidekiq-3.5.4/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
/.../production/shared/bundle/ruby/2.3.0/gems/sidekiq-failures-0.4.5/lib/sidekiq/failures/middleware.rb:9:in `call'
/.../production/shared/bundle/ruby/2.3.0/gems/sidekiq-3.5.4/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
/.../production/shared/bundle/ruby/2.3.0/gems/sidekiq-3.5.4/lib/sidekiq/middleware/server/logging.rb:11:in `block in call'
/.../production/shared/bundle/ruby/2.3.0/gems/sidekiq-3.5.4/lib/sidekiq/logging.rb:30:in `with_context'
/.../production/shared/bundle/ruby/2.3.0/gems/sidekiq-3.5.4/lib/sidekiq/middleware/server/logging.rb:7:in `call'
/.../production/shared/bundle/ruby/2.3.0/gems/sidekiq-3.5.4/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
/.../production/shared/bundle/ruby/2.3.0/gems/sidekiq-3.5.4/lib/sidekiq/middleware/chain.rb:132:in `invoke'
/.../production/shared/bundle/ruby/2.3.0/gems/sidekiq-3.5.4/lib/sidekiq/processor.rb:51:in `block in process'
/.../production/shared/bundle/ruby/2.3.0/gems/sidekiq-3.5.4/lib/sidekiq/processor.rb:104:in `stats'
/.../production/shared/bundle/ruby/2.3.0/gems/sidekiq-3.5.4/lib/sidekiq/processor.rb:50:in `process'
/.../production/shared/bundle/ruby/2.3.0/gems/celluloid-0.17.3/lib/celluloid/calls.rb:28:in `public_send'
/.../production/shared/bundle/ruby/2.3.0/gems/celluloid-0.17.3/lib/celluloid/calls.rb:28:in `dispatch'
/.../production/shared/bundle/ruby/2.3.0/gems/celluloid-0.17.3/lib/celluloid/call/async.rb:7:in `dispatch'
/.../production/shared/bundle/ruby/2.3.0/gems/celluloid-0.17.3/lib/celluloid/cell.rb:50:in `block in dispatch'
/.../production/shared/bundle/ruby/2.3.0/gems/celluloid-0.17.3/lib/celluloid/cell.rb:76:in `block in task'
/.../production/shared/bundle/ruby/2.3.0/gems/celluloid-0.17.3/lib/celluloid/actor.rb:339:in `block in task'
/.../production/shared/bundle/ruby/2.3.0/gems/celluloid-0.17.3/lib/celluloid/task.rb:44:in `block in initialize'
/.../production/shared/bundle/ruby/2.3.0/gems/celluloid-0.17.3/lib/celluloid/task/fibered.rb:14:in `block in create'

我没有在ruby bug跟踪器上找到关注此问题的人,也没有在stackoverflow上找到这个问题,并且ruby 2.3是最近的(<2个月)。

我该如何处理?

0 个答案:

没有答案