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.tatsuhito@oss.ntt.co.jp

Search Discussions

  • Joe Conway at Sep 12, 2009 at 11:22 pm

    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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-bugs @
categoriespostgresql
postedSep 9, '09 at 5:57a
activeSep 12, '09 at 11:22p
posts2
users2
websitepostgresql.org
irc#postgresql

2 users in discussion

Joe Conway: 1 post Tatsuhito Kasahara: 1 post

People

Translate

site design / logo © 2021 Grokbase