Giter Club home page Giter Club logo

Comments (4)

altairbow avatar altairbow commented on June 12, 2024

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.

from django-db-connection-pool.

blueyed avatar blueyed commented on June 12, 2024

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!

from django-db-connection-pool.

blueyed avatar blueyed commented on June 12, 2024

Well, after all it happens with every new connection, not just the first one / if the pool is empty, doesn't it?

from django-db-connection-pool.

altairbow avatar altairbow commented on June 12, 2024

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:

  1. no connections has been checked-out from pool, in this case, the pool has just been created, it's empty
  2. all connections in the pool has been checked-out, the pool is also empty

while "pool is empty", If the limit of pool is not exceeded, SQLAlchemy will make a new connection.

  • SQLAlchemy doesn't retry if new connection fails: code
  • SQLAlchemy checks connection got from pool, if connection is abnormal, three reconnection attempts will be made at maximum: code

from django-db-connection-pool.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.