2013-11-26 23 views
3

我的控制器在某些點擊時將數據推送到firebase。快速多次調用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 彪馬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不會導致此錯誤。

在此先感謝, 乾杯!

+0

看起來您正在使用包裝REST API的第三方庫?任何想法哪一個?我會很快猜測它不是線程安全的。 :( – Kato

+0

Hey Kato。控制器中的兩行代碼與firebase是abt唯一使用的firebase API。是的,線程安全似乎是問題:( – SiddharthBhagwan

回答

1

您是否使用firebase-ruby gem?我今天提交了一個針對此問題的錯誤修復。您可以熱通過重寫問題的方法,在創業板上市,像這樣自己打補丁:

模塊火力地堡

類請求

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'Hydra。