Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 96743 invoked from network); 26 Jun 2009 15:13:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 26 Jun 2009 15:13:19 -0000 Received: (qmail 47663 invoked by uid 500); 26 Jun 2009 15:13:30 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 47602 invoked by uid 500); 26 Jun 2009 15:13:30 -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 47592 invoked by uid 99); 26 Jun 2009 15:13:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Jun 2009 15:13:30 +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; Fri, 26 Jun 2009 15:13:28 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id D404D234C045 for ; Fri, 26 Jun 2009 08:13:07 -0700 (PDT) Message-ID: <1907626059.1246029187867.JavaMail.jira@brutus> Date: Fri, 26 Jun 2009 08:13:07 -0700 (PDT) From: "Knut Anders Hatlen (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Updated: (DERBY-4018) ArrayIndexOutOfBoundsException in TopService.inService under heavy multithreaded use of EmbeddedDriver In-Reply-To: <1754451845.1231858032383.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-4018?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Knut Anders Hatlen updated DERBY-4018: -------------------------------------- Attachment: d4018-1a.diff d4018-1a is a partial fix for the problem, and it should be sufficient to fix the ArrayIndexOutOfBoundsException in TopService.inService(). I ran the full repro on two machines on which I could reproduce the problem reliably without the fix, and now I don't see the exception. I don't see the deadlock that I saw with the previous patch either. This fix factors out two for loops which iterate over moduleInstances into a helper method which synchronizes on the moduleInstances object over the entire loop. This prevents other threads from removing elements from the vector, and therefore the value returned by Vector.size() should still be valid when we call Vector.get(), and no AIOOBE should be thrown. I believe that it is safe, since the calls to size() and get() are already synchronized on the Vector, and the loop doesn't do anything except unsynchronized accessing a field in the object fetched from the Vector. So there should be no new ordering of how the synchronization locks are obtained, which was the problem with the previous patch. There are still a couple of places where there's an unsynchronized window between the checking of the size and the actual retrieval from the Vector. I'll see if I can address those in a follow-up patch. > ArrayIndexOutOfBoundsException in TopService.inService under heavy multithreaded use of EmbeddedDriver > ------------------------------------------------------------------------------------------------------ > > Key: DERBY-4018 > URL: https://issues.apache.org/jira/browse/DERBY-4018 > Project: Derby > Issue Type: Bug > Components: Services > Affects Versions: 10.4.2.0 > Environment: Windows XP SP2 > Intel Core 2 Duo 3GHz, 3GB RAM > Java JDK 1.6.0_07 > Reporter: Jeff Clary > Assignee: Knut Anders Hatlen > Attachments: BeatDerbyToPieces.java, d4018-1a.diff, program_output.txt, sync.diff, trunk_stacktrace.txt > > > I have created a test program that reproduces this issue. The program pounds on Derby by running jobs on a pool of 10 threads. Each job creates a new Derby database, a schema, a table, and an index. Then it shuts down the database and finishes. The program runs until an error occurs or until 1000 jobs have finished. > The problem is very intermittent, and related I think to multithreaded access of a vector "moduleInstances" in TopService.java. I am seeing the error on my machine about half the time I run the test program. Sometimes it happens after 100 or 200 jobs...but sometimes not until 500 or more, or not at all. > I am using the 10.4.2 derby.jar downloaded from http://db.apache.org/derby/releases/release-10.4.2.0.cgi, without any modifications on my part. > I will attach the test program plus output from a run that failed with the ArrayIndexOutOfBoundsException. (The actual exception thrown to the application from Derby is SQLException, but the underlying cause is an ArrayIndexOutOfBoundsException.) BE AWARE that if you run this test program it can use up a GByte or more of disk space in your Java tmp directory. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.