pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #5465: dblink TCP connection hangs blocking translation from being terminated
8+ messages / 6 participants
[nested] [flat]

* BUG #5465: dblink TCP connection hangs blocking translation from being terminated
@ 2010-05-19 09:10  Valentine Gogichashvili <valgog@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Valentine Gogichashvili @ 2010-05-19 09:10 UTC (permalink / raw)
  To: pgsql-bugs


The following bug has been logged online:

Bug reference:      5465
Logged by:          Valentine Gogichashvili
Email address:      valgog@gmail.com
PostgreSQL version: 8.2.1
Operating system:   Red Hat 3.4.6-3 (kernel 2.6.9-42.0.3.ELsmp)
Description:        dblink TCP connection hangs blocking translation from
being terminated
Details: 

Hi all, 

we have an issue on our productive server. A stored procedure, that uses
dblink to get some data from the remote database hangs not responding to
kill signal and holds several locks on some tables as well as an advisory
lock. So I have this transaction to be completed in order to have a
possibility to operate the database normally. 

It was exactly on the time, that the procedure was accessing remote
database, the machine hosting this remote database had a panic attack and
rebooted. But the ESTABLISHED connection is still hanging on the production
database machine: 

$ netstat | grep remote_db_host
tcp 0 0 production_db_host:60248 remote_db_host:postgres ESTABLISHED

$ lsof | grep remote_db_host
postgres 1365 postgres 199u IPv4 23003779784 TCP
production_db_host:60248->remote_db_host:postgres (ESTABLISHED)

On the database session list one can see the hanging transaction:

production_db=# select procpid, now() - query_start as running, waiting,
substr(current_query,1,120) as current_query from pg_stat_activity where
current_query not like '%----STATQ-----%' and current_query != '<IDLE>'
order by query_start desc;
 procpid |        running         | waiting |                               
                                 current_query
---------+------------------------+---------+-------------------------------
----------------------------------------------------------------------------
------------------------------------
    1365 | 2 days 00:17:57.992004 | f       | SELECT * FROM
get_remote_data()

It seems like the dblink is waiting for the connection to be closed or
reseted and also makes the hole transaction hang not processing kill
signals. 

Does the dblink TCP connection have any timeout? 

How would it be possible to shutdown the DB in case this session process is
not responding to normal kill signals? Will it hinder the database from
shutting down normally? My previous experience with issuing immediate stops
or killing with -9 had been quite catastrophic and I could not start the DB
afterwards. What would you suggest in this case?

With best regards, 

-- Valentine Gogichashvili



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: BUG #5465: dblink TCP connection hangs blocking translation from being terminated
@ 2010-05-19 15:17  Magnus Hagander <magnus@hagander.net>
  parent: Valentine Gogichashvili <valgog@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Magnus Hagander @ 2010-05-19 15:17 UTC (permalink / raw)
  To: Valentine Gogichashvili <valgog@gmail.com>; +Cc: pgsql-bugs

On Wed, May 19, 2010 at 5:10 AM, Valentine Gogichashvili
<valgog@gmail.com> wrote:
>
> The following bug has been logged online:
>
> Bug reference:      5465
> Logged by:          Valentine Gogichashvili
> Email address:      valgog@gmail.com
> PostgreSQL version: 8.2.1
> Operating system:   Red Hat 3.4.6-3 (kernel 2.6.9-42.0.3.ELsmp)
> Description:        dblink TCP connection hangs blocking translation from
> being terminated
> Details:
>
> Hi all,
>
> we have an issue on our productive server. A stored procedure, that uses
> dblink to get some data from the remote database hangs not responding to
> kill signal and holds several locks on some tables as well as an advisory
> lock. So I have this transaction to be completed in order to have a
> possibility to operate the database normally.

I believe this is a known issue in dblink, where it's not possible to
cancel it when it's waiting in the TCP layer in the kernel.
Unfortunately, there is no fix ATM - there was some work towards it
for 9.0 at one point, but I think this is actually the first real
bug-report on the issue...


> It seems like the dblink is waiting for the connection to be closed or
> reseted and also makes the hole transaction hang not processing kill
> signals.
>
> Does the dblink TCP connection have any timeout?

It does not. But it would detect a conneciton that goes away, so TCP
keepalives should be able to deal with this problem. Once the kernel
notices the other end is gone, dblink should notice it and roll back.


> How would it be possible to shutdown the DB in case this session process is
> not responding to normal kill signals? Will it hinder the database from
> shutting down normally? My previous experience with issuing immediate stops
> or killing with -9 had been quite catastrophic and I could not start the DB
> afterwards. What would you suggest in this case?

kill -9 on a client will make the postmaster restart the whole
process, so yes, it's a very heavy operation.

-- 
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: BUG #5465: dblink TCP connection hangs blocking 	translation from being terminated
@ 2010-05-19 18:41  Joseph Conway <mail@joeconway.com>
  parent: Magnus Hagander <magnus@hagander.net>
  0 siblings, 1 reply; 8+ messages in thread

