Closed blueyed closed 1 year ago
This traceback shows error happens when django are acquiring database connection while database connection pool was empty. this means this is the first time to try connecting to your database,
I don't think it is a good idea to retry connecting by django-db-connection-pool or SQLAlchemy while pool is still empty, you should catch OperationalErrors in your code.
PS: Assume after invoking creator (dj_db_conn_pool.core.mixins.PooledDatabaseWrapperMixin._get_new_connection), SQLAlchemy receives dbapi connection successfully, If django requires database connection again, SQLAlchemy will try to get a DBAPI connection from the pool, if this connection was abnormal, SQLAlchemy will make three attempts to re-connect to database.
I don't think it is a good idea to retry connecting by django-db-connection-pool or SQLAlchemy while pool is still empty, you should catch OperationalErrors in your code.
Ok. While there still might be a transitional error in this case (so that it might help to retry), it is not that much an issue then.
Thanks for the additional explanation!
Well, after all it happens with every new connection, not just the first one / if the pool is empty, doesn't it?
Well, after all it happens with every new connection, not just the first one / if the pool is empty, doesn't it?
"pool is empty" has two states:
while "pool is empty", If the limit of pool is not exceeded, SQLAlchemy will make a new connection.
I am seeing sporadic errors when trying to get a new connection on Google Cloud Run with PostgreSQL, and wondered what you think about a patch to re-try in case of those when acquiring a new connection.
Those are OperationalErrors, e.g.:
Traceback: