@@ -882,9 +882,13 @@ def teardown
882
882
end
883
883
884
884
test "#execute is retryable" do
885
- kill_connection_from_server
885
+ initial_connection_id = connection_id_from_server
886
+
887
+ kill_connection_from_server ( initial_connection_id )
886
888
887
889
@connection . execute ( "SELECT 1" , allow_retry : true )
890
+
891
+ assert_not_equal initial_connection_id , connection_id_from_server
888
892
end
889
893
890
894
test "disconnect and recover on #configure_connection failure" do
@@ -975,14 +979,23 @@ def remote_disconnect(connection)
975
979
end
976
980
end
977
981
978
- def kill_connection_from_server
982
+ def connection_id_from_server
983
+ case @connection . adapter_name
984
+ when "Mysql2" , "Trilogy"
985
+ @connection . execute ( "SELECT CONNECTION_ID()" ) . to_a [ 0 ] [ 0 ]
986
+ when "PostgreSQL"
987
+ @connection . execute ( "SELECT pg_backend_pid()" ) . to_a [ 0 ] [ "pg_backend_pid" ]
988
+ else
989
+ skip ( "connection_id_from_server unsupported" )
990
+ end
991
+ end
992
+
993
+ def kill_connection_from_server ( connection_id )
979
994
conn = @connection . pool . checkout
980
995
case conn . adapter_name
981
996
when "Mysql2" , "Trilogy"
982
- connection_id = @connection . execute ( "SELECT CONNECTION_ID()" ) . to_a [ 0 ] [ 0 ]
983
997
conn . execute ( "KILL #{ connection_id } " )
984
998
when "PostgreSQL"
985
- connection_id = @connection . execute ( "SELECT pg_backend_pid()" ) . to_a [ 0 ] [ "pg_backend_pid" ]
986
999
conn . execute ( "SELECT pg_terminate_backend(#{ connection_id } )" )
987
1000
else
988
1001
skip ( "kill_connection_from_server unsupported" )
0 commit comments