Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 51381 invoked from network); 15 Jun 2009 22:54:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 15 Jun 2009 22:54:18 -0000 Received: (qmail 91322 invoked by uid 500); 15 Jun 2009 22:54:29 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 91274 invoked by uid 500); 15 Jun 2009 22:54:29 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 91266 invoked by uid 99); 15 Jun 2009 22:54:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Jun 2009 22:54:29 +0000 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.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Jun 2009 22:54:27 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 5DB61234C044 for ; Mon, 15 Jun 2009 15:54:07 -0700 (PDT) Message-ID: <841678213.1245106447369.JavaMail.jira@brutus> Date: Mon, 15 Jun 2009 15:54:07 -0700 (PDT) From: "Knut Anders Hatlen (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-2991) Index split deadlock In-Reply-To: <16734720.1186114252905.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DERBY-2991?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12719838#action_12719838 ] Knut Anders Hatlen commented on DERBY-2991: ------------------------------------------- Yes, that test was added here. It requires some coordination between two threads, so my first guess would be that there is a timing issue in the test. Please file a separate JIRA issue for this failure. Thanks. > Index split deadlock > -------------------- > > Key: DERBY-2991 > URL: https://issues.apache.org/jira/browse/DERBY-2991 > Project: Derby > Issue Type: Bug > Components: Store > Affects Versions: 10.2.2.0, 10.3.1.4, 10.4.2.0 > Environment: Windows XP, Java 6 > Reporter: Bogdan Calmac > Assignee: Knut Anders Hatlen > Fix For: 10.5.1.1 > > Attachments: d2991-2a.diff, d2991-2a.stat, d2991-2b.diff, d2991-2b.stat, d2991-preview-1a.diff, d2991-preview-1a.stat, d2991-preview-1b.diff, d2991-preview-1b.stat, d2991-preview-1c.diff, d2991-preview-1c.stat, d2991-preview-1d.diff, d2991-preview-1d.stat, d2991-preview-1e.diff, derby.log, InsertSelectDeadlock.java, perftest.diff, Repro2991.java, stacktraces_during_deadlock.txt, test-1.diff, test-2.diff, test-3.diff, test-4.diff > > > After doing dome research on the mailing list, it appears that the index split deadlock is a known behaviour, so I will start by describing the theoretical problem first and then follow with the details of my test case. > If you have concurrent select and insert transactions on the same table, the observed locking behaviour is as follows: > - the select transaction acquires an S lock on the root block of the index and then waits for an S lock on some uncommitted row of the insert transaction > - the insert transaction acquires X locks on the inserted records and if it needs to do an index split creates a sub-transaction that tries to acquire an X lock on the root block of the index > In summary: INDEX LOCK followed by ROW LOCK + ROW LOCK followed by INDEX LOCK = deadlock > In the case of my project this is an important issue (lack of concurrency after being forced to use table level locking) and I would like to contribute to the project and fix this issue (if possible). I was wondering if someone that knows the code can give me a few pointers on the implications of this issue: > - Is this a limitation of the top-down algorithm used? > - Would fixing it require to use a bottom up algorithm for better concurrency (which is certainly non trivial)? > - Trying to break the circular locking above, I would first question why does the select transaction need to acquire (and hold) a lock on the root block of the index. Would it be possible to ensure the consistency of the select without locking the index? > ----- > The attached test (InsertSelectDeadlock.java) tries to simulate a typical data collection application, it consists of: > - an insert thread that inserts records in batch > - a select thread that 'processes' the records inserted by the other thread: 'select * from table where id > ?' > The derby log provides detail about the deadlock trace and stacktraces_during_deadlock.txt shows that the inser thread is doing an index split. > The test was run on 10.2.2.0 and 10.3.1.4 with identical behaviour. > Thanks, > Bogdan Calmac. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.