tortoise / tortoise/tortoise-orm
Could not receive data from client: Connection reset by peer
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
My Production system:
FAST API + TORTOISE ORM + AWS AURORA POSTGRES + GUNICORN(UVICORN WORKER)
This error message is very frequent in our db logs. There is nothing in logs in server side and as far No connection drops too on server side But this error log in db side is worrying. Same system but with actual postgres and very less load does not show this error on db side at all.
My code Snippet
@app.on_event("startup")
async def init():
await Tortoise.init(
db_url="postgres://postgres:"
+ str(PASSWORD)
+ "@"
+ str(HOST)
+ ":"
+ str(PORT)
+ "/"
+ str(DATABASE),
modules={'models': ["__main__"],
}
)
await Tortoise.generate_schemas()
@app.on_event("shutdown")
async def shutdown_event():
await Tortoise.close_connections()
We start the project using supervisor with command
command=/home/ubuntu/env/bin/gunicorn -w 7 -k uvicorn.workers.UvicornWorker main:app
We have neither configured any setting in project nor db other than default.
This Project is REST API microservice of bigger system where other microservices are using Django orm.
Other Django microservice does not raise the same issue as mentioned.
As I am new to Tortoise orm , so pardon me for any silly mistake in my code or my bug report.
Any Help or Guide to solve this issue will be helpful.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the FastAPI startup and shutdown handlers that call Tortoise.init, Tortoise.generate_schemas, and Tortoise.close_connections, then review the Gunicorn command using seven Uvicorn workers. Compare the Aurora PostgreSQL database logs with the application and supervisor logs under load. Done means identifying a reproducible cause for the connection resets and documenting a verified configuration or code change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, fastapi, postgresql, python
- Domain
- api, backend, databases
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100