3

我的控制器在某些点击时将数据推送到 Firebase。

class FirebaseController < ApplicationController

    Firebase.base_uri = "https://firebaseProject.Firebaseio.com/"  

    def call_to_firebase

        Firebase.push("firebase_channel", "firebase_data".to_json)

        respond_to do |format|
        format.json { render nothing: true, :status => 204 }
        end
    end
end

如果快速连续调用此控制器(通过单击调用),我的 Puma 服务器会立即崩溃。

我正在使用 Rails 4.0.0 Puma 2.6.0 Ruby 2.0.0

以下是生成的庞大日志报告的一部分。

ETHON: started MULTI
ETHON:         performed EASY url= response_code=200 return_code=got_nothing total_time=2.663048
/Users/siddharthbhagwan/.rvm/gems/ruby-2.0.0-p247/gems/ethon-0.6.1/lib/ethon/multi/operations.rb:171: [BUG] Segmentation fault
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.3.0]

-- Crash Report log information --------------------------------------------
   See Crash Report log file under the one of following:
     * ~/Library/Logs/CrashReporter
     * /Library/Logs/CrashReporter
     * ~/Library/Logs/DiagnosticReports
     * /Library/Logs/DiagnosticReports
   the more detail of.

-- Control frame information -----------------------------------------------
c:0091 p:---- s:0489 e:000488 CFUNC  :multi_perform
c:0090 p:0018 s:0484 e:000483 METHOD /Users/siddharthbhagwan/.rvm/gems/ruby-2.0.0-p247/gems/ethon-0.6.1/lib/ethon/multi/operations.rb:171
c:0089 p:0034 s:0479 e:000478 METHOD /Users/siddharthbhagwan/.rvm/gems/ruby-2.0.0-p247/gems/ethon-0.6.1/lib/ethon/multi/operations.rb:160
c:0088 p:0036 s:0474 e:000473 METHOD /Users/siddharthbhagwan/.rvm/gems/ruby-2.0.0-p247/gems/ethon-0.6.1/lib/ethon/multi/operations.rb:43
c:0087 p:0020 s:0470 e:000469 METHOD /Users/siddharthbhagwan/.rvm/gems/ruby-2.0.0-p247/gems/typhoeus-0.6.6/lib/typhoeus/hydra/runnable.rb:21
c:0086 p:0008 s:0466 e:000465 METHOD /Users/siddharthbhagwan/.rvm/gems/ruby-2.0.0-p247/gems/typhoeus-0.6.6/lib/typhoeus/hydra/memoizable.rb:51
c:0085 p:0104 s:0463 e:000462 METHOD /Users/siddharthbhagwan/.rvm/gems/ruby-2.0.0-p247/gems/firebase-0.1.4/lib/firebase/request.rb:50
c:0084 p:0019 s:0456 e:000455 METHOD /Users/siddharthbhagwan/.rvm/gems/ruby-2.0.0-p247/gems/firebase-0.1.4/lib/firebase/request.rb:20
c:0083 p:0019 s:0451 e:000450 METHOD /Users/siddharthbhagwan/.rvm/gems/ruby-2.0.0-p247/gems/firebase-0.1.4/lib/firebase.rb:34

.
.
.

c:0005 p:0027 s:0029 e:000028 METHOD /Users/siddharthbhagwan/.rvm/gems/ruby-2.0.0-p247/gems/puma-2.6.0/lib/puma/server.rb:357
c:0004 p:0035 s:0022 e:000021 BLOCK  /Users/siddharthbhagwan/.rvm/gems/ruby-2.0.0-p247/gems/puma-2.6.0/lib/puma/server.rb:250 [FINISH]
c:0003 p:---- s:0016 e:000015 CFUNC  :call
c:0002 p:0084 s:0011 e:000010 BLOCK  /Users/siddharthbhagwan/.rvm/gems/ruby-2.0.0-p247/gems/puma-2.6.0/lib/puma/thread_pool.rb:92 [FINISH]
c:0001 p:---- s:0002 e:000001 TOP    [FINISH]
.
.
.
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Abort trap: 6

快速我的意思是每秒点击一次。对于较慢的点击,例如每 2 秒点击 1 次,这不会发生。

在循环中从 irb 推送到 firebase 不会导致此错误。

在此先感谢,干杯!

4

1 回答 1

1

你在使用firebase-ruby gem吗?我今天提交了针对此问题的错误修复。您可以通过覆盖 gem 中的有问题的方法来自己对其进行热补丁,如下所示:

模块 Firebase

类请求

def process(method, path, body=nil, query_options={})
  request = Typhoeus::Request.new(build_url(path),
                                  :body => body,
                                  :method => method,
                                  :params => query_options)
  response = request.run
  Firebase::Response.new(response)
end

结束结束

或者等待拉取请求被接受。问题在于宝石对 Typheous 九头蛇的使用。

于 2014-06-20T18:37:59.360 回答