Defect #40214
closedNoMethodError (undefined method `with_advisory_lock!' for class Issue)
0%
Description
When i try to delete an issue the following error occurs:
I, [2024-02-08T09:28:14.592092 #53517] INFO -- : [99d242c2-a3dd-47fa-b7fe-c74d164771c9] Current user: ivan.kruger (id=470)
I, [2024-02-08T09:28:14.606847 #53517] INFO -- : [99d242c2-a3dd-47fa-b7fe-c74d164771c9] Completed 500 Internal Server Error in 18ms (ActiveRecord: 3.7ms | Allocations: 5076)
F, [2024-02-08T09:28:14.607774 #53517] FATAL -- : [99d242c2-a3dd-47fa-b7fe-c74d164771c9]
[99d242c2-a3dd-47fa-b7fe-c74d164771c9] NoMethodError (undefined method `with_advisory_lock!' for class Issue):
[99d242c2-a3dd-47fa-b7fe-c74d164771c9]
[99d242c2-a3dd-47fa-b7fe-c74d164771c9] lib/redmine/nested_set/issue_nested_set.rb:185:in `lock_nested_set'
[99d242c2-a3dd-47fa-b7fe-c74d164771c9] lib/redmine/nested_set/issue_nested_set.rb:139:in `destroy_children'
[99d242c2-a3dd-47fa-b7fe-c74d164771c9] app/models/issue.rb:251:in `destroy'
[99d242c2-a3dd-47fa-b7fe-c74d164771c9] app/controllers/issues_controller.rb:463:in `block in destroy'
[99d242c2-a3dd-47fa-b7fe-c74d164771c9] app/controllers/issues_controller.rb:461:in `each'
[99d242c2-a3dd-47fa-b7fe-c74d164771c9] app/controllers/issues_controller.rb:461:in `destroy'
[99d242c2-a3dd-47fa-b7fe-c74d164771c9] lib/redmine/sudo_mode.rb:61:in `sudo_mode'
Those are my redmine settings:
Environment:
Redmine version 5.1.1.stable
Ruby version 3.3.0-p0 (2023-12-25) [x86_64-linux]
Rails version 6.1.7.6
Environment production
Database adapter Mysql2
Mailer queue ActiveJob::QueueAdapters::SuckerPunchAdapter
Mailer delivery smtp
Redmine settings:
Redmine theme Alternate
SCM:
Subversion 1.14.1
Git 2.34.0
Filesystem
Redmine plugins:
redmine_agile 1.6.5
redmine_checklists 3.1.22
Updated by Pavel Rosický about 1 year ago
most likely you forgot to update your Gemfile
Updated by Guilherme Espindola about 1 year ago
Pavel Rosický wrote in #note-1:
most likely you forgot to update your Gemfile
I already did it!
bitnami@debian:/opt/bitnami/redmine$ bundle install
Unknown database adapter `{"adapter"=>"mysql2", "database"=>"bitnami_redmine", "host"=>"127.0.0.1", "username"=>"bn_redmine", "password"=>"77586cf2c43c18d1caaa5213d88ee15a9d04d508d5286276e0d8322698c5b304", "encoding"=>"utf8mb4", "port"=>"3306"}` found in config/database.yml, use Gemfile.local to load your own database gems
Unknown database adapter `{"adapter"=>"mysql2", "database"=>"bitnami_redmine", "host"=>"127.0.0.1", "username"=>"bn_redmine", "password"=>"77586cf2c43c18d1caaa5213d88ee15a9d04d508d5286276e0d8322698c5b304", "encoding"=>"utf8mb4", "port"=>"3306"}` found in config/database.yml, use Gemfile.local to load your own database gems
Bundle complete! 44 Gemfile dependencies, 78 gems now installed.
Gems in the groups 'development' and 'test' were not installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
bitnami@debian:/opt/bitnami/redmine$
Updated by Pavel Rosický about 1 year ago
well, these warnings give you some advice on what's wrong
Unknown database adapter `{"adapter"=>"mysql2"...
it seems your config/database.yml looks like this
production: adapter: adapter: mysql2 database: db host: localhost username: root password: "" encoding: utf8mb4
which is an invalid config, please double-check it against the example https://github.com/redmine/redmine/blob/master/config/database.yml.example
Updated by Guilherme Espindola about 1 year ago
Pavel Rosický wrote in #note-3:
well, these warnings give you some advice on what's wrong
Unknown database adapter `{"adapter"=>"mysql2"...it seems your config/database.yml looks like this
[...]which is an invalid config, please double-check it against the example https://github.com/redmine/redmine/blob/master/config/database.yml.example
Thanks Pavel!
Despite these adapter errors my redmine was working, just not deleting the issues.
I solved my problem adjusting a parameter in Gemfile file:
Was
- Include database gems for the adapters found in the database
- configuration file
require 'erb'
require 'yaml'
database_file = File.join(File.dirname(FILE), "config/database.yml")
if File.exist?(database_file)
yaml_config = ERB.new(IO.read(database_file)).result
database_config = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(yaml_config) : YAML.load(yaml_config)
adapters = database_config.values. filter {|c| c['adapter']}.uniq
if adapters.any?
adapters.each do |adapter|
case adapter
when 'mysql2'
gem "mysql2", "~> 0.5.0", :platforms => [:mri, :mingw, :x64_mingw]
gem "with_advisory_lock"
when /postgresql/
gem 'pg', '~> 1.5.3', :platforms => [:mri, :mingw, :x64_mingw]
when /sqlite3/
gem 'sqlite3', '~> 1.6.0', :platforms => [:mri, :mingw, :x64_mingw]
when /sqlserver/
gem "tiny_tds", "~> 2.1.2", :platforms => [:mri, :mingw, :x64_mingw]
gem "activerecord-sqlserver-adapter", "~> 6.1.0", :platforms => [:mri, :mingw, :x64_mingw]
else
warn("Unknown database adapter `#{adapter}` found in config/database.yml, use Gemfile.local to load your own database gems")
end
end
else
warn("No adapter found in config/database.yml, please configure it first")
end
else
Now
- Include database gems for the adapters found in the database
- configuration file
require 'erb'
require 'yaml'
database_file = File.join(File.dirname(FILE), "config/database.yml")
if File.exist?(database_file)
yaml_config = ERB.new(IO.read(database_file)).result
database_config = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(yaml_config) : YAML.load(yaml_config)
adapters = database_config.values. filter_map {|c| c['adapter']}.uniq
if adapters.any?
adapters.each do |adapter|
case adapter
when 'mysql2'
gem "mysql2", "~> 0.5.0", :platforms => [:mri, :mingw, :x64_mingw]
gem "with_advisory_lock"
when /postgresql/
gem 'pg', '~> 1.5.3', :platforms => [:mri, :mingw, :x64_mingw]
when /sqlite3/
gem 'sqlite3', '~> 1.6.0', :platforms => [:mri, :mingw, :x64_mingw]
when /sqlserver/
gem "tiny_tds", "~> 2.1.2", :platforms => [:mri, :mingw, :x64_mingw]
gem "activerecord-sqlserver-adapter", "~> 6.1.0", :platforms => [:mri, :mingw, :x64_mingw]
else
warn("Unknown database adapter `#{adapter}` found in config/database.yml, use Gemfile.local to load your own database gems")
end
end
else
warn("No adapter found in config/database.yml, please configure it first")
end
else
I did that "adjustment" because on my first redmine upgrade from 5.0.5 to 5.1.1 was not working due that "filter_map" parameter, and when I removed it my redmine worked. Now I had to remove and issues are being deleted again!
Updated by Guilherme Espindola about 1 year ago
Pavel Rosický wrote in #note-3:
well, these warnings give you some advice on what's wrong
Unknown database adapter `{"adapter"=>"mysql2"...it seems your config/database.yml looks like this
[...]which is an invalid config, please double-check it against the example https://github.com/redmine/redmine/blob/master/config/database.yml.example
My config/database.yml
root@debian:/opt/bitnami/redmine# cat config/database.yml
# Default setup is given for MySQL 5.7.7 or later.
# Examples for PostgreSQL, SQLite3 and SQL Server can be found at the end.
# Line indentation must be 2 spaces (no tabs).
production:
adapter: mysql2
database: bitnami_redmine
host: 127.0.0.1
username: bn_redmine
password: "77586cf2c43c18d1caaa5213d88ee15a9d04d508d5286276e0d8322698c5b304"
# Use "utf8" instead of "utfmb4" for MySQL prior to 5.7.7
encoding: utf8mb4
port: "3306"
root@debian:/opt/bitnami/redmine#
Updated by Pavel Rosický about 1 year ago
before an upgrade, you should check the software requirements https://redmine.org/projects/redmine/wiki/RedmineInstall#Requirements and if you have issues, revert your modifications first.
Ruby < 2.7 support has been dropped by Redmine #38134 a year ago (and it's EOL since 2022-04-12)
however, if someone tries to do it anyway, I agree that the error message shouldn't be about a missing method.
https://github.com/redmine/redmine/commit/0b6f4c6811a4a4e823674e3bb8b970ee46a9194b#diff-d09ea66f8227784ff4393d88a19836f321c915ae10031d16c93d67e6283ab55fR66
but it's probably too late to change it back...
Updated by Go MAEDA about 1 year ago
- Status changed from New to Closed
- Resolution set to Invalid
Thank you for your feedback.