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 "Dag H. Wanvik (JIRA)" <ji...@apache.org> on 2011/01/07 00:20:45 UTC

[jira] Created: (DERBY-4960) Race condition in FileContainer#allocCache when reopening RAFContainer after interrupt

Race condition in FileContainer#allocCache when reopening RAFContainer after interrupt
--------------------------------------------------------------------------------------

                 Key: DERBY-4960
                 URL: https://issues.apache.org/jira/browse/DERBY-4960
             Project: Derby
          Issue Type: Bug
          Components: Store
    Affects Versions: 10.8.0.0
            Reporter: Dag H. Wanvik


The symptom is an ArrayIndexOutOfBoundsException:

java.lang.ArrayIndexOutOfBoundsException: -1
	at org.apache.derby.impl.store.raw.data.AllocationCache.validate(AllocationCache.java:581)
	at org.apache.derby.impl.store.raw.data.AllocationCache.getLastPageNumber(AllocationCache.java:122)
	at org.apache.derby.impl.store.raw.data.FileContainer.pageValid(FileContainer.java:2067)
	at org.apache.derby.impl.store.raw.data.FileContainer.getUserPage(FileContainer.java:2522)
	at org.apache.derby.impl.store.raw.data.FileContainer.getInsertablePage(FileContainer.java:2867)
	at org.apache.derby.impl.store.raw.data.FileContainer.getPageForInsert(FileContainer.java:3017)
	at org.apache.derby.impl.store.raw.data.BaseContainerHandle.getPageForInsert(BaseContainerHandle.java:372)
	at org.apache.derby.impl.store.access.heap.HeapController.doInsert(HeapController.java:244)
	at org.apache.derby.impl.store.access.heap.HeapController.insertAndFetchLocation(HeapController.java:599)
	at org.apache.derby.impl.sql.execute.RowChangerImpl.insertRow(RowChangerImpl.java:452)
	at org.apache.derby.impl.sql.execute.InsertResultSet.normalInsertCore(InsertResultSet.java:1028)
	at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:505)
	at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436)
	at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317)
	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1241)
	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java:1686)
	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(EmbedPreparedStatement.java:308)
	at InterruptTest$WorkerThread.run(InterruptTest.java:261

This can only happen if another thread has called allocCache.reset while the thread above is in the loop in validate, so as to set numExtents to 0.
The synchronization of allocCache is documented in the Javadoc of the FileContainer class: all accesses to allocCache should synchronize.
This is omitted when we reopen: FileContainer#openContainer calls readHeader -> readHeaderFromArray -> allocCache.reset

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-4960) Race condition in FileContainer#allocCache when reopening RAFContainer after interrupt

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4960?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12979054#action_12979054 ] 

Dag H. Wanvik commented on DERBY-4960:
--------------------------------------

Regressions passed. Note that the patch in itself does not make the repro work, since there is still outstanding parts of DERBY-4741 that need to be committed first (I saw the error while preparing a patch for those outstanding parts, sorry, I should have been clear about that). I'll still commit this fix though, incremental improvement :)

> Race condition in FileContainer#allocCache when reopening RAFContainer after interrupt
> --------------------------------------------------------------------------------------
>
>                 Key: DERBY-4960
>                 URL: https://issues.apache.org/jira/browse/DERBY-4960
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.8.0.0
>            Reporter: Dag H. Wanvik
>            Assignee: Dag H. Wanvik
>         Attachments: derby-4960-1.diff, derby-4960-1.stat, InterruptTest.java
>
>
> The symptom is an ArrayIndexOutOfBoundsException:
> java.lang.ArrayIndexOutOfBoundsException: -1
> 	at org.apache.derby.impl.store.raw.data.AllocationCache.validate(AllocationCache.java:581)
> 	at org.apache.derby.impl.store.raw.data.AllocationCache.getLastPageNumber(AllocationCache.java:122)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.pageValid(FileContainer.java:2067)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getUserPage(FileContainer.java:2522)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getInsertablePage(FileContainer.java:2867)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getPageForInsert(FileContainer.java:3017)
> 	at org.apache.derby.impl.store.raw.data.BaseContainerHandle.getPageForInsert(BaseContainerHandle.java:372)
> 	at org.apache.derby.impl.store.access.heap.HeapController.doInsert(HeapController.java:244)
> 	at org.apache.derby.impl.store.access.heap.HeapController.insertAndFetchLocation(HeapController.java:599)
> 	at org.apache.derby.impl.sql.execute.RowChangerImpl.insertRow(RowChangerImpl.java:452)
> 	at org.apache.derby.impl.sql.execute.InsertResultSet.normalInsertCore(InsertResultSet.java:1028)
> 	at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:505)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1241)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java:1686)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(EmbedPreparedStatement.java:308)
> 	at InterruptTest$WorkerThread.run(InterruptTest.java:261
> This can only happen if another thread has called allocCache.reset while the thread above is in the loop in validate, so as to set numExtents to 0.
> The synchronization of allocCache is documented in the Javadoc of the FileContainer class: all accesses to allocCache should synchronize.
> This is omitted when we reopen: FileContainer#openContainer calls readHeader -> readHeaderFromArray -> allocCache.reset

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-4960) Race condition in FileContainer#allocCache when reopening RAFContainer after interrupt

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4960?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik updated DERBY-4960:
---------------------------------

    Attachment: InterruptTest.java

