You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by afedotov <al...@gmail.com> on 2017/05/10 17:12:34 UTC

Re: Closures stuck in 2.0 when try to add an element into the queue.

Hi,

Please properly subscribe to the mailing list so that the community can
receive email notifications for your messages. To subscribe, send empty
email to user-subscribe@ignite.apache.org and follow simple instructions in
the reply.

Kind regards,
Alex.

On Wed, May 10, 2017 at 2:30 PM, fatality [via Apache Ignite Users] <
ml+s70518n12587h31@n6.nabble.com> wrote:

> Hi
>
> We have a use case as below
>
>
> 1-) Start 2 ignite instance as data nodes and insert data into the cache.
> 2-)Create a queue and register a remote listener by using remoteListen as
> below
>
> //Queue creation
> CollectionConfiguration colCfg = new CollectionConfiguration();
> colCfg.setCacheMode(PARTITIONED);
> IgniteQueue<BinaryObject> queue = Ignition.ignite().queue(queueName, 0,
> colCfg);
>
> //Remote Listener Closure
> IgnitePredicate<CacheEvent> rmtLsnr = new IgnitePredicate<CacheEvent>() {
>                         @Override public boolean apply(CacheEvent evt) {
>                                 System.out.println("Cache event [name=" +
> evt.name() + ", key=" + evt.key() + ']');
>                 Ignite ignite = Ignition.ignite();
>                 IgniteQueue<String> queue = ignite.queue(queueName, 0,
> null);
>                 String key = evt.key();
>                 BinaryObject profile = (BinaryObject) evt.newValue();
>                 System.out.println("Received event [evt=" + evt.name() +
> ", key=" + evt.key() +
>                         ", oldVal=" + evt.oldValue().toString() + ",
> newVal=" + evt.newValue().toString());
>
>                 if (profile.<Double>field("usage") > start &&
> profile.<Double>field("usage") < end
>                         && ignite.affinity("profileCache"
> ).isPrimary(ignite.cluster().localNode(), key)){
>                     queue.add(profile.field("number"));
>                 }
>                                 return false;
>                         }
>                 };
>
>
> Ignition.ignite().events(ignite.cluster().forCacheNodes("profileCache")).remoteListen(1,1l,false,null,
> rmtLsnr,
>                                 EVT_CACHE_OBJECT_PUT,
> EVT_CACHE_OBJECT_REMOVED);
>
>
> 3-)Do some updates in the cache instances as below to get updates into the
> remotelistener.
>
>     void updateAnyProfile(Double newDataUsage){
>     SqlQuery qry = new SqlQuery(VeonProfile.class,"select * from
> VeonProfile where dataUsage < 30 limit 10");
>         List<CacheEntryImpl<String, VeonProfile>> res =
> veonProfileCache.query(qry).getAll();
>         VeonProfile profile = res.iterator().next().getValue();
>         profile.setDataUsage(newDataUsage);
>         veonProfileCache.put(profile.getCtn(), profile);
>         profile.setDataUsage(newDataUsage+1);
>         veonProfileCache.put(profile.getCtn(), profile);
>
>     }
>
>
> 4-) Take the elements from the queue.
>
>         public void readFromQueue (String queueName) {
>         // Initialize new FIFO queue.
>         IgniteQueue<String> queue = Ignition.ignite().queue(queueName, 0,
> null);
>         while (true) {
>             String profile = queue.take();
>             System.out.println("Profile from queue: " +
> profile.toString());
>         }
>     }
>
> The problem is application hangs to do any operation after doing above
> scenario. Could you please help us? We would really appriciate if you could
> tell us what we are doing wrong?
>
> Below is the thread dump of the hanging datanode and same datanode hangs
> at  below code           IgniteQueue<String> queue =
> ignite.queue(queueName, 0, null);
>
>
> "sys-stripe-5-#6%null%" #25 prio=5 os_prio=31 tid=0x00007fd88d031800
> nid=0x14c07 waiting on condition [0x00007000036e7000]
>    java.lang.Thread.State: WAITING (parking)
>         at sun.misc.Unsafe.park(Native Method)
>         at java.util.concurrent.locks.LockSupport.park(LockSupport.java:304)
>
>         at org.apache.ignite.internal.util.future.GridFutureAdapter.
> get0(GridFutureAdapter.java:176)
>         at org.apache.ignite.internal.util.future.GridFutureAdapter.
> get(GridFutureAdapter.java:139)
>         at org.apache.ignite.internal.processors.cache.
> GridCacheAdapter.get0(GridCacheAdapter.java:4482)
>         at org.apache.ignite.internal.processors.cache.
> GridCacheAdapter.get(GridCacheAdapter.java:4463)
>         at org.apache.ignite.internal.processors.cache.
> GridCacheAdapter.get(GridCacheAdapter.java:1405)
>         at org.apache.ignite.internal.processors.cache.datastructures.
> CacheDataStructuresManager.queue0(CacheDataStructuresManager.java:270)
>         at org.apache.ignite.internal.processors.cache.datastructures.
> CacheDataStructuresManager.queue(CacheDataStructuresManager.java:231)
>         at org.apache.ignite.internal.processors.datastructures.
> DataStructuresProcessor$12.applyx(DataStructuresProcessor.java:952)
>         at org.apache.ignite.internal.processors.datastructures.
> DataStructuresProcessor$12.applyx(DataStructuresProcessor.java:950)
>         at org.apache.ignite.internal.processors.datastructures.
> DataStructuresProcessor.getCollection(DataStructuresProcessor.java:1078)
>         at org.apache.ignite.internal.processors.datastructures.
> DataStructuresProcessor.queue(DataStructuresProcessor.java:950)
>         at org.apache.ignite.internal.IgniteKernal.queue(IgniteKernal.java:3560)
>
>         at com.veon.ignite.trial.roaming.ProfileService$4.apply(ProfileService.java:303)
>
>         at com.veon.ignite.trial.roaming.ProfileService$4.apply(ProfileService.java:297)
>
>         at org.apache.ignite.internal.GridEventConsumeHandler$2.onEvent(
> GridEventConsumeHandler.java:170)
>         at org.apache.ignite.internal.managers.eventstorage.
> GridEventStorageManager$LocalListenerWrapper.onEvent(
> GridEventStorageManager.java:1311)
>         at org.apache.ignite.internal.managers.eventstorage.
> GridEventStorageManager.notifyListeners(GridEventStorageManager.java:892)
>         at org.apache.ignite.internal.managers.eventstorage.
> GridEventStorageManager.record0(GridEventStorageManager.java:340)
>         at org.apache.ignite.internal.managers.eventstorage.
> GridEventStorageManager.record(GridEventStorageManager.java:297)
>         at org.apache.ignite.internal.processors.cache.
> GridCacheEventManager.addEvent(GridCacheEventManager.java:297)
>         at org.apache.ignite.internal.processors.cache.
> GridCacheMapEntry.innerUpdate(GridCacheMapEntry.java:1806)
>         - locked <0x00000007b6d01f10> (a org.apache.ignite.internal.
> processors.cache.distributed.dht.atomic.GridDhtAtomicCacheEntry)
>         at org.apache.ignite.internal.processors.cache.distributed.
> dht.atomic.GridDhtAtomicCache.updateSingle(GridDhtAtomicCache.java:2386)
>         at org.apache.ignite.internal.processors.cache.distributed.
> dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal0(GridDhtAtomicCache.java:1792)
>
>         at org.apache.ignite.internal.processors.cache.distributed.
> dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal(GridDhtAtomicCache.java:1630)
>
>         at org.apache.ignite.internal.processors.cache.distributed.
> dht.atomic.GridDhtAtomicCache.processNearAtomicUpdateRequest(GridDhtAtomicCache.java:3016)
>
>         at org.apache.ignite.internal.processors.cache.distributed.
> dht.atomic.GridDhtAtomicCache.access$400(GridDhtAtomicCache.java:127)
>         at org.apache.ignite.internal.processors.cache.distributed.
> dht.atomic.GridDhtAtomicCache$6.apply(GridDhtAtomicCache.java:282)
>         at org.apache.ignite.internal.processors.cache.distributed.
> dht.atomic.GridDhtAtomicCache$6.apply(GridDhtAtomicCache.java:277)
>         at org.apache.ignite.internal.processors.cache.GridCacheIoManager.
> processMessage(GridCacheIoManager.java:863)
>         at org.apache.ignite.internal.processors.cache.
> GridCacheIoManager.onMessage0(GridCacheIoManager.java:386)
>         at org.apache.ignite.internal.processors.cache.GridCacheIoManager.
> handleMessage(GridCacheIoManager.java:308)
>         at org.apache.ignite.internal.processors.cache.
> GridCacheIoManager.access$000(GridCacheIoManager.java:100)
>         at org.apache.ignite.internal.processors.cache.
> GridCacheIoManager$1.onMessage(GridCacheIoManager.java:253)
>         at org.apache.ignite.internal.managers.communication.
> GridIoManager.invokeListener(GridIoManager.java:1257)
>         at org.apache.ignite.internal.managers.communication.
> GridIoManager.processRegularMessage0(GridIoManager.java:885)
>         at org.apache.ignite.internal.managers.communication.
> GridIoManager.access$2100(GridIoManager.java:114)
>         at org.apache.ignite.internal.managers.communication.
> GridIoManager$7.run(GridIoManager.java:802)
>         at org.apache.ignite.internal.util.StripedExecutor$Stripe.run(StripedExecutor.java:483)
>
>         at java.lang.Thread.run(Thread.java:748)
>
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://apache-ignite-users.70518.x6.nabble.com/Closures-
> stuck-in-2-0-when-try-to-add-an-element-into-the-queue-tp12587.html
> To start a new topic under Apache Ignite Users, email
> ml+s70518n1h65@n6.nabble.com
> To unsubscribe from Apache Ignite Users, click here
> <http://apache-ignite-users.70518.x6.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1&code=YWxleGFuZGVyLmZlZG90b2ZmQGdtYWlsLmNvbXwxfC0xMzYxNTU0NTg=>
> .
> NAML
> <http://apache-ignite-users.70518.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Closures-stuck-in-2-0-when-try-to-add-an-element-into-the-queue-tp12587p12603.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Closures stuck in 2.0 when try to add an element into the queue.

