0

I have a fairly standard setup where the application server is separated by a firewall from the database server. The application is using sqlalchemy and the db is postgres.

The system works fine for a few hours, but once it remains idle for a long period it appears that the communication fails between the server and the db. The error log is:

WARNI [sqlalchemy.pool.QueuePool.0x...7310] [worker 26] Error closing cursor: cursor already closed

I set up the connection pool with the 'pool_recylce' setting set to 30mins, so that there are no connections lingering for more than 30 mins. The problem persists.

any ideas?

Update: I have posted the same question on stackoverflow and got an answer that worked. Have a look at https://stackoverflow.com/questions/6592137/sqlalchemy-fails-to-connect-to-db-after-server-is-idle-for-a-few-hours

1
  • How exactly are you querying the database? Can you give an example of your code where you're querying? I.e., using SQLAlchemy's ORM, raw SQL, etc.?
    – Andrew M.
    Jul 11, 2011 at 3:45

1 Answer 1

0

I suggest to make sure that there are no active connections after half an hour of idling, e.g. with netstat -tpn. At least that will narrow down the problem to either (a) connections are still open so pool_recycle does not work as expected or (b) there are no open connections and the problem is elsewhere.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .