You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by tschuler <th...@opentext.com> on 2013/10/23 14:15:26 UTC

No transaction rollback in case of pessimistic locking failure

Hi!

We are using TomEE 1.6.0 snapshot and are actually working on usage of
pessimistic locks for an entity (entityManager.lock(entity,
LockModeType.PESSIMISTIC_WRITE)).

What we see is that if the entity is allready locked the next locking
attempt results in a PessimisticLockException marking the transaction for
rollback.

Is there a way to avoid the transaction rollback (or to get a
LockTimeoutException instead that seems to have no effect on the transaction
state)?

Best regards,
Thomas



--
View this message in context: http://openejb.979440.n4.nabble.com/No-transaction-rollback-in-case-of-pessimistic-locking-failure-tp4665710.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: AW: No transaction rollback in case of pessimistic locking failure

Posted by tschuler <th...@opentext.com>.
Trying around a bit shows that a LockTimeoutException (that has no effect on
the transaction state) is only thrown if:
- entity manager find (entityManager.find(LockEntity.class, lockId,
LockModeType.PESSIMISTIC_WRITE)) is used.
- and the entity to be locked was not loaded before within the transaction.



--
View this message in context: http://openejb.979440.n4.nabble.com/No-transaction-rollback-in-case-of-pessimistic-locking-failure-tp4665710p4666066.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: AW: No transaction rollback in case of pessimistic locking failure

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

I think the only way is to catch the exception to prevent it
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2013/10/25 tschuler <th...@opentext.com>:
> Hi!
>
> Is there a way to unset the rollback only flag for a transaction?
>
> Best regards,
> Thomas
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/No-transaction-rollback-in-case-of-pessimistic-locking-failure-tp4665710p4665726.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: AW: No transaction rollback in case of pessimistic locking failure

Posted by tschuler <th...@opentext.com>.
Hi!

Is there a way to unset the rollback only flag for a transaction?

Best regards,
Thomas



--
View this message in context: http://openejb.979440.n4.nabble.com/No-transaction-rollback-in-case-of-pessimistic-locking-failure-tp4665710p4665726.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

AW: No transaction rollback in case of pessimistic locking failure

Posted by tschuler <th...@opentext.com>.
Hi Romain!

Yes I did so:
entityManager.setProperty( "javax.persistence.lock.timeout", (int) timeout );
entityManager.lock( entity, LockModeType.PESSIMISTIC_WRITE );

Best regards,
                Thomas


Von: Romain Manni-Bucau [via OpenEJB] [mailto:ml-node+s979440n4665711h51@n4.nabble.com]
Gesendet: Mittwoch, 23. Oktober 2013 14:24
An: Thomas Schuler
Betreff: Re: No transaction rollback in case of pessimistic locking failure

Hi

did you set javax.persistence.lock.timeout property?
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2013/10/23 tschuler <[hidden email]</user/SendEmail.jtp?type=node&node=4665711&i=0>>:

> Hi!
>
> We are using TomEE 1.6.0 snapshot and are actually working on usage of
> pessimistic locks for an entity (entityManager.lock(entity,
> LockModeType.PESSIMISTIC_WRITE)).
>
> What we see is that if the entity is allready locked the next locking
> attempt results in a PessimisticLockException marking the transaction for
> rollback.
>
> Is there a way to avoid the transaction rollback (or to get a
> LockTimeoutException instead that seems to have no effect on the transaction
> state)?
>
> Best regards,
> Thomas
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/No-transaction-rollback-in-case-of-pessimistic-locking-failure-tp4665710.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

________________________________
If you reply to this email, your message will be added to the discussion below:
http://openejb.979440.n4.nabble.com/No-transaction-rollback-in-case-of-pessimistic-locking-failure-tp4665710p4665711.html
To unsubscribe from No transaction rollback in case of pessimistic locking failure, click here<http://openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4665710&code=dGhvbWFzLnNjaHVsZXJAb3BlbnRleHQuY29tfDQ2NjU3MTB8LTE4NTIyNTQ0OTI=>.
NAML<http://openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>




--
View this message in context: http://openejb.979440.n4.nabble.com/No-transaction-rollback-in-case-of-pessimistic-locking-failure-tp4665710p4665712.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: No transaction rollback in case of pessimistic locking failure

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

did you set javax.persistence.lock.timeout property?
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2013/10/23 tschuler <th...@opentext.com>:
> Hi!
>
> We are using TomEE 1.6.0 snapshot and are actually working on usage of
> pessimistic locks for an entity (entityManager.lock(entity,
> LockModeType.PESSIMISTIC_WRITE)).
>
> What we see is that if the entity is allready locked the next locking
> attempt results in a PessimisticLockException marking the transaction for
> rollback.
>
> Is there a way to avoid the transaction rollback (or to get a
> LockTimeoutException instead that seems to have no effect on the transaction
> state)?
>
> Best regards,
> Thomas
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/No-transaction-rollback-in-case-of-pessimistic-locking-failure-tp4665710.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.