X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F2E7A54FDB for ; Thu, 3 Mar 2005 12:19:47 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 48811-01 for ; Thu, 3 Mar 2005 12:19:43 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id 5B4AA54E09 for ; Thu, 3 Mar 2005 12:19:42 +0000 (GMT) Received: (qmail 12456 invoked from network); 3 Mar 2005 12:18:48 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 3 Mar 2005 12:18:48 -0000 Message-ID: <422700DB.1050503@fastcrypt.com> Date: Thu, 03 Mar 2005 07:19:39 -0500 From: Dave Cramer Reply-To: pg@fastcrypt.com Organization: Postgres International User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Mican Bican Cc: jdbc mailinglist Subject: Re: lock problem when dont commit References: <915cd3880503021437382b001e@mail.gmail.com> <42264B3F.4080409@fastcrypt.com> <15017.1109806796@sss.pgh.pa.us> <42265BA3.7030509@fastcrypt.com> <15716.1109813069@sss.pgh.pa.us> <4226C7C4.6020002@gmail.com> In-Reply-To: <4226C7C4.6020002@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.041 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/29 X-Sequence-Number: 12422 As Tom pointed out this behaviour will not change in the immediate future. I think your best bet is not to hold the lock for so long. I generally prepare all the data and do the insert in one statement. Dave Mican Bican wrote: > Tom Lane schrieb: > >> Dave Cramer writes: >> >> >>> Tom Lane wrote: >>> >>> >>>> Maybe a conflict on referenced foreign-key rows? >>>> >>> >> >> >> >>> can you explain how that happens? >>> >> >> >> When you insert or update a row in a table that has an FK reference, >> it takes out a row-level lock on the referenced row in the master table. >> This is needed to prevent someone else from deleting the master row >> before commit. (Since the someone else can't see your uncommitted row, >> nothing but a lock could stop them from thinking it's OK to remove the >> master row.) >> >> So if two sessions are trying to insert rows that reference the same >> master row, they conflict --- because the only type of row-level lock >> we have at the moment is exclusive. I believe Alvaro is looking into >> supporting shared row-level locks for 8.1, which'd make this problem >> go away. >> >> regards, tom lane >> >> >> > Ok I think thats the problem.. because > > client1: > > ... > conn.setAutoCommit(false) > insert into liefAdress(adress,postcode) //id is autoincrement insert > into liefAdress(adress2,postcode2) > .... > .... > > > postcode is a FK to a list with postcodes. When I want insert different > postcodes they are no locked.. there is only locked when the postcode are > same. But why there are locked? Have anybody a good > Idea to deal with this problem..? > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings > > -- Dave Cramer http://www.postgresintl.com 519 939 0336 ICQ#14675561