there is a lot of ActiveRecord::ConnectionNotEstablished (MySQL client is not connected)
Closed this issue · 2 comments
dillon-zheng commented
I use jets to deploy my rails cron job. my others rails app on ec2 is OK. But in this jets lambda I find a lot of Lost connections.
below is err trace msg from ruby.
please help me, where I did wrong? many thanks
Here is jets console output
2.5.8 :156 > s.group_configs.where(k:'project',v:'MKPL').explain
E, [2021-06-21T09:31:01.681126 #10919] ERROR -- : Error in exec sql: SELECT `group_configs`.* FROM `group_configs` INNER JOIN `services_group_configs` ON `group_configs`.`id` = `services_group_configs`.`group_config_id` WHERE `services_group_configs`.`service_id` = 1000 AND `group_configs`.`k` = 'project' AND `group_configs`.`v` = 'MKPL'
Traceback (most recent call last):
16: from /home/admin/.rvm/gems/ruby-2.5.8/gems/activerecord-6.1.3.2/lib/active_record/connection_adapters/abstract_adapter.rb:695:in `block in log'
15: from /home/admin/.rvm/gems/ruby-2.5.8/gems/activesupport-6.1.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
14: from /home/admin/.rvm/gems/ruby-2.5.8/gems/activesupport-6.1.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
13: from /home/admin/.rvm/gems/ruby-2.5.8/gems/activesupport-6.1.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
12: from /home/admin/.rvm/gems/ruby-2.5.8/gems/activesupport-6.1.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
11: from /home/admin/.rvm/gems/ruby-2.5.8/gems/activesupport-6.1.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
10: from /home/admin/.rvm/gems/ruby-2.5.8/gems/activerecord-6.1.3.2/lib/active_record/connection_adapters/abstract_adapter.rb:696:in `block (2 levels) in log'
9: from /home/admin/.rvm/gems/ruby-2.5.8/gems/activerecord-6.1.3.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:205:in `block in execute'
8: from /home/admin/.rvm/gems/ruby-2.5.8/gems/activesupport-6.1.3.2/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
7: from /home/admin/.rvm/gems/ruby-2.5.8/gems/activesupport-6.1.3.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
6: from /home/admin/.rvm/gems/ruby-2.5.8/gems/activesupport-6.1.3.2/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
5: from /home/admin/.rvm/gems/ruby-2.5.8/gems/activerecord-6.1.3.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:206:in `block (2 levels) in execute'
4: from /home/admin/.rvm/gems/ruby-2.5.8/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `query'
3: from /home/admin/.rvm/gems/ruby-2.5.8/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `handle_interrupt'
2: from /home/admin/.rvm/gems/ruby-2.5.8/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `block in query'
1: from /home/admin/.rvm/gems/ruby-2.5.8/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `_query'
ActiveRecord::ConnectionNotEstablished (MySQL client is not connected)
But sometimes is fine
2.5.8 :158 > s.group_configs.where(k:'project',v:'MKPL').explain
=> EXPLAIN for:
+----+-------------+------------------------+------------+------+-----------------------------------------------------------------------+------------------------------------+---------+-----------------------------------------+------+----------+-------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+------------------------+------------+------+-----------------------------------------------------------------------+------------------------------------+---------+-----------------------------------------+------+----------+-------------+
| 1 | SIMPLE | group_configs | NULL | ref | PRIMARY,uk_on_group_config_kv | uk_on_group_config_kv | 1204 | const,const | 1 | 100.0 | NULL |
| 1 | SIMPLE | services_group_configs | NULL | ref | idx_services_group_configs_service,idx_services_service_group_configs | idx_services_group_configs_service | 8 | const,service_identity.group_configs.id | 1 | 100.0 | Using index |
+----+-------------+------------------------+------------+------+-----------------------------------------------------------------------+------------------------------------+---------+-----------------------------------------+------+----------+-------------+
2 rows in set (0.00 sec)
dillon-zheng commented
jets version
3.0.9
ruby -v
ruby 2.5.8p224 (2020-03-31 revision 67882) [x86_64-linux]
sam0x17 commented
Are basic queries working? Like MyModel.all.size
? If not, then maybe you aren't connected to the db at all