Our system, running on WepSphere 5.1 is getting a lot of DB2 deadlock errors: DB2 SQLCODE: -911, SQLSTATE: 40001
I have posted more information at the end of this message about our environment as well as a full description from IBM of the error message.
There are two meanings for this error, lock timeout and deadlock. Our DBA feels it must be a deadlock becuase the lock timeout is set to never timeout.
We have structured our application in such a way that all of our database interaction consists of short transactions. I have scoured the code and verified that all database interaction is wrapped in a block like this:
session = sessionFactory.openSession();
try {
tx = session.beginTransaction();
try {
......
tx.commit();
}
catch (Exception ex) {
tx.rollback();
throw ex;
}
}
finally {
session.close();
}
The point is, I'm confident that we are always commiting or rolling back our transactions and we are always closing the session right away.
Does anybody have any suggestions how we could go about troubleshooting this problem?
Thanks,
Bryan
More info:
Hibernate version:
2.1
Full stack trace of any exception that occurs:
[8/2/06 10:02:49:731 EDT] 6244bc01 WebGroup E SRVE0026E: [Servlet Error]-[DB2 SQL error: SQLCODE: -911, SQLSTATE: 40001, SQLERRMC: 2]: net.sf.hibernate.CallbackException: DB2 SQL error: SQLCODE: -911, SQLSTATE: 40001, SQLERRMC: 2
at avatopia.auditlog.AuditLogInterceptor.setContextUserInfo(AuditLogInterceptor.java(Compiled Code))
at avatopia.auditlog.AuditLogInterceptor.setContextUserInfo(AuditLogInterceptor.java(Inlined Compiled Code))
at avatopia.auditlog.AuditLogInterceptor.preFlush(AuditLogInterceptor.java(Compiled Code))
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java(Compiled Code))
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java(Compiled Code))
at net.sf.hibernate.transaction.JTATransaction.commit(JTATransaction.java(Compiled Code))
at avatopia.dailylog.DailyLogService.saveDailyLog(DailyLogService.java(Compiled Code))
at avatopia.struts.dailylog.DailyLogActions.saveDailyLog(DailyLogActions.java(Compiled Code))
at java.lang.reflect.Method.invoke(Native Method)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java(Compiled Code))
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java(Compiled Code))
at avatopia.struts.AvatopiaBaseDispatchAction.execute(AvatopiaBaseDispatchAction.java(Compiled Code))
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java(Inlined Compiled Code))
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java(Compiled Code))
at org.apache.struts.action.ActionServlet.process(ActionServlet.java(Compiled Code))
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServicingServletState.service(StrictLifecycleServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java(Inlined Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java(Inlined Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java(Compiled Code))
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java(Compiled Code))
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java(Compiled Code))
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java(Compiled Code))
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java(Compiled Code))
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java(Compiled Code))
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java(Compiled Code))
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java(Compiled Code))
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java(Compiled Code))
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
Name and version of the database you are using:
DB2 Universal Database 8.1 Fixpak 11
Info from IBM on the message we are getting:
SQL0911N The current transaction has been
rolled back because of a deadlock
or timeout. Reason code
reason-code.
Explanation: The current unit of work was
involved in an unresolved contention for use of
an object and had to be rolled back.
The reason codes are as follows:
2 transaction rolled back due to deadlock.
68 transaction rolled back due to lock
timeout.
72 transaction rolled back due to an error
concerning a DB2 Data Links Manager
involved in the transaction.
Note: The changes associated with the unit of
work must be entered again.
The application is rolled back to the previous
COMMIT.
User Response: To help avoid deadlock or lock
timeout, issue frequent COMMIT operations, if
possible, for a long-running application, or for an
application likely to encounter a deadlock.
Federated system users: the deadlock can occur
at the federated server or at the data source.
There is no mechanism to detect deadlocks that
span data sources and potentially the federated
system. It is possible to identify the data source
failing the request (refer to the problem
determination guide to determine which data
source is failing to process the SQL statement).
Deadlocks are often normal or expected while
processing certain combinations of SQL
statements. It is recommended that you design
applications to avoid deadlocks to the extent
possible.
sqlcode: -911
sqlstate: 40001
|