From: Joseph Conway @ 2010-05-19 18:41 UTC (permalink / raw)
  To: Magnus Hagander <magnus@hagander.net>; +Cc: Valentine Gogichashvili <valgog@gmail.com>; pgsql-bugs

Magnus Hagander wrote:
> On Wed, May 19, 2010 at 5:10 AM, Valentine Gogichashvili
> <valgog@gmail.com> wrote:
>> The following bug has been logged online:
>>
>> Bug reference:      5465
>> Logged by:          Valentine Gogichashvili
>> Email address:      valgog@gmail.com
>> PostgreSQL version: 8.2.1
>> Operating system:   Red Hat 3.4.6-3 (kernel 2.6.9-42.0.3.ELsmp)
>> Description:        dblink TCP connection hangs blocking translation from
>> being terminated
>> Details:
>>
>> Hi all,
>>
>> we have an issue on our productive server. A stored procedure, that uses
>> dblink to get some data from the remote database hangs not responding to
>> kill signal and holds several locks on some tables as well as an advisory
>> lock. So I have this transaction to be completed in order to have a
>> possibility to operate the database normally.
> 
> I believe this is a known issue in dblink, where it's not possible to
> cancel it when it's waiting in the TCP layer in the kernel.
> Unfortunately, there is no fix ATM - there was some work towards it
> for 9.0 at one point, but I think this is actually the first real
> bug-report on the issue...

I thought the known issue was only on Windows though...
Note that this is not dblink specific but rather libpq.

>> How would it be possible to shutdown the DB in case this session process is
>> not responding to normal kill signals? Will it hinder the database from
>> shutting down normally? My previous experience with issuing immediate stops
>> or killing with -9 had been quite catastrophic and I could not start the DB
>> afterwards. What would you suggest in this case?
> 
> kill -9 on a client will make the postmaster restart the whole
> process, so yes, it's a very heavy operation.

Can you grab the process with gdb and call elog() manually?

Joe




^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: BUG #5465: dblink TCP connection hangs blocking translation from being terminated
@ 2010-05-21 07:45  valgog <valgog@gmail.com>
  parent: Joseph Conway <mail@joeconway.com>
  0 siblings, 1 reply; 8+ messages in thread

From: valgog @ 2010-05-21 07:45 UTC (permalink / raw)
  To: pgsql-bugs

On May 19, 8:41 pm, m...@joeconway.com (Joseph Conway) wrote:
> Magnus Hagander wrote:
> > On Wed, May 19, 2010 at 5:10 AM, Valentine Gogichashvili
> > <val...@gmail.com> wrote:
> >> The following bug has been logged online:
>
> >> Bug reference:      5465
> >> Logged by:          Valentine Gogichashvili
> >> Email address:      val...@gmail.com
> >> PostgreSQL version: 8.2.1
> >> Operating system:   Red Hat 3.4.6-3 (kernel 2.6.9-42.0.3.ELsmp)
> >> Description:        dblink TCP connection hangs blocking translation from
> >> being terminated
> >> Details:
>
> >> Hi all,
>
> >> we have an issue on our productive server. A stored procedure, that uses
> >> dblink to get some data from the remote database hangs not responding to
> >> kill signal and holds several locks on some tables as well as an advisory
> >> lock. So I have this transaction to be completed in order to have a
> >> possibility to operate the database normally.
>
> > I believe this is a known issue in dblink, where it's not possible to
> > cancel it when it's waiting in the TCP layer in the kernel.
> > Unfortunately, there is no fix ATM - there was some work towards it
> > for 9.0 at one point, but I think this is actually the first real
> > bug-report on the issue...
>
> I thought the known issue was only on Windows though...
> Note that this is not dblink specific but rather libpq.
>
> >> How would it be possible to shutdown the DB in case this session process is
> >> not responding to normal kill signals? Will it hinder the database from
> >> shutting down normally? My previous experience with issuing immediate stops
> >> or killing with -9 had been quite catastrophic and I could not start the DB
> >> afterwards. What would you suggest in this case?
>
> > kill -9 on a client will make the postmaster restart the whole
> > process, so yes, it's a very heavy operation.
>
> Can you grab the process with gdb and call elog() manually?
>
> Joe
>
> --
> Sent via pgsql-bugs mailing list (pgsql-b...@postgresql.org)
> To make changes to your subscription:http://www.postgresql.org/mailpref/pgsql-bugs

