Hi,

A notifyAll() call is done in the instanceDone()
method after setting the done flag and incrementing
the incarnationCount.
That should make all threads waiting on the lock
throw an IllegalStateException.

At the time instanceDone() does the notifyAll()
call, the transaction frontends have not yet been
terminated. I thought that this would be no problem
as the frontends would have to reaquire the lock
to do something. Unfortunately there are two problems
with this that could occur after the notifyAll()
call and before the frontends are terminated:
1) The TxCapsule.getStatus() does not try to get
   the lock, and thus could return old invalid
   status.
2) If a thread tries to aquire the TxCapsule lock
   after the notifyAll() call, the incarnationCount
   has already been updated and there is a slight
   chance that the TxCapsule instance is reused
   while the thread is waiting for the lock, causing
   an operation on the wrong transaction.

To fix this, instanceDone() should be changed so
that the loop calling setDone() on the transaction
frontends is moved to the very start of this method.

Marc, I currently have a problem with testing.
Could you do this change for me?


Best Regards,

Ole Husgaard.


jBoss CVS Development wrote:
> 
>   User: fleury
>   Date: 00/10/15 12:05:07
> 
>   Modified:    src/main/org/jboss/tm TxCapsule.java
>   Log:
>   sync problems?
> 
>   Revision  Changes    Path
>   1.14      +3 -1      jboss/src/main/org/jboss/tm/TxCapsule.java
> 
>   Index: TxCapsule.java
>   ===================================================================
>   RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/tm/TxCapsule.java,v
>   retrieving revision 1.13
>   retrieving revision 1.14
>   diff -u -r1.13 -r1.14
>   --- TxCapsule.java    2000/10/10 23:47:02     1.13
>   +++ TxCapsule.java    2000/10/15 19:05:07     1.14
>   @@ -43,7 +43,7 @@
>     *  @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
>     *  @author <a href="mailto:[EMAIL PROTECTED]">Ole Husgaard</a>
>     *
>   - *  @version $Revision: 1.13 $
>   + *  @version $Revision: 1.14 $
>     */
>    class TxCapsule implements TimeoutTarget
>    {
>   @@ -814,6 +814,8 @@
>                   wait();
>                } catch (InterruptedException ex) {}
> 
>   +                     // MF FIXME: don't we need a notify() in this case?
>   +                     // we need to release all the thread waiting on this lock
>                if (done || myIncarnation != incarnationCount)
>                  throw new IllegalStateException("No transaction");
>             }
> 
> 
>

Reply via email to