@@ -882,18 +882,7 @@ def teardown
882
882
end
883
883
884
884
test "#execute is retryable" do
885
- conn_id = case @connection . adapter_name
886
- when "Mysql2"
887
- @connection . execute ( "SELECT CONNECTION_ID()" ) . to_a [ 0 ] [ 0 ]
888
- when "Trilogy"
889
- @connection . execute ( "SELECT CONNECTION_ID() as connection_id" ) . to_a [ 0 ] [ 0 ]
890
- when "PostgreSQL"
891
- @connection . execute ( "SELECT pg_backend_pid()" ) . to_a [ 0 ] [ "pg_backend_pid" ]
892
- else
893
- skip ( "kill_connection_from_server unsupported" )
894
- end
895
-
896
- kill_connection_from_server ( conn_id )
885
+ kill_connection_from_server
897
886
898
887
@connection . execute ( "SELECT 1" , allow_retry : true )
899
888
end
@@ -964,7 +953,7 @@ def raw_transaction_open?(connection)
964
953
true
965
954
end
966
955
else
967
- skip ( "kill_connection_from_server unsupported" )
956
+ skip ( "raw_transaction_open? unsupported" )
968
957
end
969
958
end
970
959
@@ -986,13 +975,15 @@ def remote_disconnect(connection)
986
975
end
987
976
end
988
977
989
- def kill_connection_from_server ( connection_id )
978
+ def kill_connection_from_server
990
979
conn = @connection . pool . checkout
991
980
case conn . adapter_name
992
981
when "Mysql2" , "Trilogy"
982
+ connection_id = @connection . execute ( "SELECT CONNECTION_ID()" ) . to_a [ 0 ] [ 0 ]
993
983
conn . execute ( "KILL #{ connection_id } " )
994
984
when "PostgreSQL"
995
- conn . execute ( "SELECT pg_cancel_backend(#{ connection_id } )" )
985
+ connection_id = @connection . execute ( "SELECT pg_backend_pid()" ) . to_a [ 0 ] [ "pg_backend_pid" ]
986
+ conn . execute ( "SELECT pg_terminate_backend(#{ connection_id } )" )
996
987
else
997
988
skip ( "kill_connection_from_server unsupported" )
998
989
end
0 commit comments