3
我們有一些超時問題。我們使用多線程運行sidekiq。他們每個人都執行一些http操作。有時候,工作人員被困在一個網絡HTTP調用中,沒有發生超時。然後,所有的線程都閒置,不再做任何事情。全局Ruby HTTP超時
- 的HTTP
read_timeout
似乎被設置爲60,而紅寶石默認open_timeout
設置爲nil
。這可能是問題嗎? - 如果是,是否可以爲http類的所有實例設置超時的默認值?猴子補丁呢?
堆棧跟蹤:
2014-07-07T07:59:22Z 26495 TID-otmt0zt9s INFO: /home/deployer/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:879:in `initialize'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:879:in `open'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:879:in `block in connect'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/2.1.0/timeout.rb:76:in `timeout'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:878:in `connect'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:863:in `do_start'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:852:in `start'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:1369:in `request'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rack-mini-profiler-0.9.1/lib/patches/net_patches.rb:7:in `block in request_with_mini_profiler'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rack-mini-profiler-0.9.1/lib/mini_profiler/profiling_methods.rb:40:in `step'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rack-mini-profiler-0.9.1/lib/patches/net_patches.rb:6:in `request_with_mini_profiler'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rest-client-1.6.7/lib/restclient/net_http_ext.rb:51:in `request'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/faraday-0.9.0/lib/faraday/adapter/net_http.rb:80:in `perform_request'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/faraday-0.9.0/lib/faraday/adapter/net_http.rb:39:in `call'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/faraday-0.9.0/lib/faraday/request/url_encoded.rb:15:in `call'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/signet-0.5.0/lib/signet/oauth_2/client.rb:875:in `fetch_access_token'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/signet-0.5.0/lib/signet/oauth_2/client.rb:898:in `fetch_access_token!'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/signet-0.5.0/lib/signet/oauth_2/client.rb:913:in `refresh!'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/google-ads-common-0.9.5/lib/ads_common/auth/oauth2_handler.rb:91:in `refresh_token!'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/google-ads-common-0.9.5/lib/ads_common/auth/oauth2_handler.rb:83:in `get_token'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/google-ads-common-0.9.5/lib/ads_common/auth/oauth2_handler.rb:75:in `auth_string'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/google-ads-common-0.9.5/lib/ads_common/savon_headers/oauth_header_handler.rb:45:in `generate_headers'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/google-ads-common-0.9.5/lib/ads_common/savon_headers/base_header_handler.rb:75:in `prepare_request'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/google-ads-common-0.9.5/lib/ads_common/savon_service.rb:103:in `block in execute_soap_request'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/savon-1.2.0/lib/savon/client.rb:129:in `yield_objects'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/savon-1.2.0/lib/savon/client.rb:122:in `process'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/savon-1.2.0/lib/savon/client.rb:84:in `block in request'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/savon-1.2.0/lib/savon/soap/request_builder.rb:56:in `call'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/savon-1.2.0/lib/savon/soap/request_builder.rb:56:in `request'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/savon-1.2.0/lib/savon/client.rb:86:in `request'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/google-ads-common-0.9.5/lib/ads_common/savon_service.rb:101:in `execute_soap_request'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/google-ads-common-0.9.5/lib/ads_common/savon_service.rb:80:in `execute_action'
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/google-adwords-api-0.11.1/lib/adwords_api/v201402/campaign_service.rb:25:in `mutate'
/home/deployer/apps/robot/lib/adwords_helper.rb:1355:in `toggle_campaign'
/home/deployer/apps/robot/app/models/adwords_campaign.rb:262:in `adwords_toggle'
/home/deployer/apps/robot/app/workers/update_campaign_status.rb:13:in `perform'
/home/deployer/apps/robot/app/workers/recurring/refresh_campaign_status.rb:12:in `block in perform'
編輯:
我猴子修補的HTTP庫。不確定問題是否會再次發生。如果是,我會在這裏發帖。
module Net
class HTTP < Protocol
alias_method :old_initialize, :initialize
def initialize(address, port = nil, open_timeout: 60)
old_initialize(address, port)
self.open_timeout = open_timeout
end
end
end
自己回答你的問題關閉它是不是正確? – zuba
您能否將問題的答案移出問題並轉化爲答案,然後爲答案給出答案?這將有助於其他有同樣問題的人(當問題本身不存在時,更容易看出問題有答案)。 –