• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A lot of deadlocks using JDBC

 
Andrei Antonescu
Ranch Hand
Posts: 75
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I am using Sql Server 2008 for a web app deployed in Tomcat 6. There are a lot of simultaneous users that query the database. I get a lot of these errors in the tomcat logs:



Is it normal to be soo many of them? Can you tell me from where to start the investigation? Because I don't have a clue....

Thanks in advance
 
Jan Cumps
Bartender
Posts: 2575
11
C++ Linux Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you use "select ... for update"?
Do you keep transactions open for long time?
Do you use locking hints in your queries?
What is your connection's transaction isolation level? Have you specified it?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Do you use "select ... for update"?

SQL Server doesn't support his construct. But the question is still valid if you are using explicit locking hints. Are you?

In SQL server you can track why deadlock are occurring with the profiling tool. If you run your application and trace deadlock events with that you should get a picture of what sort of transactions are causing the deadlocks. Alternatively, if you can't use the profiling tool you can turn on trace logging for deadlock with dbcc. You could start by reading this.
 
Andrei Antonescu
Ranch Hand
Posts: 75
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello & thanks for posting

I use the default isolation level, I don't keep the transactios open for a long time, and I don't use locking hints in my queryes.

 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to find out what the profiling tool suggests is the cause of the deadlocks - this is not something we can know. There are common patterns of behaviour that can increase the likelihood of deadlock, but rather than go through these all I would start by using the tools SQL Server supplies to get more information.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic