db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kristian Waagan (JIRA)" <j...@apache.org>
Subject [jira] Updated: (DERBY-4928) Deadlock-prone synchronization in BasicDependencyManager
Date Mon, 06 Dec 2010 16:34:11 GMT

     [ https://issues.apache.org/jira/browse/DERBY-4928?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Kristian Waagan updated DERBY-4928:

    Attachment: derby-4928-1a-depman_sync_and_cleanup.diff

Attaching patch 1a.

This patch primarily addresses incorrect synchronization in BasicDependencyManager. The rule
was already described in the class, but the implementation didn't obey them:
 o use synchronized (this) when accessing in-memory dependencies (deps stored in BasicDependencyManager)
 o don't use synchronized (this) when accessing stored dependencies, but rely on database
locking (deps stored in the data dictionary / a system table)

I haven't come across cases where we need to synchronize over both sets of dependencies (at
the same time).

Main changes in BasicDependecyManager:
 o split body of addDepencendy into addInMemoryDependency and addStoredDependency
 o corrected JavaDoc for coreInvalidateFor (the flag 'forSync' doesn't exist)
 o fixed synchronization in clearDependencies (this is where the automatic index stats update
feature got stuck in a deadlock)
 o reformatted (+tiny refactoring) clearInMemoryDependencies
 o deleted commented out methods getAllProviders and getAllProvidersInfos
 o removed synchronized for getPersistentProvidersInfos and rewrote method
 o removed synchronized for copyDependencies
 o fixed synchronization in countDependencies
 o deleted unused method dumpDependencies (and then bubbleSort)
 o rewrote methods getProviders and getDependents for new sync rules
 o replaced HashTable with Map
 o removed methods newSList

Changes in ViewsTest and BaseJDBCTestCase:
 o added method assertStatementErrorUnordered, as the ordering of in-memory and stored dependencies
changed to to the changes described above (this can easily be switched back, but I don't see
why - decided to make the test more resilient to varying ordering instead).
 o used the new assert method were the test failed

Re-running regression tests.
Patch ready for review.

> Deadlock-prone synchronization in BasicDependencyManager
> --------------------------------------------------------
>                 Key: DERBY-4928
>                 URL: https://issues.apache.org/jira/browse/DERBY-4928
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions:
>            Reporter: Kristian Waagan
>            Assignee: Kristian Waagan
>         Attachments: derby-4928-1a-depman_sync_and_cleanup.diff
> The synchronization in BasicDependencyManager is prone to deadlock, because database
locks are obtained while holding the monitor on "this".
> Problem observed when testing the automatic index statistics update prototype.
> There are comments in the file suggesting that in-memory dependencies should be accessed
while holding the Java monitor, but the monitor should not be held when accessing stored dependencies.
The implementation is breaking this rule/suggestion.

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

View raw message