Posted by afedotov <al...@gmail.com>.
Hi.

The question was answered on stackoverflow
<http://stackoverflow.com/questions/43891757/closures-stuck-in-2-0-when-try-to-add-an-element-into-the-queue>.
Duplicating
the answer below:

It's not allowed to invoke ignite.queue and ignite.affinity methods in
EventListener, because it may lead to deadlock.

All cache operations, including EventListeners are executed in system pool,
so it's not recommended to invoke inside EventListener operations, that
uses system pool too.

You could read more here at "Closures Execution and Thread Pools":
https://apacheignite.readme.io/docs/async-support#section-listeners-and-chaining-futures

And here
https://apacheignite.readme.io/docs/thread-pools#section-system-pool

Kind regards,
Alex.

On Thu, May 11, 2017 at 2:17 PM, fatality [via Apache Ignite Users] <
ml+s70518n12628h2@n6.nabble.com> wrote:

> Hi
>
> I have just subscribed to the user group also same question is posted at
> http://stackoverflow.com/questions/43891757/closures-
> stuck-in-2-0-when-try-to-add-an-element-into-the-queue
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://apache-ignite-users.70518.x6.nabble.com/Closures-
> stuck-in-2-0-when-try-to-add-an-element-into-the-queue-tp12587p12628.html
> To start a new topic under Apache Ignite Users, email
> ml+s70518n1h65@n6.nabble.com
> To unsubscribe from Apache Ignite Users, click here
> <http://apache-ignite-users.70518.x6.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1&code=YWxleGFuZGVyLmZlZG90b2ZmQGdtYWlsLmNvbXwxfC0xMzYxNTU0NTg=>
> .
> NAML
> <http://apache-ignite-users.70518.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Closures-stuck-in-2-0-when-try-to-add-an-element-into-the-queue-tp12587p12936.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Closures stuck in 2.0 when try to add an element into the queue.

Posted by fatality <fa...@gmail.com>.
Hi 

I have just subscribed to the user group also same question is posted at
http://stackoverflow.com/questions/43891757/closures-stuck-in-2-0-when-try-to-add-an-element-into-the-queue



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Closures-stuck-in-2-0-when-try-to-add-an-element-into-the-queue-tp12587p12628.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Closures stuck in 2.0 when try to add an element into the queue.

Posted by fatality <fa...@gmail.com>.
Hi 

I have just subscribed to the user group also same question is posted at
http://stackoverflow.com/questions/43891757/closures-stuck-in-2-0-when-try-to-add-an-element-into-the-queue



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Closures-stuck-in-2-0-when-try-to-add-an-element-into-the-queue-tp12587p12609.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.