db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] Updated: (DERBY-4018) ArrayIndexOutOfBoundsException in TopService.inService under heavy multithreaded use of EmbeddedDriver
Date Mon, 29 Jun 2009 15:14:47 GMT

     [ 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-2a.diff

Patch 2a addresses the remaining issue where there's a possibility
that the size of the Vector changes between the calls to size() and
elementAt() in bootModule().

I only added synchronization on moduleInstances over the two calls
that needed a consistent view of the Vector. Since the synchronization
block does not cover the entire for loop, there is still a possibility
that elements are added to or removed from the Vector between two
retrievals from it. That should be harmless, though, since it should
only make the loop skip one of the modules or look at one of the
modules twice.

If one is skipped, the worst case would be if it was the module we
were looking for so that we boot a module unnecessarily, but this case
is already handled by the method and it'll just shut down the module
when it detects that it has been booted twice.

If one module is looked at twice, it'll just conclude twice that it's
not the module we're looking for and go on to the next one. (Since
modules are always added to the end of the Vector currently, I don't
think this will ever happen with the code as it is today.)

The patch does not introduce the possibility for any of those
situations by the way, they are just as likely without the patch.

The repro still runs without hangs or ArrayIndexOutOfBoundsExceptions,
and both Derbyall and suites.All ran cleanly.

> 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:
>         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, d4018-2a.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-,
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.

View raw message