You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Myrna van Lunteren (JIRA)" <ji...@apache.org> on 2014/06/02 20:00:11 UTC

[jira] [Commented] (DERBY-6504) change AllocPage.ReadContainerInfo to catch ArrayIndexOutOfBoundsException and turn it into Derby error.

    [ https://issues.apache.org/jira/browse/DERBY-6504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14015654#comment-14015654 ] 

Myrna van Lunteren commented on DERBY-6504:
-------------------------------------------

I am no closer to understanding why the new message gets removed when I pass the aioob exception as the second parameter.
I tried this by running tests and by using ij to connect to a previously created database (created by the Rllmodule.sql script test) when modifying the AllocPage.readContainerInfo like so:
		    try {
		        System.arraycopy(
		                epage, BORROWED_SPACE_OFFSET+BORROWED_SPACE_LEN,
						containerInfo, 0, N);
==>		        byte[] tmp = containerInfo;
==>		        System.arraycopy(epage, 109, tmp, 0, 500);
		    }  catch (ArrayIndexOutOfBoundsException ioobe) {
The extra arraycopy will cause the exception. This gets called when I access my test database (which is how I generated the derby.log files I attached). But similar results happen when I run a full test.
This is not what happened in the few cases where users reported this, so maybe the wrapping I'm now proposing is not needed, but I don't think it will hurt.
This is the catch I think I'll add:
		    }  catch (ArrayIndexOutOfBoundsException ioobe) {
                throw StandardException.newException (
                    SQLState.DATA_UNEXPECTED_EXCEPTION, 
                        StandardException.newException (
                            SQLState.UNABLE_TO_ARRAYCOPY,
                            ioobe,
                            epage.length, containerInfo.length,
                            MAX_BORROWED_SPACE,
                            BORROWED_SPACE_OFFSET,
                            BORROWED_SPACE_LEN,
                            BORROWED_SPACE_OFFSET + BORROWED_SPACE_LEN,
                            N,
                            org.apache.derby.iapi.util.StringUtil.hexDump(epage)
                        )
                );
		    }
It wraps the new error XSDG4/ SQLState.UNABLE_TO_ARRAYCOPY in an SQLState.DATA_UNEXPECTED_EXCEPTION (XSDA4: An unexpected exception was thrown).
I hope that this is an OK thing to do.
I'm still looking into tweaking the new message, it currently looks like this:
Caused by: ERROR XSDG4: Unrecoverable internal error encountered while attempting to read low level metadata about the table or index. Please provide support with the following exception information: Arraycopy failed of embryonic page bytearray with length 204 to container information byte array of length 80. The values of the variables and constants were: maximum borrowable space: 204, borrowedspace offset: 108; borrowed space length: 1; source position in arraycopy: 109; length in arraycopy: 80; embryonic page Hex dump:
00000000: 0076 0000 0001 0000 0000 0000 0002 0000  .v..............
00000010: 0000 0006 0000 0000 0000 0000 0000 0000  ................
00000020: 0000 0000 0001 0000 0000 0000 0000 0000  ................
... (more hex...)

> change AllocPage.ReadContainerInfo to catch ArrayIndexOutOfBoundsException and turn it into Derby error.
> --------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-6504
>                 URL: https://issues.apache.org/jira/browse/DERBY-6504
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.6.1.0, 10.8.2.2
>            Reporter: Mike Matrigali
>            Assignee: Myrna van Lunteren
>         Attachments: DERBY-6504.diff, derby.logtry1, derby.logtry2, derby.logtry4
>
>
> Users have reported databases that will not boot with stack traces showing:
> Caused by: java.lang.ArrayIndexOutOfBoundsException
> at java.lang.System.arraycopy(Native Method)
> at org.apache.derby.impl.store.raw.data.AllocPage.ReadContainerInfo(Unknown Source)
> at org.apache.derby.impl.store.raw.data.FileContainer.readHeader(Unknown Source)
> I suggest the code be changed to catch the out of bounds and turn it
> into a StandardException and include as much runtime information as
> possible so that the underlying problem can be diagnosed.  Information
> should include sizes of both arrays, the amount of data being copied ("N"),
> and possibly a hex dump of the source array.



--
This message was sent by Atlassian JIRA
(v6.2#6252)