For the record, to reproduce this I ran the attached InterruptTest thus:

java -XX:-UseVMInterruptibleIO -cp $CLASSPATH:. InterruptTest lock

> Race condition in FileContainer#allocCache when reopening RAFContainer after interrupt
> --------------------------------------------------------------------------------------
>
>                 Key: DERBY-4960
>                 URL: https://issues.apache.org/jira/browse/DERBY-4960
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.8.0.0
>            Reporter: Dag H. Wanvik
>         Attachments: InterruptTest.java
>
>
> The symptom is an ArrayIndexOutOfBoundsException:
> java.lang.ArrayIndexOutOfBoundsException: -1
> 	at org.apache.derby.impl.store.raw.data.AllocationCache.validate(AllocationCache.java:581)
> 	at org.apache.derby.impl.store.raw.data.AllocationCache.getLastPageNumber(AllocationCache.java:122)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.pageValid(FileContainer.java:2067)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getUserPage(FileContainer.java:2522)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getInsertablePage(FileContainer.java:2867)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getPageForInsert(FileContainer.java:3017)
> 	at org.apache.derby.impl.store.raw.data.BaseContainerHandle.getPageForInsert(BaseContainerHandle.java:372)
> 	at org.apache.derby.impl.store.access.heap.HeapController.doInsert(HeapController.java:244)
> 	at org.apache.derby.impl.store.access.heap.HeapController.insertAndFetchLocation(HeapController.java:599)
> 	at org.apache.derby.impl.sql.execute.RowChangerImpl.insertRow(RowChangerImpl.java:452)
> 	at org.apache.derby.impl.sql.execute.InsertResultSet.normalInsertCore(InsertResultSet.java:1028)
> 	at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:505)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1241)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java:1686)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(EmbedPreparedStatement.java:308)
> 	at InterruptTest$WorkerThread.run(InterruptTest.java:261
> This can only happen if another thread has called allocCache.reset while the thread above is in the loop in validate, so as to set numExtents to 0.
> The synchronization of allocCache is documented in the Javadoc of the FileContainer class: all accesses to allocCache should synchronize.
> This is omitted when we reopen: FileContainer#openContainer calls readHeader -> readHeaderFromArray -> allocCache.reset

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-4960) Race condition in FileContainer#allocCache when reopening RAFContainer after interrupt

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4960?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kathey Marsden updated DERBY-4960:
----------------------------------

    Fix Version/s: 10.8.0.0

