octopus
octopus copied to clipboard
Octopus error at startup with Rails 6: `alias_method': undefined method `any?' for class `ActiveRecord::Associations::CollectionAssociation' (NameError)
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>'
Seems like it is just not compatible: https://github.com/thiagopradi/octopus/issues/490#issuecomment-383667221
@GuiTeK This simple line can fix that https://github.com/schovi/octopus/commit/a39612969286891c705384c214d7f1d0c365609f Just migrating our app and the db gems are most painful.
I have a fix for this issue. Could you please provide me the relevant access privilege to push the code
I just hit this issue upgrading an app from 5.2 to 6.0, it would be great if a fix could be merged.
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?
Refer this https://github.com/thiagopradi/octopus/issues/540#issuecomment-543682847
@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.