Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id B477D53F45 for ; Thu, 5 Jan 2012 10:24:17 -0400 (AST) Received: from mail-qw0-f53.google.com ([209.85.216.53]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RioEq-0001Gx-Lr for pgsql-bugs@postgresql.org; Thu, 05 Jan 2012 14:24:17 +0000 Received: by qadb15 with SMTP id b15so374584qad.19 for ; Thu, 05 Jan 2012 06:24:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=ldGiCNKyum5YI5KyOLDMsw5EI3A3Fa3CdrfCEUV8FIk=; b=mdVHf/9ezbaXh+MVLTFtNxhJ6+Vx1uaLoF/fOFH0S3cZgtEimbJfet2WI977MK3wmg MKa4jg9g3IwAy+dRCKJyrbYbZ3vM4YN8O+qrx1Gw1PUrJTahkYm9YE1sqcjTO4teNMPD qkqr5ROpyD4NwgQfK7egJsQfZGoG0Bo3ObYwU= Received: by 10.224.211.198 with SMTP id gp6mr3086870qab.48.1325773444314; Thu, 05 Jan 2012 06:24:04 -0800 (PST) Received: from llserver.lakeliving.com (ool-18bbd2c6.static.optonline.net. [24.187.210.198]) by mx.google.com with ESMTPS id v5sm43697135qao.21.2012.01.05.06.23.58 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Jan 2012 06:24:02 -0800 (PST) Date: Thu, 5 Jan 2012 09:23:55 -0500 From: Ryan Kelly To: Tom Lane Cc: pgsql-bugs@postgresql.org Subject: Re: [PATCH] Prevent hanging on unreachable hosts on startup Message-ID: <20120105142355.GB26760@llserver.lakeliving.com> References: <20120105011730.GA26760@llserver.lakeliving.com> <3741.1325731017@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="J/dobhs11T7y2rNN" Content-Disposition: inline In-Reply-To: <3741.1325731017@sss.pgh.pa.us> User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -2.3 (--) X-Archive-Number: 201201/36 X-Sequence-Number: 32103 --J/dobhs11T7y2rNN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Jan 04, 2012 at 09:36:57PM -0500, Tom Lane wrote: > "Ryan P. Kelly" writes: > > The signal handler installed by setup_cancel_handler() will ignore > > attempts to exit psql should a host be unreachable. > > Hm. That may be worth doing something about, but the proposed patch > seems more like a quick-and-dirty hack than a solution. The main > thing I don't like about it is that if we care about this scenario > during initial startup, we should also care about it during a \c > command, but just delaying the installation of the signal handler > won't fix that case. Sure, but do you still think moving the signal handler down is correct? I've attached another patch that handles interrupting \c. I also noticed there appears to be what looks like duplication of code in startup.c and command.c in main() and do_connect() respectively. I'm wondering if I they should be made to share the same code which (with my patch) would then mean the signal handler could be left where it was. > More generally, what if the server becomes unreachable mid-session? > I'm not sure how much there is to be done about that case, since > there's probably no good way to distinguish it from a query that > takes a really long time. But if we're going to think about this, > we might as well think about all the cases. Well in this case we can still interrupt the query, no? This will drop us back into the prompt, where we can safely \q. > > regards, tom lane -Ryan Kelly --J/dobhs11T7y2rNN Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Allow-interrupting-hanging-c-connection-attempts.patch" --J/dobhs11T7y2rNN--