Rails Mysql Error Lost Connection To Mysql Server During Query
Contents |
Sign in Pricing Blog mysql2::error: lost connection to mysql server Support Search GitHub This repository Watch 77 rails mysql2::error: lost connection to mysql server during query Star 1,523 Fork 343 brianmario/mysql2 Code Issues 33 Pull requests 10 Projects activerecord::statementinvalid: mysql2::error: lost connection to mysql server during query: 0 Pulse Graphs New issue Lost connection to MySQL server during query on 'simple' queries #495 Closed kakubei opened sequel::databasedisconnecterror: mysql2::error: mysql server has gone away this Issue Mar 10, 2014 · 33 comments Labels None yet Milestone 0.3.17 Assignees No one assigned 13 participants kakubei commented Mar 10, 2014 Opening up a new issue for this since all the other
Mysql Lost Connection During Query
similar ones are closed. We started seeing lots of these errors after upgrading to Padrino 0.12 and Mysql2 0.3.15. We don't have access to mysql.cnf (hosted on ClearDB) so can't tweak any of the settings there. Reconnect is set to true in our database.rb file. This is on Heroku and happens (unsurprisingly) during heavy usage. By "simple" queries, I mean it's nothing crazy, just a number of joins with properly formatted foreign keys which execute pretty quickly in the console. Any ideas are welcome. Lost connection to MySQL server during query Padrino 0.12 Active Record 4.0.2 mysql2 (0.3.15) puma (2.7.1) Following is the backtrace: gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:287query gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:287block in execute gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:435block in log gems/activesupport-4.0.2/lib/active_support/notifications/instrumenter.rb:20instrument gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:430log gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:287execute gems/activerecord-4.0.2/lib/active_record/connection_adapters/mysql2_adapter.rb:222execute gems/activerecord-4.0.2/lib/active_record/conne
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about
Mysql2 Gem
Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up MySQL2: Lost connection to MySQL server during query up vote 2 down vote favorite https://github.com/brianmario/mysql2/issues/495 I am getting the following error when i am trying to use union: ActionView::Template::Error (Mysql2::Error: Lost connection to MySQL server during query: SELECT `apps`.* FROM `apps` WHERE `verve_apps`.`status` IN (1, 2) AND (apps.id IN (SELECT apps.id FROM `apps` WHERE `apps`.`status` IN (1, 2) AND (app_name LIKE '%b%') UNION SELECT apps.id FROM `verve_apps` INNER JOIN taggings ON taggings.taggable_id = apps.id INNER JOIN tags ON tags.id = taggings.tag_id AND taggings.taggable_type = 'App' http://stackoverflow.com/questions/33281995/mysql2-lost-connection-to-mysql-server-during-query WHERE `apps`.`status` IN (1, 2) AND (tags.name = 'b') ORDER BY id ASC)) ORDER BY app_name asc LIMIT 10 OFFSET 0) app.rb class App < ActiveRecord::Base include ActiveRecord::UnionScope acts_as_taggable attr_accessor: :user_name, :age, :country, tag_list scope :tagged_with, lambda { |tag| { :joins => "INNER JOIN taggings ON taggings.taggable_id = user.id\ INNER JOIN tags ON tags.id = taggings.tag_id AND taggings.taggable_type = 'App'", :conditions => ["tags.name = ?", tag], :order => 'id ASC' } } def self.search(search) if search union_scope(where('name LIKE ?', "%#{search}%") ,tagged_with(search)) else scoped end end end user_controller.rb class UserController < ActionController::Base def index @users = User.search(params[:search]).paginate(:per_page => per_page, :page => params[:page]) end database.yml pipe_local_development: &pipe_local_development adapter: mysql2 encoding: utf8 reconnect: true database: app_development pool: 5 username: root password: I am able to run this method from console without problems. mysql ruby ruby-on-rails-3 share|improve this question edited Oct 23 '15 at 6:03 asked Oct 22 '15 at 13:17 Mano 420616 1 Did you intend for where('name LIKE ?', "%#{search}%") + tagged_with(search) to be a union, or is it supposed to be a single select, which would be given by where('name LIKE ?', "%#{search}%").tagged_with(search)? –Ben Y Oct 22 '15 at 13:21 Possible duplicate of Lost connection to MySQL server during query –Drenmi Oct 22 '15 at
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business http://stackoverflow.com/questions/4983385/lost-connection-to-mysql-server-during-query-error-with-rails3-octopus-replicat Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Lost connection to MySQL server during query error with Rails3, octopus replication gem up vote 4 down vote favorite I just upgrade my web lost connection service from Rails 2.3.8 to Rails 3.0.3 It's almost working well. I has one problem, Lost connection error is occurred when the service is deployed with capistrano. About 3 times occurred every deployment. The service use octopus gem from https://github.com/tchandy/octopus for database replication with 1 master database and 2 slave database. Mysql::Error: Lost connection to MySQL server during query: SELECT regions.* FROM regions WH ... The problem is not occurred when octopus is not used lost connection to with single database. But replication is needed for traffic. Please, give me any advise. Thank you. mysql ruby-on-rails ruby-on-rails-3 replication share|improve this question asked Feb 13 '11 at 9:16 Jaehyun 230615 add a comment| 2 Answers 2 active oldest votes up vote 5 down vote accepted I'm the creator of Octopus. Can you add this to your shards.yml file? verify_connection: true Also, if that don't work, try to configure rails to automatic reconnect: http://guides.rubyonrails.org/2_3_release_notes.html#reconnecting-mysql-connections Obs: this will work only with mysql adapter, not mysql2. share|improve this answer edited Feb 27 '11 at 4:38 answered Feb 27 '11 at 4:26 Thiago Pradi 664 Thank you! I am surprising you are creator of Octopus. You are right. it is one of the solutions. But, The problem cann't be solved with passenger. It is solved using Nginx + Unicorn. –Jaehyun Feb 28 '11 at 4:41 Octopus is very good gem for replication! –Jaehyun Feb 28 '11 at 4:43 I'm working to find a solution for Passenger! Also, nice to know that it solves your issue ;-) –Thiago Pradi Feb 28 '11 at 13:09 You need to be careful with verify_connection: true because it can cause Octopus to make two SQL requests for every SQL request you actually make: one to verify the connection, plus the actual SQL reques