GOAL — To deal with db connection issues that are fluctuating .
what if we don’t retry transient connection errors and how does retries in a regulated way help ? —
A request that was about to complete may fail , similarly many other requests like this. So they were using connection but minor fluctuations caused full failure , so now client has to retry again fully . SOLUTION : Retries help to try atomic db units of work —> implies less failures —> better concurrency and resource usage Even full endpoint retries are good as we still prevent high client to server calls .
Your code
↓
SQLAlchemy AsyncSession
↓
SQLAlchemy Engine
↓
DBAPI driver (e.g. asyncpg)
↓
TCP connection to DB
For retries at endpoint level or sub-functions inside endpoints where auth has already been established.
Auth tokens — are for entering a request , they may expire while request is being processed and that’s okay . We may do some duration check of expiry for very long running bg tasks .
can we retry at sub-functions level and is it better to retry at subfunctions level ?