Possible to rollback session if a transaction fail #1034
Unanswered
kennywongck
asked this question in
Questions
Replies: 1 comment
-
This trick has worked for me: while session.in_transaction():
session.rollback() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
I try to save records in my fastapi application with the code snippet above, but when my application received a lot of concurrent request, looks like one of the session fail or hang and I got the error below which cause the whole database to fail
sqlalchemy.exc.PendingRollbackError: Can't reconnect until invalid transaction is rolled back. Please rollback() fully before proceeding (Background on this error at: https://sqlalche.me/e/20/8s2b)
Is it possible to do a session.rollback() in case a transaction fail or it is handle by sqlmodel already internally?
Operating System
Linux
Operating System Details
No response
SQLModel Version
sqlmodel==0.0.16
Python Version
python 3.11
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions