[ https://issues.apache.org/jira/browse/OAK-3234?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15163065#comment-15163065 ]
Alex Parvulescu commented on OAK-3234: -------------------------------------- FWIW we don't usually apply backported patches on branches, we do {{svn merge}} on the trunk commits so the svn history is clearer. > 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 > Labels: candidate_oak_1_0, candidate_oak_1_2 > 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)