[
https://issues.apache.org/jira/browse/IGNITE-12425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16991563#comment-16991563
]
Alexey Goncharuk commented on IGNITE-12425:
-------------------------------------------
[~ilyak] the deadlock in the attached reproducer has nothing to do with the
hash map:
* The thread which holds the entry lock waits for the store balancing wrapper
to finish the load in another thread ({{pool-5-thread-2}})
* The thread which is supposed to run the actual cache load waits to acquire
the lock on the entry ({{sys-#50}})
The very same deadlock is possible even with one key involved in the test. For
a correct fix we need to make sure that the thread running the actual store
load never waits for the entry lock (or the thread that is currently holds the
entry lock never blocks on the balancing wrapper, which actually does make
sense for ATOMIC cache).
> Deadlock on CacheStore.loadAll
> ------------------------------
>
> Key: IGNITE-12425
> URL: https://issues.apache.org/jira/browse/IGNITE-12425
> Project: Ignite
> Issue Type: Bug
> Components: cache
> Affects Versions: 2.7.6
> Reporter: Ilya Kasnacheev
> Priority: Critical
> Labels: stupid
> Attachments: ignite-dataload-deadlock.zip
>
>
> Yes, we do have a deadlock in CacheStore.loadAll, as demonstrated by this
> reproducer.
> The obvious embarassing fix is to replace HashMap with TreeMap, which will of
> course not work if keys are not comparable
> {code:java}
> diff --git
> a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
>
> b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
> index 3156d6d662d..3947800a908 100644
> ---
> a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
> +++
> b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
> @@ -34,6 +34,7 @@ import java.util.List;
> import java.util.Map;
> import java.util.NoSuchElementException;
> import java.util.Set;
> +import java.util.TreeMap;
> import java.util.UUID;
> import java.util.concurrent.Callable;
> import java.util.concurrent.ExecutorService;
> @@ -2054,7 +2055,7 @@ public abstract class GridCacheAdapter<K, V> implements
> IgniteInternalCache<K, V
>
> if (res.value() == null) {
> if (misses == null)
> - misses = new HashMap<>();
> + misses = new TreeMap<>();
>
> misses.put(key, res);
>
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)