Re: Keepalive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Jun 14, 2024, at 3:54 PM, Rui DeSousa <rui.desousa@xxxxxxxxxx> wrote:



On Jun 14, 2024, at 11:28 AM, Tom Lane <tgl@xxxxxxxxxxxxx> wrote:

Rui DeSousa <rui.desousa@xxxxxxxxxx> writes:
I have a very long running query that is not being terminated after a keep alive timeout event.  The situation is that the client drops from the network, the servers’ tcp/ip stack drops the connection, and the Postgres query continues to run without a network connection.  

The given system is running on Linux and I’m being told this is expected behavior; however, that is not has not been my experience.  My preferred platform to run Postgres on is FreeBSD and in cases like this the Postgres session is also terminated once the tcp/ip connection is dropped by the kernel.

Really?

I would expect the query to keep running until the backend tries to
perform some I/O to the client.  How quickly that happens would depend
a great deal on the details of the query, but not on which OS you're
running on.

regards, tom lane


I just tried the following spinner() function on FreeBSD and the keep alive timeout event cause both the network connection to be torn down along with the Postgres session -- as I would expect it to do.  I will try this exact function on the Linux system and see if I get different results and report back; however, I might not be able to test it out until next week.


create or replace function spinner()
returns void
as $$
declare
 _x bigint := 0;
begin
   loop
     _x := _x + 1;
   end loop;
end;
$$ language plpgsql
;




Actually, I just tested on it the Linux system.  The keep alive event occurred, the kernel state of the connection went to CLOSE_WAIT and then it was later completely removed from the kernel state; however, my spinner() function is still running with no network connection in the kernel table.

So, keep alive does behave differently between FreeBSD and Linux.  I really do prefer FreeBSD for many reasons.

-Rui.

[Index of Archives]     [Postgresql Home]     [Postgresql General]     [Postgresql Performance]     [Postgresql PHP]     [Postgresql Jobs]     [PHP Users]     [PHP Databases]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Forum]

  Powered by Linux