0

I'm writing a red5 application that actually is on a tomcat server and uses the spring framework that connects to a mysql server (the fact that it's a red5 application shouldn't really matter, it's a java ee app.)

i use the spring framework to connect to my database.

I noticed that on some of the queries I get the following error message

Lock wait timeout exceeded; try restarting transaction

I already configured the lock timeout on my server to 10 seconds, so it's got to be something in my server. I would like to debug the mysql server whenever this happens. Maybe to run show processlist and to get the output or to throw proper error messages.

Is there a way to connect a hook of some sort to the JdbcTemplate that I'm using within the spring framework to handle all cases of lock timeout? Maybe to try to retry several times, to send messages and so on.

So the thing is that I do not want to check SQLException in each place in my project and to handle it individually. This is a big project it would take a long time. Is there a way to configure that whenever an SQLException is thrown? I'll be able to check which kind and to handle and to allow to retry, but to build something generic instead of inserting try catch and handle on each query?

skaffman
  • 398,947
  • 96
  • 818
  • 769
ufk
  • 30,912
  • 70
  • 235
  • 386
  • see if this helps.. http://stackoverflow.com/questions/6000336/how-to-debug-lock-wait-timeout-exceeded – Fahim Parkar Feb 12 '12 at 11:44
  • thanks but i want to handle it using java code. i don't want to increase the deadlock even more – ufk Feb 12 '12 at 16:43

1 Answers1

1

If the exception is propagating all the way out of your handler, you could try implementing a HandlerExceptionResolver and do some querying and logging the debugging data there, when the exception is caught.

You could also subclass the JdbcTemplate, and override needed methods, wrapping a call to the super-implementation with a try-catch (rethrowing as necessary), then checking for the exception and handling recovery/debugging.

esaj
  • 15,875
  • 5
  • 38
  • 52