From derby-commits-return-11166-apmail-db-derby-commits-archive=db.apache.org@db.apache.org Thu Feb 19 20:09:40 2009 Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 91813 invoked from network); 19 Feb 2009 20:09:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Feb 2009 20:09:40 -0000 Received: (qmail 79943 invoked by uid 500); 19 Feb 2009 20:09:40 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 79876 invoked by uid 500); 19 Feb 2009 20:09:40 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 79867 invoked by uid 99); 19 Feb 2009 20:09:39 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Feb 2009 12:09:39 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Feb 2009 20:09:37 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A14A123889B2; Thu, 19 Feb 2009 20:09:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r745982 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ReclaimSpaceHelper.java Date: Thu, 19 Feb 2009 20:09:16 -0000 To: derby-commits@db.apache.org From: kmarsden@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090219200916.A14A123889B2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kmarsden Date: Thu Feb 19 20:09:16 2009 New Revision: 745982 URL: http://svn.apache.org/viewvc?rev=745982&view=rev Log: DERBY-4059 If space reclamation cannot obtain container lock it will not retry getting the lock This change does make the change so that the retry occurs but in practical application it is unlikely that we will get the lock after three retries, because the retry happens so quickly. See https://issues.apache.org/jira/browse/DERBY-4055?focusedCommentId=12673436#action_12673436 for suggestions on long term solutions to the retry problem. Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ReclaimSpaceHelper.java Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ReclaimSpaceHelper.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ReclaimSpaceHelper.java?rev=745982&r1=745981&r2=745982&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ReclaimSpaceHelper.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ReclaimSpaceHelper.java Thu Feb 19 20:09:16 2009 @@ -42,6 +42,7 @@ import org.apache.derby.iapi.store.raw.xact.RawTransaction; import org.apache.derby.iapi.store.raw.data.RawContainerHandle; +import org.apache.derby.shared.common.reference.SQLState; /** @@ -259,6 +260,9 @@ } if (work.incrAttempts() < 3) // retry this for serveral times + // it is however, unlikely that three tries will be + // enough because there is no delay between retries. + // See DERBY-4059 and DERBY-4055 for details. { return Serviceable.REQUEUE; } @@ -509,17 +513,34 @@ /** - Open container shared no wait + * Open container shared no wait + * + * @param tran Transaction + * @param rlock LockingPolicy + * @param containerId container id. + * + * @return ContainerHandle or null if it could not obtain lock. + * + * @throws StandardException */ private static ContainerHandle openContainerNW(Transaction tran, LockingPolicy rlock, ContainerKey containerId) throws StandardException { - ContainerHandle containerHdl = tran.openContainer - (containerId, rlock, - ContainerHandle.MODE_FORUPDATE | - ContainerHandle.MODE_LOCK_NOWAIT); - + ContainerHandle containerHdl = null; + try { + containerHdl = tran.openContainer + (containerId, rlock, + ContainerHandle.MODE_FORUPDATE | + ContainerHandle.MODE_LOCK_NOWAIT); + } catch (StandardException se) { + // DERBY-4059 + // if this is a lock timeout just return null. + // otherwise throw the exception + if (!se.getSQLState().equals(SQLState.LOCK_TIMEOUT)) { + throw se; + } + } return containerHdl; }