> Race condition in FileContainer#allocCache when reopening RAFContainer after interrupt
> --------------------------------------------------------------------------------------
>
>                 Key: DERBY-4960
>                 URL: https://issues.apache.org/jira/browse/DERBY-4960
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.8.0.0
>            Reporter: Dag H. Wanvik
>            Assignee: Dag H. Wanvik
>             Fix For: 10.8.0.0
>
>         Attachments: derby-4960-1.diff, derby-4960-1.stat, derby-4960-2.diff, derby-4960-2.stat, InterruptTest.java
>
>
> The symptom is an ArrayIndexOutOfBoundsException:
> java.lang.ArrayIndexOutOfBoundsException: -1
> 	at org.apache.derby.impl.store.raw.data.AllocationCache.validate(AllocationCache.java:581)
> 	at org.apache.derby.impl.store.raw.data.AllocationCache.getLastPageNumber(AllocationCache.java:122)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.pageValid(FileContainer.java:2067)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getUserPage(FileContainer.java:2522)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getInsertablePage(FileContainer.java:2867)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getPageForInsert(FileContainer.java:3017)
> 	at org.apache.derby.impl.store.raw.data.BaseContainerHandle.getPageForInsert(BaseContainerHandle.java:372)
> 	at org.apache.derby.impl.store.access.heap.HeapController.doInsert(HeapController.java:244)
> 	at org.apache.derby.impl.store.access.heap.HeapController.insertAndFetchLocation(HeapController.java:599)
> 	at org.apache.derby.impl.sql.execute.RowChangerImpl.insertRow(RowChangerImpl.java:452)
> 	at org.apache.derby.impl.sql.execute.InsertResultSet.normalInsertCore(InsertResultSet.java:1028)
> 	at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:505)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1241)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java:1686)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(EmbedPreparedStatement.java:308)
> 	at InterruptTest$WorkerThread.run(InterruptTest.java:261
> This can only happen if another thread has called allocCache.reset while the thread above is in the loop in validate, so as to set numExtents to 0.
> The synchronization of allocCache is documented in the Javadoc of the FileContainer class: all accesses to allocCache should synchronize.
> This is omitted when we reopen: FileContainer#openContainer calls readHeader -> readHeaderFromArray -> allocCache.reset

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-4960) Race condition in FileContainer#allocCache when reopening RAFContainer after interrupt

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4960?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik updated DERBY-4960:
---------------------------------

    Attachment: derby-4960-2.stat
                derby-4960-2.diff

Uploading version 2, simplified.

> Race condition in FileContainer#allocCache when reopening RAFContainer after interrupt
> --------------------------------------------------------------------------------------
>
>                 Key: DERBY-4960
>                 URL: https://issues.apache.org/jira/browse/DERBY-4960
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.8.0.0
>            Reporter: Dag H. Wanvik
>            Assignee: Dag H. Wanvik
>         Attachments: derby-4960-1.diff, derby-4960-1.stat, derby-4960-2.diff, derby-4960-2.stat, InterruptTest.java
>
>
> The symptom is an ArrayIndexOutOfBoundsException:
> java.lang.ArrayIndexOutOfBoundsException: -1
> 	at org.apache.derby.impl.store.raw.data.AllocationCache.validate(AllocationCache.java:581)
> 	at org.apache.derby.impl.store.raw.data.AllocationCache.getLastPageNumber(AllocationCache.java:122)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.pageValid(FileContainer.java:2067)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getUserPage(FileContainer.java:2522)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getInsertablePage(FileContainer.java:2867)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getPageForInsert(FileContainer.java:3017)
> 	at org.apache.derby.impl.store.raw.data.BaseContainerHandle.getPageForInsert(BaseContainerHandle.java:372)
> 	at org.apache.derby.impl.store.access.heap.HeapController.doInsert(HeapController.java:244)
> 	at org.apache.derby.impl.store.access.heap.HeapController.insertAndFetchLocation(HeapController.java:599)
> 	at org.apache.derby.impl.sql.execute.RowChangerImpl.insertRow(RowChangerImpl.java:452)
> 	at org.apache.derby.impl.sql.execute.InsertResultSet.normalInsertCore(InsertResultSet.java:1028)
> 	at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:505)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1241)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java:1686)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(EmbedPreparedStatement.java:308)
> 	at InterruptTest$WorkerThread.run(InterruptTest.java:261
> This can only happen if another thread has called allocCache.reset while the thread above is in the loop in validate, so as to set numExtents to 0.
> The synchronization of allocCache is documented in the Javadoc of the FileContainer class: all accesses to allocCache should synchronize.
> This is omitted when we reopen: FileContainer#openContainer calls readHeader -> readHeaderFromArray -> allocCache.reset

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-4960) Race condition in FileContainer#allocCache when reopening RAFContainer after interrupt

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4960?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12978577#action_12978577 ] 

Dag H. Wanvik commented on DERBY-4960:
--------------------------------------

Trying to synchronize here gave deadlock instead:

One thread owns allocCache and is wait for latch. Another thread owns the latch, sees interrupt and tries to reopen the container and in that process need to call allocCache.reset: hence deadlock. 

Probably we can skip the call to allocCache.reset: when we reopen, since we are not really reusing the file container object for another container, we are just reopening it...


