File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed
spec/activerecord/debug_errors/ext/connection_adapters Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -58,12 +58,22 @@ def cause_deadlock(role:)
5858
5959 context "when the user doesn't have the permission to execute 'SHOW ENGINE INNODB STATUS'" do
6060 it "displays an error message" do
61- expect {
62- ActiveRecord ::Base . connected_to ( role : :reading ) do
63- cause_deadlock ( role : :reading )
64- end
65- } . to raise_error ( ActiveRecord ::Deadlocked )
66- expect ( log . string ) . to include ( "Failed to execute" )
61+ # In ActiveRecord 8.1+, replica connections cannot execute lock queries,
62+ # so it raises ActiveRecord::ReadOnlyError instead of ActiveRecord::Deadlocked.
63+ if ActiveRecord . version >= Gem ::Version . new ( "8.1" )
64+ expect {
65+ ActiveRecord ::Base . connected_to ( role : :reading ) do
66+ cause_deadlock ( role : :reading )
67+ end
68+ } . to raise_error ( ActiveRecord ::ReadOnlyError )
69+ else
70+ expect {
71+ ActiveRecord ::Base . connected_to ( role : :reading ) do
72+ cause_deadlock ( role : :reading )
73+ end
74+ } . to raise_error ( ActiveRecord ::Deadlocked )
75+ expect ( log . string ) . to include ( "Failed to execute" )
76+ end
6777 end
6878 end
6979 end
You can’t perform that action at this time.
0 commit comments