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

Pavel Pereslegin edited comment on IGNITE-10250 at 11/22/18 11:54 AM:
----------------------------------------------------------------------

I managed to reproduce this problem only on atomic partitioned/replicated cache 
with a single node.

In case of concurrent notifications from the cache when changing the queue 
header, we can observe the following execution order:
 (initially queue size = 0, capacity = 1).
{noformat}
T1 (put)
onHeaderChanged("queue full" notification)

T2 (take)
onHeaderChanged("queue empty" notification)
{noformat}
if T2 somehow go ahead T1, then T1 can drain permits that T2 has released.
{noformat}
T2 ("queue empty" notification)
drainPermits()
release(1)

T1 ("queue full" notification)
drainPermits()
{noformat}
As a result, T1 waits infinitely for the semaphore permit to invoke next put.
 To resolve this problem we can drain permits only if queue is not full.


was (Author: xtern):
I managed to reproduce this problem only on atomic partitioned/replicated cache 
with a single node.

In case of concurrent notifications from the cache when changing the queue 
header, we can observe the following execution order:
 (initially queue size = 0, capacity = 1).
{noformat}
T3 (put)
onHeaderChanged("queue full" notification)

T4 (take)
onHeaderChanged("queue empty" notification)
{noformat}
if T4 somehow go ahead T3, then T3 can drain permits that T4 has released.
{noformat}
T4 ("queue empty" notification)
drainPermits()
release(1)

T3 ("queue full" notification)
drainPermits()
{noformat}
As a result, T3 waits infinitely for the semaphore permit to invoke next put.
 To resolve this problem we can drain permits only if queue is not full.

> Ignite Queue hangs after several read/write operations
> ------------------------------------------------------
>
>                 Key: IGNITE-10250
>                 URL: https://issues.apache.org/jira/browse/IGNITE-10250
>             Project: Ignite
>          Issue Type: Bug
>          Components: data structures
>    Affects Versions: 2.7
>            Reporter: Anton Dmitriev
>            Assignee: Pavel Pereslegin
>            Priority: Major
>             Fix For: 2.8
>
>
> Ignite Queue hangs after several read/write operations. Code to reproduce:
> {code:java}
> try (Ignite ignite = Ignition.start()) {
>   IgniteQueue<Integer> queue = ignite.queue("TEST_QUEUE", 1, new 
> CollectionConfiguration());
>   new Thread(() -> {
>     for (int i = 0;; i++) {
>       queue.put(i);
>       System.out.println("Put: " + i);
>     }
>   }).start();
>   new Thread(() -> {
>     for (int i = 0;; i++) {
>       queue.take();
>       System.out.println("Take: " + i);
>     }
>   }).start();
>   Thread.currentThread().join();
> }
> {code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to