You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Tomek Rękawek (JIRA)" <ji...@apache.org> on 2016/02/24 15:04:18 UTC

[jira] [Commented] (OAK-3234) LIRS cache: possible deadlock while loading an entry

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

Tomek Rękawek commented on OAK-3234:
------------------------------------

Attached patch backported for 1.0 and 1.2.

> LIRS cache: possible deadlock while loading an entry
> ----------------------------------------------------
>
>                 Key: OAK-3234
>                 URL: https://issues.apache.org/jira/browse/OAK-3234
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>          Components: core
>            Reporter: Thomas Mueller
>            Assignee: Thomas Mueller
>             Fix For: 1.3.4
>
>         Attachments: OAK-3234-backported.patch
>
>
> If multiple threads concurrently load entries while they are already loading entries (using a cache loader or callable), then it is possible to get into a deadlock. For example:
> * Thread 1 loads entry A, so it is calling the loader...
> * Thread 2 loads entry B, so it is calling the loader...
> * Thread 1 (within the loader) tries to load entry B, so it waits for thread 2...
> * Thread 2 (within the loader) tries to load entry A, so it waits for thread 1...
> One solution is to detect the case that the current thread is already loading an entry, and then instead of waiting for the other thread, it can also load the entry. A small optimization for that is to only load the entry (not waiting for the other thread) if the hash code of the key is smaller or equal the entry that this thread is loading. So that there is a clear order.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)