BRBeans Rule Management APIs - Avoiding Deadlock on DB2®
 Technote (FAQ)
 
Problem
There are some scenarios using the BRBeans rule management APIs (in all releases of Enterprise Extensions 4.0) where deadlocks can occur. These scenarios can occur when two or more threads are running at the same time, each of which is using the BRBeans rule management APIs to create, update or delete rules. The deadlocks have occurred when running DB2 on Windows®. The deadlocks may or may not occur on other databases since the locking protocols at the database level may be different than those used by DB2. For DB2, the deadlock shows up as a transaction being rolled back. An exception from DB2 appears in the standard output log of the WebSphere® Application Server in which the BRBeans enterprise Java beans (EJBs) are running.
 
Cause
The message text of the exception indicates that a transaction is being rolled back due to a deadlock. The actual text seen in the log is as follows:

COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0911N The current transaction has been rolled back because of a deadlock or timeout. Reason code "2". SQLSTATE=40001
 
Solution
If deadlocks are occurring as described above, all of the following should be done to reduce their likelihood:

1. Install the Enterprise Extensions release 4.1 if it is not already installed.  Several changes were made to the BRBeans
code in this release to make deadlocks less likely.

2. Create an index over the RULENAME column of the EJB.BRBEANS_RULE table.  This will accomplish two things.  First, it will mean that certain queries that are performed during some rule management operations will lock fewer rows in the table because a scan of the entire table is no longer necessary.  This reduces the chances of deadlocks.  Second, the fact that a table scan is not needed will generally increase performance, both during rule management and, more importantly, when rules are actually being triggered since a rule trigger entails a query by rule name.

3. Change the program using the rule management APIs to perform all rule creations, updates, and deletions using rule copies instead of calling methods on the Rule EJB directly.  The BRBeans changes in release 4.1 make these operations fairly immune to deadlocks if they are performed through rule copies.  The corresponding operations performed directly on the Rule EJB still have potential deadlocks at this time.  The BRBeans team will look into eliminating these potential deadlocks in a future release.  For more information on how to use rule copies, refer to the documentation for the BRBeans rule management APIs.
 
 
Cross Reference information
Segment Product Component Platform Version Edition
Application Servers WebSphere Application Server Enterprise Business Rule Beans
 
 


Document Information


Product categories: Software > Application Servers > Distributed Application & Web Servers > WebSphere Application Server
Operating system(s): HP-UX
Software version: 4.0.1
Software edition:
Reference #: 1048991
IBM Group: Software Group
Modified date: Dec 15, 2003