> Race condition in FileContainer#allocCache when reopening RAFContainer after interrupt
> --------------------------------------------------------------------------------------
>
>                 Key: DERBY-4960
>                 URL: https://issues.apache.org/jira/browse/DERBY-4960
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.8.0.0
>            Reporter: Dag H. Wanvik
>
> The symptom is an ArrayIndexOutOfBoundsException:
> java.lang.ArrayIndexOutOfBoundsException: -1
> 	at org.apache.derby.impl.store.raw.data.AllocationCache.validate(AllocationCache.java:581)
> 	at org.apache.derby.impl.store.raw.data.AllocationCache.getLastPageNumber(AllocationCache.java:122)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.pageValid(FileContainer.java:2067)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getUserPage(FileContainer.java:2522)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getInsertablePage(FileContainer.java:2867)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getPageForInsert(FileContainer.java:3017)
> 	at org.apache.derby.impl.store.raw.data.BaseContainerHandle.getPageForInsert(BaseContainerHandle.java:372)
> 	at org.apache.derby.impl.store.access.heap.HeapController.doInsert(HeapController.java:244)
> 	at org.apache.derby.impl.store.access.heap.HeapController.insertAndFetchLocation(HeapController.java:599)
> 	at org.apache.derby.impl.sql.execute.RowChangerImpl.insertRow(RowChangerImpl.java:452)
> 	at org.apache.derby.impl.sql.execute.InsertResultSet.normalInsertCore(InsertResultSet.java:1028)
> 	at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:505)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1241)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java:1686)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(EmbedPreparedStatement.java:308)
> 	at InterruptTest$WorkerThread.run(InterruptTest.java:261
> This can only happen if another thread has called allocCache.reset while the thread above is in the loop in validate, so as to set numExtents to 0.
> The synchronization of allocCache is documented in the Javadoc of the FileContainer class: all accesses to allocCache should synchronize.
> This is omitted when we reopen: FileContainer#openContainer calls readHeader -> readHeaderFromArray -> allocCache.reset

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (DERBY-4960) Race condition in FileContainer#allocCache when reopening RAFContainer after interrupt

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4960?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik reassigned DERBY-4960:
------------------------------------

    Assignee: Dag H. Wanvik

> Race condition in FileContainer#allocCache when reopening RAFContainer after interrupt
> --------------------------------------------------------------------------------------
>
>                 Key: DERBY-4960
>                 URL: https://issues.apache.org/jira/browse/DERBY-4960
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.8.0.0
>            Reporter: Dag H. Wanvik
>            Assignee: Dag H. Wanvik
>         Attachments: InterruptTest.java
>
>
> The symptom is an ArrayIndexOutOfBoundsException:
> java.lang.ArrayIndexOutOfBoundsException: -1
> 	at org.apache.derby.impl.store.raw.data.AllocationCache.validate(AllocationCache.java:581)
> 	at org.apache.derby.impl.store.raw.data.AllocationCache.getLastPageNumber(AllocationCache.java:122)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.pageValid(FileContainer.java:2067)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getUserPage(FileContainer.java:2522)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getInsertablePage(FileContainer.java:2867)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getPageForInsert(FileContainer.java:3017)
> 	at org.apache.derby.impl.store.raw.data.BaseContainerHandle.getPageForInsert(BaseContainerHandle.java:372)
> 	at org.apache.derby.impl.store.access.heap.HeapController.doInsert(HeapController.java:244)
> 	at org.apache.derby.impl.store.access.heap.HeapController.insertAndFetchLocation(HeapController.java:599)
> 	at org.apache.derby.impl.sql.execute.RowChangerImpl.insertRow(RowChangerImpl.java:452)
> 	at org.apache.derby.impl.sql.execute.InsertResultSet.normalInsertCore(InsertResultSet.java:1028)
> 	at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:505)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1241)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java:1686)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(EmbedPreparedStatement.java:308)
> 	at InterruptTest$WorkerThread.run(InterruptTest.java:261
> This can only happen if another thread has called allocCache.reset while the thread above is in the loop in validate, so as to set numExtents to 0.
> The synchronization of allocCache is documented in the Javadoc of the FileContainer class: all accesses to allocCache should synchronize.
> This is omitted when we reopen: FileContainer#openContainer calls readHeader -> readHeaderFromArray -> allocCache.reset

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-4960) Race condition in FileContainer#allocCache when reopening RAFContainer after interrupt

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4960?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik updated DERBY-4960:
---------------------------------

    Attachment: derby-4960-1.stat
                derby-4960-1.diff

Uploading a patch, derby-4960-1, which omits reading the page header when reopening the container after an interrupt. This sidesteps the problem seen. An new "reopenContainer" method is used for this purpose. Additionally the patch changes a couple of "private final" to just private, since final there is redundant.

Running regressions.

