You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Srikanth R <sr...@trigent.com> on 2005/07/21 14:42:21 UTC
JTA transaction with PB API
Hi,
I am using OJB 1.0.0 in Jboss [3.2.5] environment. The
PersistenceBrokerFactoryClass used is "PersistenceBrokerFactorySyncImpl". We
are using PB API and per broker cache.
I am having problem with the PB / JTA transactions. Below is the scenario:
I have two session beans. First session bean's method A is calling second
session bean's method B. The "trans-attribute" of method A is "Required" and
that of method B is "RequiresNew".
The method B updates a record in the database. This updated record is
fetched from database in method A after the call to method B.
But when we retrieve this record, we are getting the old values and not the
updated values.
I am under the assumption that once method B is completed, the data should
be committed to the database.
Is my assumption true? If so, then what could be the problem??
Thanks,
Sriki
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: JTA transaction with PB API
Posted by Armin Waibel <ar...@apache.org>.
Hi Sriki,
sounds strange!
Srikanth R wrote:
> Hi Armin,
>
> We thought this could be becoz of broker cache. So we did some more testing
> as follows:
>
> 1. Close the broker in method A after the call to method B.
> 2. Obtain a new broker in method A after the call to method B. Use this
> broker to find the updated values.
>
> Even after doing this, sometimes we get STALE data.
>
> The behaviour is unpredictable. Sometimes we get the updated value and some
> times we get the old values.
>
> This behaviour happens when there are concurrent users doing the same
> transaction. This we have reporduced using "Grinder" load testing tool. To
> handle the concurrent users, we have put the static SYNCHRONIZE block inside
> method B.
>
This could only happen when different clients use the same PB- or
connection instance or when a global/shared cache is used.
1. Make sure that you are using DataSource from your appServer in
jdbc-connection-descriptor? Local/direct access via jdbcDriver is not
allowed.
2. Did you check the caching? Make sure that no global cache (e.g.
ObjectCacheDefaultImpl) is used. Only empty- or per-broker cache is allowed.
3. Did you share PersistenceBroker instances (PB instances are NOT
thread-safe)? Make sure that in each method** of your session bean a new
PB instance was used (PBF.create...), close this instance at the end of
the method, because session beans are pooled and stateless.
**= clarification: for all public bean methods, internal used methods
can use a PB argument.
4. Never pool any PB instances by your own.
Hope this help.
regards
Armin
> Even after doing this, we get STALE data from the new broker.
>
> If i bypass OJB, that is, if i do a direct JDBC call then i get the updated
> values always.
>
> Any thoughts on this.
>
> Regards,
> Sriki
>
> -----Original Message-----
> From: Armin Waibel [mailto:arminw@apache.org]
> Sent: Thursday, July 21, 2005 6:42 PM
> To: OJB Users List
> Subject: Re: JTA transaction with PB API
>
>
> Hi Sirki,
>
> > I am under the assumption that once method B is completed, the data
> should
> > be committed to the database.
> >
> > Is my assumption true?
>
> yep, I suppose so.
>
>
> > If so, then what could be the problem??
>
> think the problem is the per broker cache. When bean B is used the
> running tx of bean A will be suspended and a new tx for bean B starts.
> Bean B lookup a PB instance and OJB return a new PB instance, because
> now we use a different tx, so OJB can't reuse the PB instance from Bean
> A. If the object updated in Bean B was used in A too, then in the
> broker-cache of the PB instance used in bean A the outdated object will
> still be remain.
>
> Did you try to running your test without an cache?
>
> regards,
> Armin
>
> Srikanth R wrote:
>
>>Hi,
>>
>>I am using OJB 1.0.0 in Jboss [3.2.5] environment. The
>>PersistenceBrokerFactoryClass used is "PersistenceBrokerFactorySyncImpl".
>
> We
>
>>are using PB API and per broker cache.
>>
>>I am having problem with the PB / JTA transactions. Below is the scenario:
>>
>>I have two session beans. First session bean's method A is calling second
>>session bean's method B. The "trans-attribute" of method A is "Required"
>
> and
>
>>that of method B is "RequiresNew".
>>
>>The method B updates a record in the database. This updated record is
>>fetched from database in method A after the call to method B.
>>
>>But when we retrieve this record, we are getting the old values and not
>
> the
>
>>updated values.
>>
>>I am under the assumption that once method B is completed, the data should
>>be committed to the database.
>>
>>Is my assumption true? If so, then what could be the problem??
>>
>>Thanks,
>>Sriki
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
RE: JTA transaction with PB API
Posted by Srikanth R <sr...@trigent.com>.
Hi Armin,
We thought this could be becoz of broker cache. So we did some more testing
as follows:
1. Close the broker in method A after the call to method B.
2. Obtain a new broker in method A after the call to method B. Use this
broker to find the updated values.
Even after doing this, sometimes we get STALE data.
The behaviour is unpredictable. Sometimes we get the updated value and some
times we get the old values.
This behaviour happens when there are concurrent users doing the same
transaction. This we have reporduced using "Grinder" load testing tool. To
handle the concurrent users, we have put the static SYNCHRONIZE block inside
method B.
Even after doing this, we get STALE data from the new broker.
If i bypass OJB, that is, if i do a direct JDBC call then i get the updated
values always.
Any thoughts on this.
Regards,
Sriki
-----Original Message-----
From: Armin Waibel [mailto:arminw@apache.org]
Sent: Thursday, July 21, 2005 6:42 PM
To: OJB Users List
Subject: Re: JTA transaction with PB API
Hi Sirki,
> I am under the assumption that once method B is completed, the data
should
> be committed to the database.
>
> Is my assumption true?
yep, I suppose so.
> If so, then what could be the problem??
think the problem is the per broker cache. When bean B is used the
running tx of bean A will be suspended and a new tx for bean B starts.
Bean B lookup a PB instance and OJB return a new PB instance, because
now we use a different tx, so OJB can't reuse the PB instance from Bean
A. If the object updated in Bean B was used in A too, then in the
broker-cache of the PB instance used in bean A the outdated object will
still be remain.
Did you try to running your test without an cache?
regards,
Armin
Srikanth R wrote:
> Hi,
>
> I am using OJB 1.0.0 in Jboss [3.2.5] environment. The
> PersistenceBrokerFactoryClass used is "PersistenceBrokerFactorySyncImpl".
We
> are using PB API and per broker cache.
>
> I am having problem with the PB / JTA transactions. Below is the scenario:
>
> I have two session beans. First session bean's method A is calling second
> session bean's method B. The "trans-attribute" of method A is "Required"
and
> that of method B is "RequiresNew".
>
> The method B updates a record in the database. This updated record is
> fetched from database in method A after the call to method B.
>
> But when we retrieve this record, we are getting the old values and not
the
> updated values.
>
> I am under the assumption that once method B is completed, the data should
> be committed to the database.
>
> Is my assumption true? If so, then what could be the problem??
>
> Thanks,
> Sriki
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: JTA transaction with PB API
Posted by Armin Waibel <ar...@apache.org>.
Hi Sirki,
> I am under the assumption that once method B is completed, the data
should
> be committed to the database.
>
> Is my assumption true?
yep, I suppose so.
> If so, then what could be the problem??
think the problem is the per broker cache. When bean B is used the
running tx of bean A will be suspended and a new tx for bean B starts.
Bean B lookup a PB instance and OJB return a new PB instance, because
now we use a different tx, so OJB can't reuse the PB instance from Bean
A. If the object updated in Bean B was used in A too, then in the
broker-cache of the PB instance used in bean A the outdated object will
still be remain.
Did you try to running your test without an cache?
regards,
Armin
Srikanth R wrote:
> Hi,
>
> I am using OJB 1.0.0 in Jboss [3.2.5] environment. The
> PersistenceBrokerFactoryClass used is "PersistenceBrokerFactorySyncImpl". We
> are using PB API and per broker cache.
>
> I am having problem with the PB / JTA transactions. Below is the scenario:
>
> I have two session beans. First session bean's method A is calling second
> session bean's method B. The "trans-attribute" of method A is "Required" and
> that of method B is "RequiresNew".
>
> The method B updates a record in the database. This updated record is
> fetched from database in method A after the call to method B.
>
> But when we retrieve this record, we are getting the old values and not the
> updated values.
>
> I am under the assumption that once method B is completed, the data should
> be committed to the database.
>
> Is my assumption true? If so, then what could be the problem??
>
> Thanks,
> Sriki
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org