You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by Jeff Hair <je...@greenqloud.com> on 2015/10/14 19:04:28 UTC

TransactionContextInterceptor Keeps Releasing My Lock

I'm using the DAO API to create a lock in the lock table as per
https://cwiki.apache.org/confluence/display/CLOUDSTACK/Data+Access+Layer.
However, the lock seems to mysteriously vanish after acquireInLockTable or
lockInLockTable method returns. Looking at the code, I've discovered that
TransactionContextInterceptor is closing the TransactionLegacy after the
method returns.

I have @DB on the method calling acquireFromLockTable. What am I doing
wrong?

Re: TransactionContextInterceptor Keeps Releasing My Lock

Posted by Jeff Hair <je...@greenqloud.com>.
My experience is this:
 - If I call the method directly from within the class, @DB seems to apply
and the lock in the op_lock table stays active as long as it is needed.
 - If I call the method on another thread (internal class implementing
Runnable), @DB does not apply and I have to wrap the acquireInLock call and
associated code in Transaction.doInTransaction.

On Wed, Oct 28, 2015 at 10:02 AM, Frank Maximus <
frank.maximus@nuagenetworks.net> wrote:

> Would you happen to call the method annotated with @DB from within the same
> class? If so,  you would directly go to the method, instead of using the
> proxy which applies AOP.
>
> Regards,
> Frank
> On 26 Oct 2015 12:53, "Jeff Hair" <je...@greenqloud.com> wrote:
>
> > I have narrowed it down to multithreading being the cause. I have a set
> of
> > workers running through an executor service, and it seems cglib is not
> > respecting the @DB annotation on the method being called by the thread.
> >
> > I can force the lock to be acquired if the entire method is executed in a
> > transaction, or if I remove the producer-consumer BlockingQueue. Is
> there a
> > way that makes sense besides one of these two options?
> >
> > On Wed, Oct 14, 2015 at 5:04 PM, Jeff Hair <je...@greenqloud.com> wrote:
> >
> > > I'm using the DAO API to create a lock in the lock table as per
> > >
> https://cwiki.apache.org/confluence/display/CLOUDSTACK/Data+Access+Layer
> > .
> > > However, the lock seems to mysteriously vanish after acquireInLockTable
> > or
> > > lockInLockTable method returns. Looking at the code, I've discovered
> that
> > > TransactionContextInterceptor is closing the TransactionLegacy after
> the
> > > method returns.
> > >
> > > I have @DB on the method calling acquireFromLockTable. What am I doing
> > > wrong?
> > >
> >
> >
> >
> > --
> > *Jeff Hair*
> > Technical Lead and Software Developer
> >
> > Tel: (+354) 415 0200
> > jeff@greenqloud.com
> > www.greenqloud.com
> >
>



-- 
*Jeff Hair*
Technical Lead and Software Developer

Tel: (+354) 415 0200
jeff@greenqloud.com
www.greenqloud.com

Re: TransactionContextInterceptor Keeps Releasing My Lock

Posted by Frank Maximus <fr...@nuagenetworks.net>.
Would you happen to call the method annotated with @DB from within the same
class? If so,  you would directly go to the method, instead of using the
proxy which applies AOP.

Regards,
Frank
On 26 Oct 2015 12:53, "Jeff Hair" <je...@greenqloud.com> wrote:

> I have narrowed it down to multithreading being the cause. I have a set of
> workers running through an executor service, and it seems cglib is not
> respecting the @DB annotation on the method being called by the thread.
>
> I can force the lock to be acquired if the entire method is executed in a
> transaction, or if I remove the producer-consumer BlockingQueue. Is there a
> way that makes sense besides one of these two options?
>
> On Wed, Oct 14, 2015 at 5:04 PM, Jeff Hair <je...@greenqloud.com> wrote:
>
> > I'm using the DAO API to create a lock in the lock table as per
> > https://cwiki.apache.org/confluence/display/CLOUDSTACK/Data+Access+Layer
> .
> > However, the lock seems to mysteriously vanish after acquireInLockTable
> or
> > lockInLockTable method returns. Looking at the code, I've discovered that
> > TransactionContextInterceptor is closing the TransactionLegacy after the
> > method returns.
> >
> > I have @DB on the method calling acquireFromLockTable. What am I doing
> > wrong?
> >
>
>
>
> --
> *Jeff Hair*
> Technical Lead and Software Developer
>
> Tel: (+354) 415 0200
> jeff@greenqloud.com
> www.greenqloud.com
>

Re: TransactionContextInterceptor Keeps Releasing My Lock

Posted by Jeff Hair <je...@greenqloud.com>.
I have narrowed it down to multithreading being the cause. I have a set of
workers running through an executor service, and it seems cglib is not
respecting the @DB annotation on the method being called by the thread.

I can force the lock to be acquired if the entire method is executed in a
transaction, or if I remove the producer-consumer BlockingQueue. Is there a
way that makes sense besides one of these two options?

On Wed, Oct 14, 2015 at 5:04 PM, Jeff Hair <je...@greenqloud.com> wrote:

> I'm using the DAO API to create a lock in the lock table as per
> https://cwiki.apache.org/confluence/display/CLOUDSTACK/Data+Access+Layer.
> However, the lock seems to mysteriously vanish after acquireInLockTable or
> lockInLockTable method returns. Looking at the code, I've discovered that
> TransactionContextInterceptor is closing the TransactionLegacy after the
> method returns.
>
> I have @DB on the method calling acquireFromLockTable. What am I doing
> wrong?
>



-- 
*Jeff Hair*
Technical Lead and Software Developer

Tel: (+354) 415 0200
jeff@greenqloud.com
www.greenqloud.com