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

Octopus error at startup with Rails 6: alias_method': undefined method any?' for class `ActiveRecord::Associations::CollectionAssociation' (NameError) #540

Open
GuiTeK opened this issue Oct 14, 2019 · 7 comments

Comments

@GuiTeK
Copy link

GuiTeK commented Oct 14, 2019

Hi,

I'm trying to get Octopus working with my Rails 6 application. What I want to achieve is to use an AWS RDS read-replica for the read-only queries of my Rails application.

I'm using Octopus v. 0.10.2. Gemfile:

gem 'ar-octopus', '~> 0.10.2'

Here is what my MY-PROJECT/config/shards.yml looks like:

---
octopus:
  environments:
  - production
  replicated: true
  fully_replicated: true
  production:
    rds_read_replica:
      adapter: postgresql
      host: XXX.eu-west-1.rds.amazonaws.com
      port: '5432'
      database: XXX
      username: XXX
      password: XXX
      encoding: utf8

However, when I run bundle exec rails server, I have the huge cryptic error below. The application works fine without Octopus. Do you have an idea of what can cause this problem?

Error:

/srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/ar-octopus-0.10.2/lib/octopus/shard_tracking.rb:23:in `alias_method': undefined method `any?' for class `ActiveRecord::Associations::CollectionAssociation' (NameError)
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/ar-octopus-0.10.2/lib/octopus/shard_tracking.rb:23:in `create_sharded_method'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/ar-octopus-0.10.2/lib/octopus/shard_tracking.rb:12:in `block in sharded_methods'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/ar-octopus-0.10.2/lib/octopus/shard_tracking.rb:12:in `each'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/ar-octopus-0.10.2/lib/octopus/shard_tracking.rb:12:in `sharded_methods'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/ar-octopus-0.10.2/lib/octopus/collection_association.rb:9:in `included'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/ar-octopus-0.10.2/lib/octopus/collection_association.rb:17:in `include'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/ar-octopus-0.10.2/lib/octopus/collection_association.rb:17:in `<main>'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `block in require'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:291:in `load_dependency'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `require'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/ar-octopus-0.10.2/lib/octopus.rb:189:in `<main>'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `block in require'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:291:in `load_dependency'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `require'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/ar-octopus-0.10.2/lib/ar-octopus.rb:1:in `<main>'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /usr/local/bundle/gems/bundler-2.0.2/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
        from /usr/local/bundle/gems/bundler-2.0.2/lib/bundler/runtime.rb:76:in `each'
        from /usr/local/bundle/gems/bundler-2.0.2/lib/bundler/runtime.rb:76:in `block in require'
        from /usr/local/bundle/gems/bundler-2.0.2/lib/bundler/runtime.rb:65:in `each'
        from /usr/local/bundle/gems/bundler-2.0.2/lib/bundler/runtime.rb:65:in `require'
        from /usr/local/bundle/gems/bundler-2.0.2/lib/bundler.rb:114:in `require'
        from /srv/MY-PROJECT/config/application.rb:20:in `<main>'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `block in require'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:291:in `load_dependency'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `require'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/railties-6.0.0/lib/rails/commands/server/server_command.rb:141:in `block in perform'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/railties-6.0.0/lib/rails/commands/server/server_command.rb:138:in `tap'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/railties-6.0.0/lib/rails/commands/server/server_command.rb:138:in `perform'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/railties-6.0.0/lib/rails/command/base.rb:65:in `perform'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/railties-6.0.0/lib/rails/command.rb:46:in `invoke'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/railties-6.0.0/lib/rails/commands.rb:18:in `<main>'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `block in require'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:291:in `load_dependency'
        from /srv/MY-PROJECT/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `require'
        from bin/rails:9:in `<main>'

@GuiTeK
Copy link
Author

GuiTeK commented Oct 15, 2019

Seems like it is just not compatible: #490 (comment)

@schovi
Copy link

schovi commented Oct 18, 2019

@GuiTeK This simple line can fix that schovi@a396129
Just migrating our app and the db gems are most painful.

@Anoop1989
Copy link

I have a fix for this issue. Could you please provide me the relevant access privilege to push the code

@wjessop
Copy link

wjessop commented Sep 24, 2020

I just hit this issue upgrading an app from 5.2 to 6.0, it would be great if a fix could be merged.

@sb128265
Copy link

sb128265 commented Dec 22, 2020

Hi, I have the same issue after upgrading from Rails 5.0.7.1 to Rails 6.1.0. Is there a fix/merge for this now?

@Anoop1989
Copy link

Refer this #540 (comment)

@wjessop
Copy link

wjessop commented Dec 22, 2020

@Anoop1989 Yeah, it was a while ago and a different client, but I believe we monkey patched the behaviour in. It was a massive PITA finding the problem though, and it would still be great if Octopus worked out of the box.

shiratsu pushed a commit to tsunagu-grp/octopus that referenced this issue Jul 13, 2021
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

5 participants