Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T6K9m-0004PS-U9 for pgsql-bugs@postgresql.org; Tue, 28 Aug 2012 11:40:31 +0000 Received: from mail-vc0-f174.google.com ([209.85.220.174]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T6K9i-0005uv-MN for pgsql-bugs@postgresql.org; Tue, 28 Aug 2012 11:40:29 +0000 Received: by vcbfk26 with SMTP id fk26so5660250vcb.19 for ; Tue, 28 Aug 2012 04:40:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=rfbEcrE/4/7e8WxCyCHPvWOZIKuQFib4hZ8Amc5XhDQ=; b=otvjPfPJyTe237J2Rcok9P+LNZ9S22KIqt/oXm4uu8m0p+/E2E5jIzPAh5isp0Pgm0 MVwEmOp0UVLMYPpcLWFrj775C+dgjDB1PnHrow38jXYJ/WU441iborQhfCrw1PRayUOP QH8sTFrTAyQ1CkHroH2ldfKFlX9xuFVWSfxEXfq79u5ufe6BVro3yP7EfrWl5vMVkpFH P3jKTDZNacR/pcKdBMyrpkiOxLe07eGl0v5+0eml3U6xdXKLBStv46GCIUQwBY2Klv7j xM801Do/10aTnKOLVMKmUr2oDyA2l7ZKiWGp6uNn4uw++SSov1xKwFJ4WnJIwpPtF3fG 8OKQ== Received: by 10.52.38.168 with SMTP id h8mr12019638vdk.93.1346154025274; Tue, 28 Aug 2012 04:40:25 -0700 (PDT) Received: from llserver.lakeliving.com (ool-18bbd2c6.static.optonline.net. [24.187.210.198]) by mx.google.com with ESMTPS id wc15sm449380vdb.4.2012.08.28.04.40.10 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 28 Aug 2012 04:40:11 -0700 (PDT) Date: Tue, 28 Aug 2012 07:40:07 -0400 From: Ryan Kelly To: Tom Lane Cc: Bruce Momjian , pgsql-bugs@postgresql.org Subject: Re: [PATCH] Prevent hanging on unreachable hosts on startup Message-ID: <20120828114007.GA31047@llserver.lakeliving.com> References: <20120105011730.GA26760@llserver.lakeliving.com> <3741.1325731017@sss.pgh.pa.us> <20120105142355.GB26760@llserver.lakeliving.com> <20120827032741.GE28780@momjian.us> <14892.1346117688@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <14892.1346117688@sss.pgh.pa.us> User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -2.5 (--) X-Archive-Number: 201208/213 X-Sequence-Number: 33937 On Mon, Aug 27, 2012 at 09:34:48PM -0400, Tom Lane wrote: > Bruce Momjian writes: > > Tom, can you comment on this patch because you commented on the previous > > version? Thanks. > > Doesn't that provoke a pile of compiler warnings about local variables > potentially being altered during longjmp? It sure looks pretty unsafe > from here. It also fails to print any error message if a connection > attempt is canceled. > > A bigger-picture question is just how safe it is to longjmp out of libpq > partway through a connection attempt. At the very least, that's likely > to leak an open socket and some memory. Maybe that doesn't matter too > much for psql, but I'm not convinced. It seems fairly likely that > internal state for libc (malloc), openssl, etc, could be left in a > corrupt state if the interrupt happens at just the wrong time. (This > didn't matter so much for the original proposal, where we'd just have > been exiting psql anyway on failure. But if it's in \c then we want > psql to still be operational after a failure.) > > We could perhaps dodge the longjmp safety question by using a > PQconnectStartParams/PQconnectPoll loop. I'm not sure that provides > 100% the same functionality --- in particular, I think it wouldn't allow > interrupting out of a DNS name resolution delay. But it'd be less > likely to result in strange crashes. > > regards, tom lane The latest on this patch can be found here: http://archives.postgresql.org/message-id/500151C4.5010509@enterprisedb.com -Ryan Kelly