X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0D96ED1C9C0 for ; Fri, 1 Aug 2003 06:22:06 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 16301-10 for ; Fri, 1 Aug 2003 03:20:59 -0300 (ADT) Received: from megazone.bigpanda.com (45.mufb.snfc.sffca01r18.dsl.att.net [12.103.249.45]) by svr1.postgresql.org (Postfix) with ESMTP id E53F8D1C9B6 for ; Fri, 1 Aug 2003 03:21:58 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id A5AAED62E; Thu, 31 Jul 2003 23:21:59 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 9B5E25C10; Thu, 31 Jul 2003 23:21:59 -0700 (PDT) Date: Thu, 31 Jul 2003 23:21:59 -0700 (PDT) From: Stephan Szabo To: Cc: , Subject: Re: Parallel transactions failing oddly In-Reply-To: <1059717370.6233.42.camel@taekwondo.intra.pretax.net> Message-ID: <20030731231607.J38816-100000@megazone.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/9 X-Sequence-Number: 9732 On 1 Aug 2003, Mauri Sahlberg wrote: > On pe, 2003-08-01 at 08:51, Stephan Szabo wrote: > > On 1 Aug 2003, Mauri Sahlberg wrote: > > > > > On pe, 2003-08-01 at 03:12, Stephan Szabo wrote: > > > > > interface. If we run them one by one everything goes fine. But if I > > > > > run them in parallel - in separate processes - all but the first one > > > > > claiming the lock for "ryhmalaiset"-table will fail. And they will > > > > > fail as soon as the first one is finished by trying to insert > > > > > duplicate row in the shared table. Incidentally this row would also be > > > > > the very first row they are trying to insert. They all run the same code > > > > > but with different data. > > > > > > > > > The second transaction won't see the row inserted by the first transaction > > > > until it commits (at best). Both transactions can think there are no > > > > matching rows. > > > > > > Umh, but as the "ryhmalaiset" table is locked until the transaction is > > > commited? And what do you mean with "at best"? Is there any way ensuring > > > that the other transactions won't access the table until the first one > > > has finished updating it if the lock is not enough? > > > > I said at best because I dont think serializable mode transactions won't > > see the row even after commit as long as its snapshot's been taken > > already. You are locking the table in access exclusive mode right? > > Yes. Another possibility is if you locking the table inside the function? If so, I think you may not see the state of the other transaction's commits even in read committed isolation.