Return-Path: Delivered-To: apmail-openjpa-users-archive@locus.apache.org Received: (qmail 7087 invoked from network); 22 Oct 2007 15:09:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Oct 2007 15:09:01 -0000 Received: (qmail 37935 invoked by uid 500); 22 Oct 2007 15:08:48 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 37830 invoked by uid 500); 22 Oct 2007 15:08:48 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 37806 invoked by uid 99); 22 Oct 2007 15:08:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Oct 2007 08:08:48 -0700 X-ASF-Spam-Status: No, hits=3.7 required=10.0 tests=DNS_FROM_OPENWHOIS,FORGED_HOTMAIL_RCVD2,SPF_HELO_PASS,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Oct 2007 15:08:51 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1IjytK-0003Ny-LX for users@openjpa.apache.org; Mon, 22 Oct 2007 08:08:30 -0700 Message-ID: <13342370.post@talk.nabble.com> Date: Mon, 22 Oct 2007 08:08:30 -0700 (PDT) From: Christiaan To: users@openjpa.apache.org Subject: Use of List increases chance on concurrency contention MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Nabble-From: christiaan_db@hotmail.com X-Virus-Checked: Checked by ClamAV on apache.org Hi, I am writing this since this may be useful to others. I=E2=80=99ve quite so= me classes which have a List attribute. OpenJPA create a relationship table with an order column to maintain the order of the elements. Recently we encountered quite some blocking scenarios when using it in a multi-user environment. The reason was that when List.add(index, object) is being used OpenJPA sends the following sql statement, so the order of the elements can be built up from scratch: =E2=80=9CDelete from RELATION_TABLE where ID =3D =E2=80=9C In ms sql server this causes an exclusive lock on the entire table which of course easily introduces blocking issues (long running transactions having = a shared lock or other client who like to insert objects in their list as well).=20 List.add(Object) does not have this behaviour so when adding objects to the end of the list it is always better to use this method. My suggestions: 1)=09In the proxy list openjpa creates add a check to List.add(index, objec= t) whether index is equal to List.size() so it can use the same logic as add() 2)=09May be provide some other mode for updating the order of elements when elements are being inserted, eg. execute update statements instead of a deletion? Kind regards, Christiaan --=20 View this message in context: http://www.nabble.com/Use-of-List-increases-c= hance-on-concurrency-contention-tf4670571.html#a13342370 Sent from the OpenJPA Users mailing list archive at Nabble.com.