I’ve asked: How to break connections TCP/IP by keepalive postgreSQL without changing anything in the register?
And now, I want to confirm:
My system (C#.NET, NHibernate and Active Record) is running with a database PostgreSQL 8.4 and a Windows Server. I need a way to break idle or lost TCP/IP connections and unblock data.
I can’t tweak OS configs nor recompile the PostgreSQL. My system can run in Oracle 10g Express if needed! I need to know: Can I break idle conections without implement a new patch for PostgreSQL? Do I need to migrate my database to Oracle for that?
Thanks,
If there’s a way to force each new connection to execute a query at connect time, you could write a database function that dynamically calls “pg_terminate_backend(pid)” for any processes that are in some criteria. Without knowing your setup, some possibilities are:
Personally, I would try and refactor in order to minimize the amount of time any transaction can possibly be open. Some places where you may have a transaction open unnecessarily, resulting in an increased chance of triggering your problem: