Diamond Problem

Discussions

EJB design: Diamond Problem

  1. Diamond Problem (2 messages)

    What is an diamond problem of data base.

    Threaded Messages (2)

  2. Diamond Problem[ Go to top ]

    Hi,

    Diamond problem is more related to transaction managers than to databases. Diamond problems can arise both in transactions that are local as well as distributed. However, I would try to explain diamond problem in general and then what all a transaction framework can do to solve this diamond problems.

    Consider a single transaction that involves 3 components (may be EJBs, MTS or CORBA components) say A, B and C. Now a method call on A in turn makes method calls on B and C (these method calls are serialized and not concurrent, since they take place within the same transaction context). Imagine a situation where B and C, both access the same piece of data. So if you visualize, this situation forms a diamond. A making calls to B and C which in turn accesses the same piece of data (may be a single row or multiple rows), within the same transaction. Here the problem is, data that is cached by C may now become inconsistent after B altered the same set of data. So now the question is, how would the transaction framework (or transaction manager) and application server co-ordinate with each other, so that the data that is available to component C is consistent enough to reflect the changes made by a method call on B?

    If the underlying infrastructure is able to solve this problem then it is supposed to provide Diamond Problem Solution. Now based on whether components A, B and C (in our case) are located in the same process (local diamond) or different processes (distributed diamond), solutions can be different. For example, in order to handle distributed diamonds, the infrastructure (i.e. container in J2EE) can synchronize the data with the database by loading it each time a method call is made on the components, in the same transaction, that happen to access the same data set. This is just one of the techniques (that I believe many EJB containers are using for solving distributed diamonds) to solve this problem. I am sure there are other existing techniques too, to solve this problem.

    Hope this helps,
    Reema.
  3. Diamond Problem[ Go to top ]

    <q>
    For example, in order to handle distributed diamonds, the infrastructure (i.e. container in J2EE) can synchronize the data with the database by loading it each time a method call is made on the components, in the same transaction, that happen to access the same data set.
    </q>
    I doubt this gonna work, depend on the underlying database,
    one party may not able to see the other party's changes in
    the database, even though they are in the same transaction.
    The container should route the requests related to
    the same data set to ONE bean, thus break the diamond.