Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ jobs:
- '7_1'
- '7_2'
- '8_0'
- '8_1'
- 'latest'
mysql-version:
- '8.0'
exclude:
# Exclude conditions that don't meat the minimal requirement
- ruby-version: '3.1'
activerecord-version: '8_0'
- ruby-version: '3.1'
activerecord-version: '8_1'

# Exclude duplicate conditions
- ruby-version: '3.1'
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/activerecord_8_1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eval_gemfile("../Gemfile")
gem "activerecord", "~> 8.1.0"
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,22 @@ def cause_deadlock(role:)

context "when the user doesn't have the permission to execute 'SHOW ENGINE INNODB STATUS'" do
it "displays an error message" do
expect {
ActiveRecord::Base.connected_to(role: :reading) do
cause_deadlock(role: :reading)
end
}.to raise_error(ActiveRecord::Deadlocked)
expect(log.string).to include("Failed to execute")
# In ActiveRecord 8.1+, replica connections cannot execute lock queries,
# so it raises ActiveRecord::ReadOnlyError instead of ActiveRecord::Deadlocked.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand why this test fails since 8.1.,0 but I'm not sure how this test should be. Although the current approach passes tests, it looks like a workaround.

if ActiveRecord.version >= Gem::Version.new("8.1")
expect {
ActiveRecord::Base.connected_to(role: :reading) do
cause_deadlock(role: :reading)
end
}.to raise_error(ActiveRecord::ReadOnlyError)
else
expect {
ActiveRecord::Base.connected_to(role: :reading) do
cause_deadlock(role: :reading)
end
}.to raise_error(ActiveRecord::Deadlocked)
expect(log.string).to include("Failed to execute")
end
end
end
end
Expand Down