2014-01-21 54 views
0

我已經更新了從rails 3.2到rails 4.0.2的應用程序,我似乎在運行rspec時會出現隨機mysql錯誤。這在升級rails 4之前不會發生。導軌4升級後的mysql錯誤

環境的詳細信息:

  • 的Mac OSX
  • 紅寶石2.0
  • 的Rails 4.0.2
  • mysql2寶石

錯誤:

ActiveRecord::StatementInvalid: 
    Mysql2::Error: MySQL server has gone away: SELECT 

UPDATE:在Heroku上有一個類似的問題,同時運行rake任務以及

堆棧跟蹤:

Mysql2::Error: Lost connection to MySQL server during query: SELECT .... 
    (0.1ms) ROLLBACK 
Mysql2::Error: MySQL server has gone away: ROLLBACK 
rake aborted! 
Mysql2::Error: Lost connection to MySQL server during query: SELECT ... 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:287:in `query' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:287:in `block in execute' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:435:in `block in log' 
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/notifications/instrumenter.rb:20:in `instrument' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:430:in `log' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:287:in `execute' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/mysql2_adapter.rb:222:in `execute' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/mysql2_adapter.rb:226:in `exec_query' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/mysql2_adapter.rb:235:in `select' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:24:in `select_all' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/querying.rb:36:in `find_by_sql' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/relation.rb:585:in `exec_queries' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/relation.rb:471:in `load' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/relation.rb:220:in `to_a' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/relation.rb:598:in `exec_queries' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/association_relation.rb:15:in `exec_queries' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/relation.rb:471:in `load' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/relation.rb:220:in `to_a' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/relation/finder_methods.rb:325:in `find_first' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/relation/finder_methods.rb:90:in `first' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-deprecated_finders-1.0.3/lib/active_record/deprecated_finders/relation.rb:129:in `first' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/associations/singular_association.rb:42:in `find_target' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/associations/association.rb:147:in `load_target' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/associations/association.rb:54:in `reload' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/associations/singular_association.rb:9:in `reader' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/associations/builder/association.rb:70:in `assessment' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/associations/builder/belongs_to.rb:28:in `belongs_to_counter_cache_after_create_for_assessment' 
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:375:in `_run__4224105350082465631__create__callbacks' 
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:80:in `run_callbacks' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/callbacks.rb:306:in `create_record' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/timestamp.rb:57:in `create_record' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/persistence.rb:477:in `create_or_update' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/callbacks.rb:302:in `block in create_or_update' 
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:403:in `_run__4224105350082465631__save__callbacks' 
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:80:in `run_callbacks' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/callbacks.rb:302:in `create_or_update' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/persistence.rb:128:in `save!' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/validations.rb:57:in `save!' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/attribute_methods/dirty.rb:41:in `save!' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:275:in `block in save!' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:326:in `block in with_transaction_returning_status' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:200:in `transaction' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:209:in `transaction' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:323:in `with_transaction_returning_status' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:275:in `save!' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/associations/has_many_through_association.rb:94:in `save_through_record' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/associations/has_many_through_association.rb:65:in `insert_record' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/associations/collection_association.rb:523:in `block (2 levels) in concat_records' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/associations/collection_association.rb:367:in `add_to_target' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/associations/collection_association.rb:522:in `block in concat_records' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/associations/collection_association.rb:520:in `each' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/associations/collection_association.rb:520:in `concat_records' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/associations/has_many_through_association.rb:43:in `concat_records' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/associations/collection_association.rb:137:in `block in concat' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/associations/collection_association.rb:152:in `block in transaction' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:209:in `transaction' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/associations/collection_association.rb:151:in `transaction' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/associations/collection_association.rb:137:in `concat' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/associations/has_many_through_association.rb:37:in `concat' 
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/associations/collection_proxy.rb:943:in `<<' 
/app/lib/tasks/scrape_workbook.rake:143:in `block (3 levels) in <top (required)>' 
/app/vendor/bundle/ruby/2.0.0/gems/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:237:in `block in each' 
/app/vendor/bundle/ruby/2.0.0/gems/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:236:in `upto' 
/app/vendor/bundle/ruby/2.0.0/gems/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:236:in `each' 
/app/lib/tasks/scrape_workbook.rake:29:in `block (2 levels) in <top (required)>' 
/app/vendor/bundle/ruby/2.0.0/gems/aws-sdk-1.32.0/lib/aws/core/collection.rb:48:in `each' 
/app/vendor/bundle/ruby/2.0.0/gems/aws-sdk-1.32.0/lib/aws/core/collection.rb:48:in `block in each' 
/app/vendor/bundle/ruby/2.0.0/gems/aws-sdk-1.32.0/lib/aws/core/collection/with_limit_and_next_token.rb:61:in `_each_batch' 
/app/vendor/bundle/ruby/2.0.0/gems/aws-sdk-1.32.0/lib/aws/core/collection.rb:80:in `each_batch' 
/app/vendor/bundle/ruby/2.0.0/gems/aws-sdk-1.32.0/lib/aws/core/collection.rb:47:in `each' 
/app/vendor/bundle/ruby/2.0.0/gems/aws-sdk-1.32.0/lib/aws/s3/object_collection.rb:282:in `each' 
/app/lib/tasks/scrape_workbook.rake:12:in `block in <top (required)>' 
+1

多一點錯誤日誌和錯誤行代碼將有所幫助:) – Santhosh

回答

0

試試這個。

do "bundle install --without production" 

看看這是否有幫助。

+0

沒有運氣......增加更新與類似的問題在heroku以及.... – user2515011