is not running (:ticket:`#962`).
- Make sure that the notifies callback is called during the use of the
`~Connection.notifies()` generator (:ticket:`#972`).
-- Raise `~errors.IdleInTransactionSessionTimeout` instead of a generic
- `OperationalError` upon hitting an idle-in-transaction timeout
+- Raise the correct error returned by the database (such as `!AdminShutdown`
+ or `!IdleInTransactionSessionTimeout`) instead of a generic
+ `OperationalError` when a server error causes a client disconnection
(:ticket:`#988`).
assert conninfo_to_dict(got) == {"host": "foo.com", "hostaddr": "1.1.1.1"}
-@pytest.mark.slow
+@pytest.mark.crdb_skip("pg_terminate_backend")
def test_right_exception_on_server_disconnect(conn):
+ with pytest.raises(e.AdminShutdown):
+ conn.execute("select pg_terminate_backend(%s)", [conn.pgconn.backend_pid])
+
+
+@pytest.mark.slow
+def test_right_exception_on_session_timeout(conn):
conn.execute("SET SESSION idle_in_transaction_session_timeout = 100")
sleep(0.2)
with pytest.raises(e.IdleInTransactionSessionTimeout):
assert conninfo_to_dict(got) == {"host": "foo.com", "hostaddr": "1.1.1.1"}
-@pytest.mark.slow
+@pytest.mark.crdb_skip("pg_terminate_backend")
async def test_right_exception_on_server_disconnect(aconn):
+ with pytest.raises(e.AdminShutdown):
+ await aconn.execute(
+ "select pg_terminate_backend(%s)", [aconn.pgconn.backend_pid]
+ )
+
+
+@pytest.mark.slow
+async def test_right_exception_on_session_timeout(aconn):
await aconn.execute("SET SESSION idle_in_transaction_session_timeout = 100")
await asleep(0.2)
with pytest.raises(e.IdleInTransactionSessionTimeout):