[OFBiz] Users - Re: [OFBiz] Dev - Transaction Timeouts

Si Chen schen at graciousstyle.com
Thu Mar 31 14:42:56 EST 2005


Ryan,

Thanks for looking into this.  I've had intermitten problems with this 
over time and am glad somebody finally tracked it down.

Si

Ryan Warnick wrote:

>It looks like the JOTM team agrees. I will make sure this bug gets
>logged in their tracking system.
>
>Ryan
>
>-----Original Message-----
>From: tony.ortiz at objectweb.org [mailto:tony.ortiz at objectweb.org] 
>Sent: Thursday, March 31, 2005 10:27 AM
>To: Ryan Warnick
>Cc: jotm at objectweb.org
>Subject: Re: [jotm] Local Transaction Timeout Bug
>
>
>
>
>
>
>
>Ryan,
>
>We agree with your analysis. Please issue a bug report on JOTM. If you
>cannot (no permission), please let us know so that we can issue a bug
>report.
>
>Thanks,
>    Tony
>
>
>
> 
>
>             "Ryan Warnick"
>
>             <warnickr_1 at isp01
>
>             .net>
>To 
>                                       <jotm at objectweb.org>
>
>             03/31/2005 01:30
>cc 
>             AM
>
> 
>Subject 
>                                       [jotm] Local Transaction Timeout
>
>                                       Bug
>
> 
>
> 
>
> 
>
> 
>
> 
>
> 
>
>
>
>
>
>We think that this could be a bug in JOTM.  See below
>
>-----Original Message-----
>From: dev-bounces at lists.ofbiz.org [mailto:dev-bounces at lists.ofbiz.org]
>On Behalf Of A. Zeneski
>Sent: Wednesday, March 30, 2005 10:36 PM
>To: OFBiz Project Development Discussion (High Traffic)
>Cc: users at lists.ofbiz.org
>Subject: Re: [OFBiz] Dev - Transaction Timeouts
>
>
>I just reviewed the code and I agree; this does look like a bug in JOTM.
>We should contact them regarding this as it is causing a race condition.
>Here is what happens:
>
>We call setTransactionTimeout(), then begin(). A new transaction is
>created and associated with the current thread using the set timeout.
>However, if something else sets the timeout right after we do then it is
>possible that the timeout which we thought we set got overwritten.
>
>Also, the timeout does not seem to be reset.  We should see what the
>JOTM guys have to say.
>
>-Andy
>
>On Mar 30, 2005, at 6:41 PM, Ryan Warnick wrote:
>
>  
>
>>It looks like the localized transaction timeout stuff doesn't work as 
>>it was intended to.  It is my understanding that a service can define 
>>a timeout value and that this is used when creating the transaction 
>>for the service in TransactionUtil:
>>
>>    public static boolean begin(int timeout) throws 
>>GenericTransactionException {
>>         UserTransaction ut = TransactionFactory.getUserTransaction();
>>        if (ut != null) {
>>             try {
>>                 int currentStatus = ut.getStatus();
>>                 Debug.logVerbose("[TransactionUtil.begin] current 
>>status : " + getTransactionStateString(currentStatus), module);
>>
>>                if (currentStatus == Status.STATUS_ACTIVE) {
>>                     Debug.logVerbose("[TransactionUtil.begin] active 
>>transaction in place, so no transaction begun", module);
>>
>>                    return false;
>>                 } else if (currentStatus ==
>>Status.STATUS_MARKED_ROLLBACK) {
>>                     Exception e = getTransactionBeginStack();
>>                    if (e != null) {
>>                         Debug.logWarning(e, "[TransactionUtil.begin] 
>>active transaction marked for rollback in place, so no transaction 
>>begun; this stack trace shows when the exception began: ", module);
>>
>>                    } else {
>>                         Debug.logWarning("[TransactionUtil.begin]
>>active transaction marked for rollback in place, so no transaction 
>>begun", module);
>>
>>                    }
>>
>>                    throw new GenericTransactionException("The current
>>    
>>
>
>  
>
>>transaction is marked for rollback, should stop immediately.");
>>
>>                }
>>
>>                // set the timeout for THIS transaction
>>                 if (timeout > 0) {
>>                    ut.setTransactionTimeout(timeout);
>>                    Debug.logVerbose("[TransactionUtil.begin] set 
>>transaction timeout to : " + timeout + " seconds", module);
>>
>>                 }
>>
>>                // begin the transaction
>>                 ut.begin();
>>                 Debug.logVerbose("[TransactionUtil.begin] transaction
>>    
>>
>
>  
>
>>begun", module);
>>
>>                // reset the transaction stamps, just in case..  .  .
>> .
>>
>>
>>
>>On the surface, this seems like it would work, but the problem is that
>>    
>>
>
>  
>
>>JOTM doesn't seem to really have a localized transaction timeout
>>setting.  The JOTM class that implements the TransactionManager and
>>UserTransaction interfaces is the Current class.  According to the
>>JOTM javadocs, there is only one Current object per JVM.  The timeout
>>setting for a JOTM transaction is a member of the Current class.  It
>>turns out that the call to setTransactionTimeout that is made in
>>TransactionUtil is actually changing the timeout value that is of  the
>>    
>>
>
>  
>
>>Current class.  This seems strange given the following code snippets
>>from Current.java:
>>
>>    /**
>>       * Modifies the value of the timeout value that is associated
>>with the
>>       * transactions started by the current thread with the begin
>>method.
>>       *
>>       *  If    an application has not called this method, the
>>transaction
>>       * service uses some default value for the transaction timeout.
>>       *
>>       * @param timeout value of the timeout (in seconds). If the
>>value is zero,
>>       * the transaction service restores the default value.
>>       *
>>       * @exception SystemException Thrown if the transaction manager
>>       * encounters an unexpected error condition
>>       */
>>
>>    public void setTransactionTimeout(int timeout) throws
>>SystemException {
>>
>>        if (TraceTm.jta.isDebugEnabled()) {
>>             TraceTm.jta.debug("timeout="+ timeout);
>>         }
>>
>>        if (timeout > 0) {
>>             transactionTimeout = timeout;
>>         } else {
>>             transactionTimeout = DEFAULT_TIMEOUT;
>>        }
>>     }
>>
>>.
>> .
>> .
>>
>>    /**
>>      * Sets the default timeout value
>>      *
>>     * @param timeout timeout value (in seconds)
>>      */
>>
>>    public void setDefaultTimeout(int timeout) {
>>
>>        if (TraceTm.jta.isDebugEnabled()) {
>>             TraceTm.jta.debug("timeout="+ timeout);
>>         }
>>
>>        if (timeout != 0) {
>>             transactionTimeout = timeout;
>>         }
>>     }
>>
>>
>>
>>According to the javadoc information, the setTransactionTimeout method
>>    
>>
>
>  
>
>>should only change the timeout value for transactions that are started
>>    
>>
>
>  
>
>>by the current thread with the begin method, but it appears as though
>>setTransactionTimeout and setDefaultTimeout are both modifying the
>>global default timeout value.  I don't see how this could possibly be
>>local to the current thread and it seems that every call to
>>setTransactionTimeout is changing the default timeout for all future
>>transactions.
>>
>>Ryan
>>
>>
>>_______________________________________________
>>Dev mailing list
>>Dev at lists.ofbiz.org
>>http://lists.ofbiz.org/mailman/listinfo/dev
>>    
>>
>
>__________ NOD32 1.1041 (20050330) Information __________
>
>This message was checked by NOD32 antivirus system.
>http://www.nod32.com
>
>(See attached file: ATT00010.txt)
>--
>You receive this message as a subscriber of the jotm at objectweb.org
>mailing
>list.
>To unsubscribe: mailto:jotm-unsubscribe at objectweb.org
>For general help: mailto:sympa at objectweb.org?subject=help
>ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>
>
>__________ NOD32 1.1042 (20050331) Information __________
>
>This message was checked by NOD32 antivirus system.
>http://www.nod32.com
>
>  
>
>------------------------------------------------------------------------
>
> 
>_______________________________________________
>Users mailing list
>Users at lists.ofbiz.org
>http://lists.ofbiz.org/mailman/listinfo/users
>


More information about the Users mailing list