X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 63366475B84 for ; Sun, 9 Feb 2003 22:39:33 -0500 (EST) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 02985475AFF for ; Sun, 9 Feb 2003 22:39:33 -0500 (EST) Received: by news.hub.org (Postfix, from userid 8) id DFE4043A666; Sun, 9 Feb 2003 22:39:32 -0500 (EST) From: "Frankie Lam" X-Newsgroups: comp.databases.postgresql.sql Subject: Re: plpgsql + dblink() question Date: Mon, 10 Feb 2003 11:39:54 +0800 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 49 Message-ID: References: <3E449DAB.9050106@joeconway.com> X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 To: pgsql-sql@postgresql.org X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/183 X-Sequence-Number: 11581 Joe, thanks very much for your reply. However, the caller (function on Server 1) is still waiting for something to return endlessly. It seems to me that the connect_timeout option doesn't work. I've tried to set connect_timeout to 1, and it also has to wait for the function on Server 2 to complete. (Is this a bug?) Thanks very much for your help. Frankie Lam "Joe Conway" wrote in message news:3E449DAB.9050106@joeconway.com... > Frankie wrote: > > The case is when I call a function (from Server 1 at psql prompt) that will > > call dblink to do some operation > > on another server(it will take certain time), i.e. Server 2, and meanwhile I > > just unplug the network cable to Server 2. > > The consequence is that the function will never return except I plug the > > cable into it again, moreover I cannot even cancel > > the query and stop the postgresql server (have to 'kill -9'.) > > dblink just uses libpq to handle the communication, so you can use the > connect_timeout connection parameter. It defaults to infinite if not > explicitly set. Something like this should set a 5 second timeout: > > select * into tmp from dblink(''host=linux dbname=twins connect_timeout=5'', > ''select mysleep();'') as (retval text); > > See: > http://www.us.postgresql.org/users-lounge/docs/7.3/postgres/libpq-connect.ht ml > > HTH, > > Joe > > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster