Lists: | pgsql-bugs |
---|
From: | Tatsuhito Kasahara <kasahara(dot)tatsuhito(at)oss(dot)ntt(dot)co(dot)jp> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | dblink generates orphaned connections |
Date: | 2009-09-09 05:35:37 |
Message-ID: | 4AA73EA9.5070203@oss.ntt.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
Hi.
dblink generates orphaned connections when we failed on performing dblink() function.
# But it occurs only when dblink('conn_str', 'sql', true). See following examples.
==============================================================================
$ pslq local
local=# SELECT datname, procpid, current_query FROM pg_stat_activity
WHERE pg_backend_pid() <> procpid;
datname | procpid | current_query
---------+---------+---------------
(0 rows)
local=# SELECT * FROM dblink('dbname=remote', 'SELECT * FROM no_exist') AS t1 (aid bigint);
ERROR: relation "no_exist" does not exist
CONTEXT: Error occurred on dblink connection named "unnamed": could not execute query.
local=# SELECT datname, procpid, current_query FROM pg_stat_activity
WHERE pg_backend_pid() <> procpid;
datname | procpid | current_query
---------+---------+---------------
remote | 29620 | <IDLE>
(1 row)
local=# SELECT * FROM dblink('dbname=remote', 'SELECT * FROM no_exist') AS t1 (aid bigint);
ERROR: relation "no_exist" does not exist
CONTEXT: Error occurred on dblink connection named "unnamed": could not execute query.
local=# SELECT datname, procpid, current_query FROM pg_stat_activity
WHERE pg_backend_pid() <> procpid;
datname | procpid | current_query
---------+---------+---------------
remote | 29620 | <IDLE>
remote | 29630 | <IDLE>
(2 rows)
==============================================================================
I think that the dblink should not ereport() before PQfinish(conn) in
dblink_record_internal() when we use temporary connection.
Attached the brief patch to avoid above problem.
Best regards,
--
Tatsuhito Kasahara
kasahara(dot)tatsuhito(at)oss(dot)ntt(dot)co(dot)jp
Attachment | Content-Type | Size |
---|---|---|
dblink.c.path | text/plain | 761 bytes |
From: | Joe Conway <mail(at)joeconway(dot)com> |
---|---|
To: | Tatsuhito Kasahara <kasahara(dot)tatsuhito(at)oss(dot)ntt(dot)co(dot)jp> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: dblink generates orphaned connections |
Date: | 2009-09-12 23:22:32 |
Message-ID: | 4AAC2D38.4020306@joeconway.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
Tatsuhito Kasahara wrote:
> dblink generates orphaned connections when we failed on performing dblink() function.
> # But it occurs only when dblink('conn_str', 'sql', true). See following examples.
> I think that the dblink should not ereport() before PQfinish(conn) in
> dblink_record_internal() when we use temporary connection.
Thanks for the report. Patch applied to HEAD and 8.4 branch. Problem
introduced in 8.4
Joe