You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi team, during the testing I found a very unusual behaviour of Toxiproxy#down method. The following snippet causes the MySQL client is not connected error:
test"#record_create throws a SQL exception if mysql_master database is down"dorecord=Record.new(attributes)Toxiproxy[:mysql_master].downdoassert_raises(ActiveRecord::ConnectionNotEstablished,ActiveRecord::StatementInvalid)docreate_record(record)endendRecord.first# => raising an error, i.e. "ActiveRecord::ConnectionNotEstablished: MySQL client is not connected"end
The text was updated successfully, but these errors were encountered:
@kuldeepaggarwal the issue is that ActiveRecord caches the connection, after you've taken down the DB and run a query it breaks the connection that's cached, you need to do an ActiveRecord::Base.connection.reset! (or there's probably a better equivalent) to reset the cached connection.
I've got a ToxiproxyHelper module in my apps that sets this up as a teardown:
defself.included(base)returnunlessbase.ancestors.include?(ActiveSupport::TestCase)base.class_evaldoteardowndoToxiproxy.reset# Rails caches the connection which we may have brokenActiveRecord::Base.connection.reset!endendend
Hi team, during the testing I found a very unusual behaviour of Toxiproxy#down method. The following snippet causes the
MySQL client is not connected
error:The text was updated successfully, but these errors were encountered: