knopflerfish / knopflerfish.org

Knopflerfish OSGi Service Platform. OSGi run-time container and SDK source code repo
http://www.knopflerfish.org
BSD 3-Clause "New" or "Revised" License
33 stars 11 forks source link

Http Server: threads created in transactions increase activeCount and server will eventually stop processing requests #58

Open marco-zi opened 2 years ago

marco-zi commented 2 years ago

We have the problem, that the http server sometimes becomes irresponsive. I tracked it down to the following: Transactions are no longer processed if the activeCount of the TransactionManager is higher than the configured maximum (in run method of the SocketListener). If a new thread is created during a transaction, it adds to this count because its parent is the worker thread which is in the TransactionManager group. If more threads are generated, the limit can be hit although this is not representing that (too) many transactions are queued (which i believe is the idea behind the limit). The problem can be avoided by explicitly setting the thread group of threads created during calls but i don't think anyone will be aware of the problem and do it. I propose that activeCount in TransactionManager should not be activeCount of the ThreadGroup but the number of not idle workers (num_workers or size of workers) plus the size of the transQueue. Either by overriding the activeCount method or creating a new one.