Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ApplicationRecord Load getting Mysql Error #155

Open
markhermano opened this issue Mar 1, 2024 · 1 comment
Open

ApplicationRecord Load getting Mysql Error #155

markhermano opened this issue Mar 1, 2024 · 1 comment

Comments

@markhermano
Copy link

Hello,

I stumbled into another issue here which only occurs again on CI but works locally.
The gem loads the resource for the ApplicationRecord model but doesn't find a DB table associated with it.

The error I get in GitHub actions is:
image

Here is the test.log from the Github actions artifacts:

[CY_DEV]   �[1m�[36mItemToProcess Load (0.6ms)�[0m  �[1m�[34mSELECT `items_to_process`.* FROM `items_to_process` LIMIT 100�[0m
[CY_DEV]   �[1m�[36mLabelDisplay Load (0.5ms)�[0m  �[1m�[34mSELECT `label_displays`.* FROM `label_displays` LIMIT 100�[0m
[CY_DEV]   �[1m�[36mLeadsDetail Load (0.6ms)�[0m  �[1m�[34mSELECT `leads_details`.* FROM `leads_details` LIMIT 100�[0m
[CY_DEV]   �[1m�[36mApplicationRecord Load (0.5ms)�[0m  �[1m�[34mSELECT ``.* FROM `` LIMIT 100�[0m
[CY_DEV] fail to execute /app/spec-cypress/e2e/app_commands/log_fail.rb: Mysql2::Error: Incorrect table name ''
[CY_DEV] /app/vendor/bundle/ruby/3.0.0/gems/mysql2-0.5.5/lib/mysql2/client.rb:151:in `_query'
/app/vendor/bundle/ruby/3.0.0/gems/mysql2-0.5.5/lib/mysql2/client.rb:151:in `block in query'
/app/vendor/bundle/ruby/3.0.0/gems/mysql2-0.5.5/lib/mysql2/client.rb:150:in `handle_interrupt'
/app/vendor/bundle/ruby/3.0.0/gems/mysql2-0.5.5/lib/mysql2/client.rb:150:in `query'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:201:in `block (2 levels) in execute'
/app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.6.1/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
/app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.6.1/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.6.1/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:200:in `block in execute'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract_adapter.rb:728:in `block (2 levels) in log'
/app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
/app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract_adapter.rb:727:in `block in log'
/app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.6.1/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract_adapter.rb:718:in `log'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:199:in `execute'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/mysql/database_statements.rb:41:in `execute'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:210:in `execute_and_free'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/mysql/database_statements.rb:46:in `exec_query'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract/database_statements.rb:489:in `select'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract/database_statements.rb:70:in `select_all'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract/query_cache.rb:105:in `block in select_all'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract/query_cache.rb:122:in `block in cache_sql'
/app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
/app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract/query_cache.rb:113:in `cache_sql'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/abstract/query_cache.rb:105:in `select_all'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/connection_adapters/mysql/database_statements.rb:12:in `select_all'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/querying.rb:46:in `find_by_sql'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/relation.rb:824:in `block in exec_queries'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/relation.rb:842:in `skip_query_cache_if_necessary'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/relation.rb:811:in `exec_queries'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/relation.rb:626:in `load'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/relation.rb:250:in `records'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.6.1/lib/active_record/relation/delegation.rb:88:in `each'
/app/spec-cypress/e2e/app_commands/log_fail.rb:16:in `map'
/app/spec-cypress/e2e/app_commands/log_fail.rb:16:in `block in perform'
/app/spec-cypress/e2e/app_commands/log_fail.rb:15:in `each'
/app/spec-cypress/e2e/app_commands/log_fail.rb:15:in `each_with_object'
/app/spec-cypress/e2e/app_commands/log_fail.rb:15:in `perform'
/app/vendor/bundle/ruby/3.0.0/gems/cypress-on-rails-1.16.0/lib/cypress_on_rails/command_executor.rb:9:in `eval'
/app/vendor/bundle/ruby/3.0.0/gems/cypress-on-rails-1.16.0/lib/cypress_on_rails/command_executor.rb:9:in `perform'
/app/vendor/bundle/ruby/3.0.0/gems/cypress-on-rails-1.16.0/lib/cypress_on_rails/middleware.rb:61:in `block in handle_command'
/app/vendor/bundle/ruby/3.0.0/gems/cypress-on-rails-1.16.0/lib/cypress_on_rails/middleware.rb:61:in `map'
/app/vendor/bundle/ruby/3.0.0/gems/cypress-on-rails-1.16.0/lib/cypress_on_rails/middleware.rb:61:in `handle_command'
/app/vendor/bundle/ruby/3.0.0/gems/cypress-on-rails-1.16.0/lib/cypress_on_rails/middleware.rb:20:in `block in call'

Is there a workaround for this issue?

@markhermano
Copy link
Author

I found a solution to the issue above by doing the following in log_fail.rb but I'm unsure if this is a better way of doing it.

json_result["records"] =
    (ActiveRecord::Base.descendants - [ApplicationRecord]).each_with_object({}) do |record_class, records|
      records[record_class.to_s] = record_class.limit(100).map(&:attributes)
    rescue StandardError => e
      raise e
    end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant