Home > Software engineering >  Is it possible to manage mysql threads(stuck queries) from tomcat?
Is it possible to manage mysql threads(stuck queries) from tomcat?

Time:05-18

For some context, we have a really big application running on a tomcat, we have lots of ways to build custom filters, and some of them may be too slow.

The question is, there is a way i can control/kill a mysql thread directly or via tomcat(maybe thread pool)? and if there's a way to manage it from tomcat, if i kill the thread, it will kill the mysql thread too? (didn't find anything related on documentation).

I am trying to build a layer to prevent queries to stay stuck on database. For example, if a querie stay running for more than 1minute, my application can kill it(instead of me going on terminal and killing 'by hand').

Thanks in advance.

CodePudding user response:

Very likely you want to work with a connection pool. If this is managed by Tomcat, your entry point is a datasource. See the https://tomcat.apache.org/tomcat-9.0-doc/jndi-datasource-examples-howto.html how to configure that. With this you can control the amount of parallel connections the application can have on the database.

On top of that you want to configure timeouts so a stray thread will not block the database forever. See

  • Related