新手问题 [mysql2 error] mysql client is not connected

whjwssy2017 · 2018年04月17日 · 最后由 whjwssy2017 回复于 2018年04月17日 · 3360 次阅读

Mysql2::Error (MySQL client is not connected): /home/work/ruby/lib/ruby/gems/1.8/gems/activerecord-mysql2-adapter-0.0.3/lib/active_record/connection_adapters/mysql2_adapter.rb:168:in escape' /home/work/ruby/lib/ruby/gems/1.8/gems/activerecord-mysql2-adapter-0.0.3/lib/active_record/connection_adapters/mysql2_adapter.rb:168:inquote_string' /home/work/ruby/lib/ruby/gems/1.8/gems/activerecord-mysql2-adapter-0.0.3/lib/active_record/connection_adapters/mysql2_adapter.rb:155:in quote' app/models/issue.rb:3554:inasync_svn_package' app/controllers/issues_controller.rb:550:in svn_pack' app/controllers/issues_controller.rb:526:insvn_pack' passenger (3.0.19) lib/phusion_passenger/rack/request_handler.rb:96:in process_request' passenger (3.0.19) lib/phusion_passenger/abstract_request_handler.rb:516:inaccept_and_process_next_request' passenger (3.0.19) lib/phusion_passenger/abstract_request_handler.rb:274:in main_loop' passenger (3.0.19) lib/phusion_passenger/rack/application_spawner.rb:206:instart_request_handler' passenger (3.0.19) lib/phusion_passenger/rack/application_spawner.rb:171:in send' passenger (3.0.19) lib/phusion_passenger/rack/application_spawner.rb:171:inhandle_spawn_application' passenger (3.0.19) lib/phusion_passenger/utils.rb:470:in safe_fork' passenger (3.0.19) lib/phusion_passenger/rack/application_spawner.rb:166:inhandle_spawn_application' passenger (3.0.19) lib/phusion_passenger/abstract_server.rb:357:in __send__' passenger (3.0.19) lib/phusion_passenger/abstract_server.rb:357:inserver_main_loop' passenger (3.0.19) lib/phusion_passenger/abstract_server.rb:206:in start_synchronously' passenger (3.0.19) lib/phusion_passenger/abstract_server.rb:180:instart' passenger (3.0.19) lib/phusion_passenger/rack/application_spawner.rb:129:in start' passenger (3.0.19) lib/phusion_passenger/spawn_manager.rb:253:inspawn_rack_application' passenger (3.0.19) lib/phusion_passenger/abstract_server_collection.rb:132:in lookup_or_add' passenger (3.0.19) lib/phusion_passenger/spawn_manager.rb:246:inspawn_rack_application' passenger (3.0.19) lib/phusion_passenger/abstract_server_collection.rb:82:in synchronize' passenger (3.0.19) lib/phusion_passenger/abstract_server_collection.rb:79:insynchronize' passenger (3.0.19) lib/phusion_passenger/spawn_manager.rb:244:in spawn_rack_application' passenger (3.0.19) lib/phusion_passenger/spawn_manager.rb:137:inspawn_application' passenger (3.0.19) lib/phusion_passenger/spawn_manager.rb:275:in handle_spawn_application' passenger (3.0.19) lib/phusion_passenger/abstract_server.rb:357:insend' passenger (3.0.19) lib/phusion_passenger/abstract_server.rb:357:in server_main_loop' passenger (3.0.19) lib/phusion_passenger/abstract_server.rb:206:instart_synchronously' passenger (3.0.19) helper-scripts/passenger-spawn-server:99

Rendering /home/work/oem/redmine_git/public/500.html (500 Internal Server Error) rendering section "request" rendering section "session" rendering section "environment" rendering section "backtrace"

问题背景:我执行打包任务,打包时间过长,大约 9 分钟,然后 production 的日志记录显示 mysql2 error 上述问题,我怎样解决呢?

database.yml 看下

是因为太长时间没有进行 sql 操作,然后 mysql2 短连接然后断开了是吗?那 mysql2 能够实现重连接吗?或者在 models 层还能有其他的办法吗?

需要 登录 后方可回复, 如果你还没有账号请 注册新账号