On production, my Flask / SQLAlchemy app randomly throws psycopg2.OperationalError: server closed the connection unexpectedly on RDS Aurora. Until I track down the issue, I would like my unit tests to ensure that I handle this properly, e.g. that my rollback mechanism is effective, etc.
Right now, I mock the Session.commit method to throw a fake exception, but this does not (afaik?) leave the session in a failed state that needs actual rollback.
What are some reliable ways to simulate an actual connection failure in my local, Docker Compose-based development environment?