Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id F2167B5DBF6 for ; Fri, 24 Jun 2011 18:53:29 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 12246-10 for ; Fri, 24 Jun 2011 21:53:23 +0000 (UTC) X-Greylist: delayed 00:25:36.801458 by SQLgrey-1.7.6 Received: from mail-gw0-f46.google.com (mail-gw0-f46.google.com [74.125.83.46]) by mail.postgresql.org (Postfix) with ESMTP id 68916B5DBF1 for ; Fri, 24 Jun 2011 18:53:23 -0300 (ADT) Received: by gwaa18 with SMTP id a18so1247025gwa.19 for ; Fri, 24 Jun 2011 14:53:23 -0700 (PDT) Received: by 10.236.154.199 with SMTP id h47mr6136045yhk.149.1308950865306; Fri, 24 Jun 2011 14:27:45 -0700 (PDT) Received: from postojna.workantile.com ([66.93.0.189]) by mx.google.com with ESMTPS id u64sm1962982yhm.27.2011.06.24.14.27.43 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 24 Jun 2011 14:27:44 -0700 (PDT) Message-Id: <591CB8F5-CE42-4ACF-8E43-ACE5A152DB35@prettyrobots.com> From: Alan Gutierrez To: pgsql-admin@postgresql.org Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Subject: Fast Shutdown and Transactions Date: Fri, 24 Jun 2011 17:27:42 -0400 X-Mailer: Apple Mail (2.936) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201106/141 X-Sequence-Number: 37767 I'm implementing failover for streaming replication using HAProxy. I'm trying to implement soft failover, (or failback), that will give applications in the midst of transaction a clear indication of the state of their transaction. My question is, if you use: pg_ctl -D [DIR] stop -m fast and the application has issue a commit if a transaction and the transaction has completed, will postmaster send an affirmative message before shutting down? Or will it just close the socket? I can see that stopping fast while a transaction is open in psql will not generate a message until the next statement. I'm concerned about the case where an application detects that the connection has been terminated and assumes that the transaction failed, so it reattempts the transaction and creates duplicates. I'd like applications to be able to assume that a dropped connection is a failed transaction. Is there some other, better way to check to see if your transaction was successful or not? One that can be performed across a subsequent connection? -- Alan Gutierrez - http://twitter.com/bigeasy - http://github.com/bigeasy