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

Kartik commented on CAMEL-19619:
--------------------------------

So according to you, each route will spin 2 thread pool each with 10 threads as 
we have 2 throttles; also I want to know why the thread is needed for 
throttling. we can use one polling thread at regular intervals which resumes 
the consumer if time has elapsed and the consumer will block itself if exceeded 
the limit after processing the exchange. Also can't we use something like 
Quartz scheduler triggers? Looks like an enhancement to me.

Meanwhile, if I provide a shared thread pool with 4 threads in the pool and 4 
of my user consumes more messages than allowed and are blocked what happens to 
the 5th user when he/she exhausts the allowed limit as there are no thread to 
handle?

> Throttle when used in camel-kafka route creates thread leak
> -----------------------------------------------------------
>
>                 Key: CAMEL-19619
>                 URL: https://issues.apache.org/jira/browse/CAMEL-19619
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 3.14.9
>            Reporter: Kartik
>            Priority: Critical
>         Attachments: image-2023-07-19-19-33-10-591.png, 
> image-2023-07-19-19-33-33-151.png, image-2023-07-19-20-05-52-306.png
>
>
> I have used throttle in the camel Kafka route to control the message flow and 
> I have 10 routes running initially there will be no throttle thread created 
> as soon as the message comes to the Kafka topic and read huge number of 
> throttle threads are created.
>  
> For 10 routes I see 88 throttle "threads" threads created and are doing no 
> work.
>  
> !image-2023-07-19-19-33-10-591.png!
>  
> !image-2023-07-19-19-33-33-151.png!
>  
> Stack trace of each throttle thread.
> "Camel (InfaDefaultCamelContext) thread #51 - Throttle" #135 daemon prio=5 
> os_prio=0 tid=0x000001dfee834000 nid=0x2dbc waiting on condition 
> [0x000000d5a2dff000]
>    java.lang.Thread.State: WAITING (parking)
>         at sun.misc.Unsafe.park(Native Method)
>         - parking to wait for  <0x000000073da9aaf0> (a 
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
>         at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
>         at 
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2044)
>         at 
> java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1088)
>         at 
> java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
>         at 
> java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
>         at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
>         at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>         at java.lang.Thread.run(Thread.java:750)
>  
>    Locked ownable synchronizers:
>         - None
>  
> "Camel (InfaDefaultCamelContext) thread #50 - Throttle" #134 daemon prio=5 
> os_prio=0 tid=0x000001dfee835800 nid=0x71d4 waiting on condition 
> [0x000000d5a2cfe000]
>    java.lang.Thread.State: WAITING (parking)
>         at sun.misc.Unsafe.park(Native Method)
>         - parking to wait for  <0x000000073db8c0c0> (a 
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
>         at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
>         at 
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2044)
>         at 
> java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1088)
>         at 
> java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
>         at 
> java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
>         at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
>         at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>         at java.lang.Thread.run(Thread.java:750)
>  
>    Locked ownable synchronizers:
>         - None
>  
> "Camel (InfaDefaultCamelContext) thread #49 - Throttle" #133 daemon prio=5 
> os_prio=0 tid=0x000001dfee82b000 nid=0x5574 waiting on condition 
> [0x000000d5a2bfe000]
>    java.lang.Thread.State: WAITING (parking)
>         at sun.misc.Unsafe.park(Native Method)
>         - parking to wait for  <0x000000073de977d8> (a 
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
>         at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
>         at 
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2044)
>         at 
> java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1088)
>         at 
> java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
>         at 
> java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
>         at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
>         at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>         at java.lang.Thread.run(Thread.java:750)
>  
>    Locked ownable synchronizers:
>         - None
>  
> "Camel (InfaDefaultCamelContext) thread #48 - Throttle" #132 daemon prio=5 
> os_prio=0 tid=0x000001dff3b5e800 nid=0x60cc waiting on condition 
> [0x000000d5a2aff000]
>    java.lang.Thread.State: WAITING (parking)
>         at sun.misc.Unsafe.park(Native Method)
>         - parking to wait for  <0x000000073e02bf60> (a 
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
>         at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
>         at 
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2044)
>         at 
> java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1088)
>         at 
> java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
>         at 
> java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
>         at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
>         at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>         at java.lang.Thread.run(Thread.java:750)
>  
>    Locked ownable synchronizers:
>         - None
>  
> Any idea if this is a leak or configuration issue
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to