-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example to handle failures in Transaction: Getting connection-timeout for subsequent requests #72
Comments
If i set hikari data source explicitly with leakDetection threshold = 2000 millis, i get the following exceptn and then SQLTransientConnectionException for the next transaction as before
Also, how to recover from this situation, since that connection cannot be used anymore. |
Reopening as I cant find community to help me debug this.
and
Even using above styles is giving me same result. |
As expected, the issue is that the sql query in QueryUpdateOnSubscribe object should be a commit or a rollback and then it would call Util::closeQuietly(connection) directly. However, in the case of failure, none of them is getting called as I am not able to handle failure (tried onErrorResumeNext()/onExceptionResumeNext) Internal Details: Current flow (important steps): |
Thanks for the report. I'm a bit limited in time at the moment but I'd like to have a look at it soon. |
so i have applied a patch locally that works for my use-case now, basically |
I think I am running into the same issue as well. I have the following...
When I run this query 1 completes but I deliberately cause a query exception on the table 2 operations. When I do this the thread hangs at the first delete table statement and never completes. Looking into the MySQL transactions table I see an outstanding tx (which I believe is the operation that did not close/rollback properly) and I see a transaction for the "delete from table" that is waiting. I used |
Upon further debugging it seems this for me is related to autocommit. Since the first query completes successfully and |
Your observations are in sync with mine. As per my understanding, the auto-commit is off in case of transactions and on for normal queries. We only need to handle the case when auto-commit is off. You can try this:
and then define a private method like following
|
I think I am running into the same issue. Does the catch block look like this after your changes? catch (Throwable e) {
try {
if (!state.con.getAutoCommit()) {
performRollbackForcefully(state);
}
} catch (SQLException e1) {
e1.printStackTrace();
}
query.context().endTransactionObserve();
query.context().endTransactionSubscribe();
try {
close(state);
} finally {
handleException(e, subscriber);
}
} My tests seem to behave much better after this change. |
Transation 'firstTransaction' has two insert queries Q1 and Q2. In the following example query Q2 fails due to primary key constraint violation.
If we attempt to run some another subsequent transaction, we get an exception
Max pool size is 1. (it is reproducible on even for other values). Full method impl
Versions:
rxjava-jdbc: 0.7.2 , 0.7.3
Hikari: 2.5.1
postgresql: 9.4.1212
Most likely m doing wrong, but m not able to figure out :(
The text was updated successfully, but these errors were encountered: