[hibernate-issues] [JIRA] (HHH-14062) @Transactional timeout attribute wrong work

ssosso (JIRA) jira at hibernate.atlassian.net
Sun Jun 7 04:54:09 EDT 2020


ssosso ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A37d856ec-a49f-422e-a97e-a15f29433835 ) *updated* an issue

Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNDFmNTA2Nzk3ZjI4NDFmNjk5MGI1NGIzNGEyYTcyNmUiLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HHH-14062?atlOrigin=eyJpIjoiNDFmNTA2Nzk3ZjI4NDFmNjk5MGI1NGIzNGEyYTcyNmUiLCJwIjoiaiJ9 ) HHH-14062 ( https://hibernate.atlassian.net/browse/HHH-14062?atlOrigin=eyJpIjoiNDFmNTA2Nzk3ZjI4NDFmNjk5MGI1NGIzNGEyYTcyNmUiLCJwIjoiaiJ9 ) @Transactional timeout attribute wrong work ( https://hibernate.atlassian.net/browse/HHH-14062?atlOrigin=eyJpIjoiNDFmNTA2Nzk3ZjI4NDFmNjk5MGI1NGIzNGEyYTcyNmUiLCJwIjoiaiJ9 )

Change By: ssosso ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A37d856ec-a49f-422e-a97e-a15f29433835 )

!1 (cca38fb1-5eec-4a43-92cf-de14bc8fbb7d).png|width=672,height=82!

!2 (a9640152-45ff-46b7-bc19-8d62af5f0cb9).png|width=855,height=199!

org/hibernate/engine/jdbc/internal/JdbcCoordinatorImpl.class([242 line|https://github.com/hibernate/hibernate-orm/blob/5963dc7fe8/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcCoordinatorImpl.java#L242])

If set as @Transactional(timeout=1), the transaction timeout will fail unconditionally due to the current timeout checking logic. This is because the / (divide) operation is used.

When set as @Transactional(timeout=1),

{code:java}(Timeout upper limit date and time - Transaction end date and time) / 1000{code}

is always 0 (zero).

!3 (0e92237d-95aa-42dd-873c-fb13416d9bc1).png|width=643,height=1280!

Therefore, TransactionException is always caused by the following logic.

{code:java}if (secondsRemaining <= 0) {
throw new TransactionException( "transaction timeout expired" );
}{code}

I am considering this as a bug, so I suggest to fix the code as below.

{code:java}if (secondsRemaining < 0) {
throw new TransactionException( "transaction timeout expired" );
}{code}

If necessary, please refer to my PR.

[https://github.com/hibernate/hibernate-orm/pull/3429|https://github.com/hibernate/hibernate-orm/pull/3429|smart-link]

( https://hibernate.atlassian.net/browse/HHH-14062#add-comment?atlOrigin=eyJpIjoiNDFmNTA2Nzk3ZjI4NDFmNjk5MGI1NGIzNGEyYTcyNmUiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-14062#add-comment?atlOrigin=eyJpIjoiNDFmNTA2Nzk3ZjI4NDFmNjk5MGI1NGIzNGEyYTcyNmUiLCJwIjoiaiJ9 )

Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100128- sha1:078e4e4 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200607/25383362/attachment.html 


More information about the hibernate-issues mailing list