> Race condition in FileContainer#allocCache when reopening RAFContainer after interrupt
> --------------------------------------------------------------------------------------
>
>                 Key: DERBY-4960
>                 URL: https://issues.apache.org/jira/browse/DERBY-4960
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.8.0.0
>            Reporter: Dag H. Wanvik
>            Assignee: Dag H. Wanvik
>         Attachments: derby-4960-1.diff, derby-4960-1.stat, InterruptTest.java
>
>
> The symptom is an ArrayIndexOutOfBoundsException:
> java.lang.ArrayIndexOutOfBoundsException: -1
> 	at org.apache.derby.impl.store.raw.data.AllocationCache.validate(AllocationCache.java:581)
> 	at org.apache.derby.impl.store.raw.data.AllocationCache.getLastPageNumber(AllocationCache.java:122)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.pageValid(FileContainer.java:2067)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getUserPage(FileContainer.java:2522)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getInsertablePage(FileContainer.java:2867)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getPageForInsert(FileContainer.java:3017)
> 	at org.apache.derby.impl.store.raw.data.BaseContainerHandle.getPageForInsert(BaseContainerHandle.java:372)
> 	at org.apache.derby.impl.store.access.heap.HeapController.doInsert(HeapController.java:244)
> 	at org.apache.derby.impl.store.access.heap.HeapController.insertAndFetchLocation(HeapController.java:599)
> 	at org.apache.derby.impl.sql.execute.RowChangerImpl.insertRow(RowChangerImpl.java:452)
> 	at org.apache.derby.impl.sql.execute.InsertResultSet.normalInsertCore(InsertResultSet.java:1028)
> 	at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:505)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1241)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java:1686)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(EmbedPreparedStatement.java:308)
> 	at InterruptTest$WorkerThread.run(InterruptTest.java:261
> This can only happen if another thread has called allocCache.reset while the thread above is in the loop in validate, so as to set numExtents to 0.
> The synchronization of allocCache is documented in the Javadoc of the FileContainer class: all accesses to allocCache should synchronize.
> This is omitted when we reopen: FileContainer#openContainer calls readHeader -> readHeaderFromArray -> allocCache.reset

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (DERBY-4960) Race condition in FileContainer#allocCache when reopening RAFContainer after interrupt

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4960?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik closed DERBY-4960.
--------------------------------

    Resolution: Fixed

Committed version 2 as svn 1056591, closing.


> Race condition in FileContainer#allocCache when reopening RAFContainer after interrupt
> --------------------------------------------------------------------------------------
>
>                 Key: DERBY-4960
>                 URL: https://issues.apache.org/jira/browse/DERBY-4960
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.8.0.0
>            Reporter: Dag H. Wanvik
>            Assignee: Dag H. Wanvik
>         Attachments: derby-4960-1.diff, derby-4960-1.stat, derby-4960-2.diff, derby-4960-2.stat, InterruptTest.java
>
>
> The symptom is an ArrayIndexOutOfBoundsException:
> java.lang.ArrayIndexOutOfBoundsException: -1
> 	at org.apache.derby.impl.store.raw.data.AllocationCache.validate(AllocationCache.java:581)
> 	at org.apache.derby.impl.store.raw.data.AllocationCache.getLastPageNumber(AllocationCache.java:122)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.pageValid(FileContainer.java:2067)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getUserPage(FileContainer.java:2522)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getInsertablePage(FileContainer.java:2867)
> 	at org.apache.derby.impl.store.raw.data.FileContainer.getPageForInsert(FileContainer.java:3017)
> 	at org.apache.derby.impl.store.raw.data.BaseContainerHandle.getPageForInsert(BaseContainerHandle.java:372)
> 	at org.apache.derby.impl.store.access.heap.HeapController.doInsert(HeapController.java:244)
> 	at org.apache.derby.impl.store.access.heap.HeapController.insertAndFetchLocation(HeapController.java:599)
> 	at org.apache.derby.impl.sql.execute.RowChangerImpl.insertRow(RowChangerImpl.java:452)
> 	at org.apache.derby.impl.sql.execute.InsertResultSet.normalInsertCore(InsertResultSet.java:1028)
> 	at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:505)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1241)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java:1686)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(EmbedPreparedStatement.java:308)
> 	at InterruptTest$WorkerThread.run(InterruptTest.java:261
> This can only happen if another thread has called allocCache.reset while the thread above is in the loop in validate, so as to set numExtents to 0.
> The synchronization of allocCache is documented in the Javadoc of the FileContainer class: all accesses to allocCache should synchronize.
> This is omitted when we reopen: FileContainer#openContainer calls readHeader -> readHeaderFromArray -> allocCache.reset

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.