Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 0EE749552D6 for ; Tue, 28 Feb 2012 18:02:04 -0400 (AST) Received: from gwmta.wicourts.gov ([165.219.244.99] helo=gw.wicourts.gov) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S2V7R-0006zq-Ao for pgsql-bugs@postgresql.org; Tue, 28 Feb 2012 22:02:03 +0000 Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Tue, 28 Feb 2012 16:01:47 -0600 Message-Id: <4F4CFA640200002500045CAC@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.2 Date: Tue, 28 Feb 2012 16:01:40 -0600 From: "Kevin Grittner" To: ,"Tom Lane" Cc: Subject: Re: BUG #6497: Error sent to client, but data written anyway References: <23519.1330465109@sss.pgh.pa.us> In-Reply-To: <23519.1330465109@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Pg-Spam-Score: -4.2 (----) X-Archive-Number: 201202/205 X-Sequence-Number: 32548 Tom Lane wrote: > rlowe@pablowe.net writes: >> There is an edge case where Postgres will return an error to the >> client, but commit the operation anyway, thus breaking the >> contract with the client: > >> postgres=# begin; insert into s.t (c) values (1); >> > not affected)> >> postgres=# commit; >> >> >> The data is now on both the master and slave, but the application >> believes that the transaction was rolled back. A well-behaved >> application will dutifully retry the transaction because it >> *should* have rolled back. However, the data is there so we'll >> have had the transaction execute *twice*. > > Huh? If the backend dumped core before you sent it the commit, > the data will certainly not be committed. It might be physically > present on disk, but it won't be considered valid. I suppose that there is a window of time between the commit becoming effective and the return to the application which, from a user perspective, would be hard to distinguish from what the OP described. I don't really see how that can be avoided, though, short of a transaction manager using 2PC. Any time the server crashes while a COMMIT is pending, one must check to see whether it "took". As long as the client application sees the connection as dead in this situation, I think PostgreSQL is doing everything just as it should. -Kevin