Unfortunately I could not install gdb on that machine :-( some
dependencies are not installable and I cannot upgrade that production
machine...

-- Valentine



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: BUG #5465: dblink TCP connection hangs blocking transaction from being terminated
@ 2010-05-21 07:48  valgog <valgog@gmail.com>
  parent: valgog <valgog@gmail.com>
  0 siblings, 0 replies; 8+ messages in thread

From: valgog @ 2010-05-21 07:48 UTC (permalink / raw)
  To: pgsql-bugs

Oh, found an type in the subject. Transaction, not Translation.




^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* BUG #5465: dblink TCP connection hangs blocking translation from being terminated
@ 2014-03-14 08:30  Robert Voinea <rvoinea@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Robert Voinea @ 2014-03-14 08:30 UTC (permalink / raw)
  To: pgsql-bugs

Hi

In our setup, we make use extensively of dblink.
Due to the fact that some queries take some time to complete and that the link 
is over the internet, sometime the server process (the transaction that runs 
the dblink queries) hangs when the link goes down, keeping locks on several 
records plus some advisory locks and thus freezing the whole (most of) the 
database.

What I have found is this bug, that is remarkably similar (if not identical) 
with what we are experiencing.

http://postgresql.1045698.n5.nabble.com/BUG-5465-dblink-TCP-connection-hangs-blocking-translation-fr...

The bug dates from may 2010 and no update since.

One of the comments states that there is work done for version 9.0 ...but I  
haven't seen anything in the changelog related to this in any version starting 
with the one we are using (9.1.12).

<quote>
I believe this is a known issue in dblink, where it's not possible to 
cancel it when it's waiting in the TCP layer in the kernel. 
Unfortunately, there is no fix ATM - there was some work towards it 
for 9.0 at one point, but I think this is actually the first real 
bug-report on the issue... 
</quote>

Has there been any progress in this direction?

Thank you!

-- 
Robert Voinea
Software Engineer
+4 0740 467 262

Don't take life too seriously. You'll never get out of it alive.
(Elbert Hubbard)




-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: BUG #5465: dblink TCP connection hangs blocking translation from being terminated
@ 2014-03-14 13:45  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Robert Voinea <rvoinea@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Tom Lane @ 2014-03-14 13:45 UTC (permalink / raw)
  To: Robert Voinea <rvoinea@gmail.com>; +Cc: pgsql-bugs

Robert Voinea <rvoinea@gmail.com> writes:
> In our setup, we make use extensively of dblink.
> Due to the fact that some queries take some time to complete and that the link 
> is over the internet, sometime the server process (the transaction that runs 
> the dblink queries) hangs when the link goes down, keeping locks on several 
> records plus some advisory locks and thus freezing the whole (most of) the 
> database.

> What I have found is this bug, that is remarkably similar (if not identical) 
> with what we are experiencing.
> http://postgresql.1045698.n5.nabble.com/BUG-5465-dblink-TCP-connection-hangs-blocking-translation-fr...

That does not sound like a Postgres bug to me.  What you are unhappy about
is that the kernel isn't timing out a lost TCP connection more quickly.
The default timeout is long (>1 hour probably), but that's required by
Internet standards.  The appropriate fix for this is to use aggressive
keepalive parameters on the connection.  You can set libpq's keepalive
parameters in the connection string given to dblink.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: BUG #5465: dblink TCP connection hangs blocking translation from being terminated
@ 2014-03-17 11:09  Robert Voinea <rvoinea@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 8+ messages in thread

From: Robert Voinea @ 2014-03-17 11:09 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs

Hi

On Friday 14 March 2014 09:45:22 Tom Lane wrote:
> Robert Voinea <rvoinea@gmail.com> writes:
> > In our setup, we make use extensively of dblink.
> > Due to the fact that some queries take some time to complete and that the
> > link is over the internet, sometime the server process (the transaction
> > that runs the dblink queries) hangs when the link goes down, keeping
> > locks on several records plus some advisory locks and thus freezing the
> > whole (most of) the database.
> > 
> > What I have found is this bug, that is remarkably similar (if not
> > identical) with what we are experiencing.
> > http://postgresql.1045698.n5.nabble.com/BUG-5465-dblink-TCP-connection-han
> > gs-blocking-translation-from-being-terminated-td2132419.html#a2132420
> That does not sound like a Postgres bug to me.  What you are unhappy about
> is that the kernel isn't timing out a lost TCP connection more quickly.
> The default timeout is long (>1 hour probably), but that's required by
> Internet standards.  The appropriate fix for this is to use aggressive
> keepalive parameters on the connection.  You can set libpq's keepalive
> parameters in the connection string given to dblink.
> 
> 			regards, tom lane

I seem to have missed those parameters... and the fact that you actually need 
keep-alive on both client AND server, not only on the server.

Thank you!

-- 
Robert Voinea
Software Engineer
+4 0740 467 262

Don't take life too seriously. You'll never get out of it alive.
(Elbert Hubbard)




-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2014-03-17 11:09 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-05-19 09:10 BUG #5465: dblink TCP connection hangs blocking translation from being terminated Valentine Gogichashvili <valgog@gmail.com>
2010-05-19 15:17 ` Magnus Hagander <magnus@hagander.net>
2010-05-19 18:41   ` Re: BUG #5465: dblink TCP connection hangs blocking 	translation from being terminated Joseph Conway <mail@joeconway.com>
2010-05-21 07:45     ` valgog <valgog@gmail.com>
2010-05-21 07:48       ` Re: BUG #5465: dblink TCP connection hangs blocking transaction from being terminated valgog <valgog@gmail.com>
2014-03-14 08:30 BUG #5465: dblink TCP connection hangs blocking translation from being terminated Robert Voinea <rvoinea@gmail.com>
2014-03-14 13:45 ` Tom Lane <tgl@sss.pgh.pa.us>
2014-03-17 11:09   ` Robert Voinea <rvoinea@gmail.com>

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