Repository navigation
NoMethodError: undefined method `lock' for #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0x0000000105b1e008> #127
Copy link
Copy link
Open
Description
v2.2.2, mysql2 0.5.4, Ruby 2.7, Rails 5.
When I downgrade to 1.8 it works. Maybe a Rails version check is needed in dependency list for 2.X?
NoMethodError:
undefined method `lock' for #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0x0000000105b1e008>
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/database_cleaner-active_record-2.2.2/lib/database_cleaner/active_record/transaction.rb:20:in `block in clean'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/database_cleaner-active_record-2.2.2/lib/database_cleaner/active_record/transaction.rb:19:in `each'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/database_cleaner-active_record-2.2.2/lib/database_cleaner/active_record/transaction.rb:19:in `clean'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/database_cleaner-core-2.0.1/lib/database_cleaner/strategy.rb:32:in `cleaning'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/2.7.0/forwardable.rb:235:in `cleaning'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/database_cleaner-core-2.0.1/lib/database_cleaner/cleaners.rb:34:in `block (2 levels) in cleaning'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/database_cleaner-core-2.0.1/lib/database_cleaner/cleaners.rb:35:in `cleaning'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/2.7.0/forwardable.rb:235:in `cleaning'
# ./spec/rails_helper.rb:90:in `block (2 levels) in <top (required)>'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:457:in `instance_exec'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:457:in `instance_exec'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/hooks.rb:390:in `execute_with'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:352:in `call'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/hooks.rb:629:in `run_around_example_hooks_for'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/hooks.rb:486:in `run'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:468:in `with_around_example_hooks'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:511:in `with_around_and_singleton_context_hooks'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:259:in `run'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:646:in `block in run_examples'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:642:in `map'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:642:in `run_examples'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:607:in `run'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:608:in `block in run'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:608:in `map'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:608:in `run'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:608:in `block in run'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:608:in `map'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:608:in `run'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:121:in `block (3 levels) in run_specs'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:121:in `map'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:121:in `block (2 levels) in run_specs'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/configuration.rb:2068:in `with_suite_hooks'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:116:in `block in run_specs'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/reporter.rb:74:in `report'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:115:in `run_specs'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:89:in `run'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:71:in `run'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:45:in `invoke'
# /Users/sshaw/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rspec-core-3.11.0/exe/rspec:4:in `<top (required)>'
# ./bin/rspec:17:in `load'
# ./bin/rspec:17:in `<main>'
Config
config.use_transactional_fixtures = false
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
config.around :each do |ex|
DatabaseCleaner.strategy = :truncation if ex.metadata[:js]
DatabaseCleaner.cleaning { ex.run }
DatabaseCleaner.strategy = :transaction
endReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
etagwerker commentedon Aug 15, 2025
Thanks for reporting this. I think this is a recent change, so have you tried using v2.2.1?
sshaw commentedon Aug 17, 2025
Hi, 2.2.1 works, yay, thanks. What change in 2.2.2 you think is the cause?
RyanSnodgrass commentedon Sep 26, 2025
I'm getting the same issue.
Starts in database_cleaner-active_record version 2.2.0.
Locking to 2.1.0 resolves the issue for me.