0 Replies Latest reply on Aug 16, 2004 12:41 PM by marlig

    Need help with transaction problem in cluster

    marlig

      Hi,

      I've run into a problem while trying to move an application from a single server to a clustered environment.

      The application uses a BMP entity bean, where it first calls a finder method which returns some instances of the bean (using an SQL select query) , and then the application takes the first returned bean, changes some attributes (using a PL/SQL stored procedure) and uses these attributes further on.

      To make it a bit more understandable, let's say the bean has an attribute X. The finder returns all bean instances (table rows) where X=0. Then the application sets X to 1 (marks it as used) for the first retrieved instance and continues using this bean (assuming it has the exclusive access to it since concurrent processes will not find it because of X=1).

      This works fine on a single node, even under high load. However, when I change to the cluster (2 nodes for now), the following happens. When the same procedure runs on both cluster instances roughly at the same time, both first find the same beans, take the first bean (which is the same) and then update it. There is no concurrent access or other exception, so both processes think they have unique access to the bean. Further on, this causes some trouble, as you might guess.

      I think, that in the non-clustered environment, JBoss locks the entity bean as soon as the first transaction accesses it, thus preventing the other transactions from reading it. In the clustered environment, the two JBoss instances do not prevent this, since they only see their own entity instances.

      Now I'm wondering how to get out of this situation. Will I need to work around this with some clever SQL, or is there a way to make JBoss do the entity locking (as I imagine it) in the cluster? Or something else? I know that the entity cache will be available from JBoss 4 only.

      Btw, I'm using JBoss 3.2.4, the datasource is local, isolation level is Repeatable_Read, and commit option is C. What is the difference between "Standard BMP EntityBean" and "Clustered BMP EntityBean"?

      Thanks for your help
      Martin