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

Dimitris
  • 656
  • 5
  • 6
  • 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 '11 at 03:45

1 Answers1

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.

Aleh
  • 121
  • 2