Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 97636 invoked from network); 2 Nov 2005 16:32:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 Nov 2005 16:32:07 -0000 Received: (qmail 72252 invoked by uid 500); 2 Nov 2005 16:32:05 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 72224 invoked by uid 500); 2 Nov 2005 16:32:05 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 72210 invoked by uid 99); 2 Nov 2005 16:32:05 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Nov 2005 08:32:05 -0800 X-ASF-Spam-Status: No, hits=2.8 required=10.0 tests=DNS_FROM_RFC_ABUSE,DNS_FROM_RFC_POST,DNS_FROM_RFC_WHOIS X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [32.97.182.141] (HELO e1.ny.us.ibm.com) (32.97.182.141) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Nov 2005 08:32:00 -0800 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e1.ny.us.ibm.com (8.12.11/8.12.11) with ESMTP id jA2GVX9v032112 for ; Wed, 2 Nov 2005 11:31:33 -0500 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay04.pok.ibm.com (8.12.10/NCO/VERS6.7) with ESMTP id jA2GVX3X121616 for ; Wed, 2 Nov 2005 11:31:33 -0500 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.12.11/8.13.3) with ESMTP id jA2GVNgF005084 for ; Wed, 2 Nov 2005 11:31:23 -0500 Received: from [127.0.0.1] (sig-9-48-112-168.mts.ibm.com [9.48.112.168]) by d01av03.pok.ibm.com (8.12.11/8.12.11) with ESMTP id jA2GVLtt004382 for ; Wed, 2 Nov 2005 11:31:22 -0500 Message-ID: <4368E9CF.6030401@sbcglobal.net> Date: Wed, 02 Nov 2005 08:31:11 -0800 From: Mike Matrigali Reply-To: mikem_app@sbcglobal.net User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Derby Discussion Subject: Re: Parsing lockTable dumps References: <1130851171.4229.34.camel@pc977.sb.statsbiblioteket.dk> <1130929925.20959.9.camel@pc977.sb.statsbiblioteket.dk> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Knut Anders Hatlen wrote: > Lars Clausen writes: > > >>On Tue, 2005-11-01 at 15:36, Knut Anders Hatlen wrote: >> >>>Lars Clausen writes: >>> >>> >>>>Hi! >>>> >>>>Delving further into our deadlock/lock timeout problems, I now have a >>>>dump of the locks in question. I think I understand what they're >>>>saying, but my interpretation doesn't make as much sense as I'd like it >>>>to. The lockTable dump is as follows: >>>> >>>>ERROR 40XL2: A lock could not be obtained within the time requested. The lockTable dump is: >>>>2005-11-01 12:14:33.516 GMT >>>>XID |TYPE |MODE|LOCKCOUNT|LOCKNAME |STATE|TABLETYPE / LOCKOBJ |INDEXNAME / CONTAINER_ID / (MODE for LATCH only) |TABLENAME / CONGLOM_ID | >>>>------------------------------------------------------------------------------------------------------------------------------------------------------------- >>>>*** The following row is the victim *** >>>>20965 |ROW |X |0 |(4,105) |WAIT |T |NULL |SEEDLISTS | >>>>*** The above row is the victim *** >>>>20963 |ROW |S |9 |(4,105) |GRANT|T |NULL |SEEDLISTS | >>>>20965 |ROW |S |1 |(4,105) |GRANT|T |NULL |SEEDLISTS | >>>>20965 |ROW |S |1 |(5,1) |GRANT|T |SEEDLISTDOMAIN |SEEDLISTS | >> >>[...] >> >>>>------------------------------------------------------------------------------------------------------------------------------------------------------------- >>>> >>>>The interesting lock of course is on the SEEDLISTS table. It appears to >>>>me that the 20963 XID has a shared table lock while the 20965 XID has an >>>>exclusive table lock. That's the first thing that doesn't make sense -- >>>>doesn't seem like a very exclusive lock that. Also, I would expect the >>>>20965 XID to have no problems getting an additional lock on a SEEDLISTS >>>>table row, since it already has a lock on the entire table. Could >>>>somebody explain these oddities to me? >>> >>>You have misinterpreted IS and IX locks. These are intentional locks, >>>which means that the transaction intends to lock rows in that >>>table. For example, if a transaction wants an exclusive lock on row R1 >>>in table T1, it will lock table T1 with intent exclusive (IX) and row >>>R1 in exclusive mode (X). This prevents others from locking the entire >>>table or that particular row, but not from locking other rows in the >>>table. >> >>Thank you, that made it a lot clearer. So for wanting to lock a row, >>the intentional table locks are irrelevant. That trims the relevant >>entries to the above. Now I got a suspicion that I want to run by you: >> >>I've been running the entire system with autocommit off and committing >>explicitly after all updates. Does that mean that shared locks are kept >>until the next commit, even if the statements causing the locks are >>close()d? It appears likely, as switching to autocommit on for all but >>the few places that requires transactions seems to cure the problem[1], >>but it is not the behaviour I expected from reading the java.sql >>documentation. > > > This depends on the isolation level: > > 1) In read uncommitted mode, both shared and exclusive locks are > released after you have finished the operation on a row. In read uncommitted mode no read locks are obtained. exclusive locks are held until end transaction in all isolation modes including read uncommitted. > > 2) In read committed mode (default in Derby), shared locks are > released after you have finished reading the row, but exclusive > locks are kept until the transaction is committed or rolled > back. the exact timing of when the lock is released is dependent on the exact query you are running. Definitely when you close the resultset there are no locks outstanding. In almost all cases when you do the rs.next() the lock on the previous row will be gone. The harder to describe cases are complicated joins involving multiple tables and multiple indexes. > > 3) In repeatable read mode, both shared and exclusive locks are > kept until the transaction has finished. > > 4) Serializable mode is like repeatable read, but additionally > prevents so-called phantom reads. > > If you are using the default isolation level, shared locks should not > be kept until the next commit. The lock table indicates that you are > running with repeatable read or serializable. > > >>-Lars >> >>[1] Seems to, as it is not quite consistently reproducable. > >