{"action":"created","issue":{"url":"https://api.github.com/repos/mjiderhamn/classloader-leak-prevention/issues/29","repository_url":"https://api.github.com/repos/mjiderhamn/classloader-leak-prevention","labels_url":"https://api.github.com/repos/mjiderhamn/classloader-leak-prevention/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/mjiderhamn/classloader-leak-prevention/issues/29/comments","events_url":"https://api.github.com/repos/mjiderhamn/classloader-leak-prevention/issues/29/events","html_url":"https://github.com/mjiderhamn/classloader-leak-prevention/issues/29","id":67227621,"number":29,"title":"Stopping container threads, probably inadvertently","user":{"login":"TomiTakussaari","id":1768778,"avatar_url":"https://avatars.githubusercontent.com/u/1768778?v=3","gravatar_id":"","url":"https://api.github.com/users/TomiTakussaari","html_url":"https://github.com/TomiTakussaari","followers_url":"https://api.github.com/users/TomiTakussaari/followers","following_url":"https://api.github.com/users/TomiTakussaari/following{/other_user}","gists_url":"https://api.github.com/users/TomiTakussaari/gists{/gist_id}","starred_url":"https://api.github.com/users/TomiTakussaari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TomiTakussaari/subscriptions","organizations_url":"https://api.github.com/users/TomiTakussaari/orgs","repos_url":"https://api.github.com/users/TomiTakussaari/repos","events_url":"https://api.github.com/users/TomiTakussaari/events{/privacy}","received_events_url":"https://api.github.com/users/TomiTakussaari/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":19,"created_at":"2015-04-08T21:49:53Z","updated_at":"2017-01-04T22:05:18Z","closed_at":"2015-05-02T21:02:28Z","body":"We are experiencing some strange things when using this library on our application deployed to Tomcat7.\n\n```\nClassLoaderLeakPreventor: Stopping Thread 'Thread[catalina-exec-720,5,main]' of type org.apache.tomcat.util.threads.TaskThread running in web app after 5000 ms\n```\n\nThis happens randomly during application deployment, but eventually halts all Tomcat executor threads, which then makes Tomcat quite unresponsive as all executors are in this kind of state:\n\n```\n\"catalina-exec-919\" #32896 daemon prio=5 os_prio=0 tid=0x00007f780c0f7000 nid=0x46d5 waiting on condition [0x00007f77e4c1b000]\n   java.lang.Thread.State: WAITING (parking)\n        at sun.misc.Unsafe.park(Native Method)\n        - parking to wait for  <0x00000000e08c9478> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)\n        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)\n        at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836)\n        at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:870)\n        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2083)\n        at java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467)\n        at org.apache.tomcat.util.threads.TaskQueue.poll(TaskQueue.java:86)\n```\n\nAfter a while, all threads in Tomcat threadpool (maxThreadPoolSize) will be in this state, and Tomcat will be stuck until restart\n\nHas anyone else experienced anything like this ? \nAny ideas to resolve this ? \n\nI would not want to skip shutting down threads as we do have some JDBC related threads that we do need to close.. \n"},"comment":{"url":"https://api.github.com/repos/mjiderhamn/classloader-leak-prevention/issues/comments/270500434","html_url":"https://github.com/mjiderhamn/classloader-leak-prevention/issues/29#issuecomment-270500434","issue_url":"https://api.github.com/repos/mjiderhamn/classloader-leak-prevention/issues/29","id":270500434,"user":{"login":"mjiderhamn","id":837073,"avatar_url":"https://avatars.githubusercontent.com/u/837073?v=3","gravatar_id":"","url":"https://api.github.com/users/mjiderhamn","html_url":"https://github.com/mjiderhamn","followers_url":"https://api.github.com/users/mjiderhamn/followers","following_url":"https://api.github.com/users/mjiderhamn/following{/other_user}","gists_url":"https://api.github.com/users/mjiderhamn/gists{/gist_id}","starred_url":"https://api.github.com/users/mjiderhamn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjiderhamn/subscriptions","organizations_url":"https://api.github.com/users/mjiderhamn/orgs","repos_url":"https://api.github.com/users/mjiderhamn/repos","events_url":"https://api.github.com/users/mjiderhamn/events{/privacy}","received_events_url":"https://api.github.com/users/mjiderhamn/received_events","type":"User","site_admin":false},"created_at":"2017-01-04T22:05:18Z","updated_at":"2017-01-04T22:05:18Z","body":"@szakrewsky Thanks for the log. Seems I misunderstood the issue previously (which lead to some other improvements though :-) ).\r\n\r\nI've been digging into why I'm shutting down `ThreadPoolExecutor`s in the first place, and the only reason I could find is that I was inspired by Tomcats built in leak prevention mechanism doing it. (Though I'm not sure how it avoids shutting down its own ThreadPoolExecutor.) I cannot recall having seen a real life scenario where a `ThreadPoolExecutor` has been the cause of a leak.\r\n\r\nI therefore decided to change strategy and become much more restrictive about when a `ThreadPoolExecutor` is shut down. Instead of your suggestions in 2 ii a, I went with checking if the `ThreadPoolExecutor` itself or its `ThreadFactory` is loaded by the ClassLoader that needs protecting. If neither of those conditions are fulfilled, I can at this time only imagine one scenario where this could cause a leak, and that is if the `Worker` has a `firstTask` that implies a reference to the ClassLoader, and that task does not finish. Possibly I'll look into that - or maybe I'll wait until someone reports an actual case of this happening.\r\n\r\nThis should be available on `master`, together with even more improved logging. I'd appreciate if you could test and get back with the results.\r\n\r\nI'm not sure I understand your point in 2 i and 2 ii b would supposedly be irrelevant with the changes I made (or you'd be doing something really strange)."}}
{"actor":{"display_login":"mjiderhamn"}}