Cannot detect transaction timeout after query execution on DataSourceTransactionManager [SPR-14038] #18610
Comments
Kazuki Shimizu commented I've added repro project. |
Juergen Hoeller commented This is unfortunately a fundamental limitation of timeout handling against native resources: They all just support timeout hints but no timeout enforcement. As a consequence, a Spring-specified timeout is also just a hint: It may lead to an enforced timeout depending on the transaction manager (like in the JTA case where a parallel cleanup thread cancels timed-out transactions) but usually just suggests a timeout to the underlying resource. This is similar to a Spring-specified read-only flag which is also just an optimization hint, not a hard enforcement. We could theoretically cancel a transaction at commit time if we determine that it took too long. However, that seems wasteful: The operations did succeed by then, and with a native transaction manager, the subsequent commit signal is usually a quick step to take. Enforcing a timeout at that late point, for a transaction which essentially has been successful, seems counter-intuitive. After all, timeouts are primarily there to avoid hanging when an operation runs into a lock, not for a hard cancel attempt when an operation happened to take slightly longer than expected. Juergen |
Kazuki Shimizu commented Juergen Hoeller, thanks for answer !!! However, in my application, it want to ensure rollback a transaction, if read-timeout was detected at Client application. My team was consider a following solution: e.g.)
If can ensure to rollback transaction when transaction timeout was occurred, we thought this issue can be resolved by timeout desgin except for the rare case. Have best practice to implements this specification on spring application(actually, spring boot application) ? Thanks. |
Bulk closing outdated, unresolved issues. Please, reopen if still relevant. |
Kazuki Shimizu opened SPR-14038 and commented
Currently, there are cases where the transaction in excess of the timeout period is committed.
e.x.)
This behavior is same with
JpaTransactionManager
andJmsTransactionManager
.If
JtaTransactionManager
is used, we can detect a transaction timeout.I hope to detect timeout at committing. What do you think ?
Affects: 4.2.5
Referenced from: commits spring-projects/spring-framework-issues@3c2a425, spring-projects/spring-framework-issues@2b20a1a
The text was updated successfully, but these errors were encountered: