pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rui DeSousa <rui.desousa@icloud.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-admin <pgsql-admin@postgresql.org>
Subject: Re: Keepalive
Date: Fri, 14 Jun 2024 15:54:38 -0400
Message-ID: <D52B3E92-EA77-4D2D-A39F-B21F65528208@icloud.com> (raw)
In-Reply-To: <2300378.1718378913@sss.pgh.pa.us>
References: <161042FE-FC86-456B-A8E1-AED38AE01820@icloud.com>
	<2300378.1718378913@sss.pgh.pa.us>



> On Jun 14, 2024, at 11:28 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> 
> Rui DeSousa <rui.desousa@icloud.com> 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
;

view thread (8+ messages)  latest in thread

Message-ID: <D52B3E92-EA77-4D2D-A39F-B21F65528208@icloud.com>
Permalink:  ../D52B3E92-EA77-4D2D-A39F-B21F65528208@icloud.com/
Also on:    postgresql.org/message-id/D52B3E92-EA77-4D2D-A39F-B21F65528208@icloud.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: rui.desousa@icloud.com, tgl@sss.pgh.pa.us
  Subject: Re: Keepalive
  In-Reply-To: <D52B3E92-EA77-4D2D-A39F-B21F65528208@icloud.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox