davidmoten / davidmoten/rxjava-jdbc
Example to handle failures in Transaction: Getting connection-timeout for subsequent requests
- Dominant language
- Java
- Stars
- 801
- Forks
- 114
- Avg merge
- 1m
- Merged PRs (30d)
- 3
Description
Transation 'firstTransaction' has two insert queries Q1 and Q2. In the following example query Q2 fails due to primary key constraint violation.
```
@Test
public void test() {
Observable firstTransactionFirstPart = database.update(queryThatInsertsinTableWithPrimaryKeyA)
.dependsOn(database.beginTransaction())
.parameters(new Object[0])
.count();
Observable firstTransactionSecondPart = database.update(queryThatInsertsinTableWithPrimaryKeyA)
.dependsOn(firstTransactionFirstPart)
.parameters(new Object[0])
.count();
Observable firstTransaction = database.commit(firstTransactionSecondPart);
firstTransaction.subscribe(...);//logging
```
If we attempt to run some another subsequent transaction, we get an exception
```
com.github.davidmoten.rx.jdbc.exceptions.SQLRuntimeException: java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30000ms.
at com.github.davidmoten.rx.jdbc.ConnectionProviderPooled.get(ConnectionProviderPooled.java:92)
at com.github.davidmoten.rx.jdbc.ConnectionProviderSingletonManualCommit.get(ConnectionProviderSingletonManualCommit.java:43)
at com.github.davidmoten.rx.jdbc.QueryUpdateOnSubscribe.getConnection(QueryUpdateOnSubscribe.java:127)
at com.github.davidmoten.rx.jdbc.QueryUpdateOnSubscribe.call(QueryUpdateOnSubscribe.java:80)
at com.github.davidmoten.rx.jdbc.QueryUpdateOnSubscribe.call(QueryUpdateOnSubscribe.java:22)
at rx.Observable.unsafeSubscribe(Observable.java:8460)
```
Max pool size is 1. (it is reproducible on even for other values). [Full method impl](http://pastebin.com/nr0UbGgj)
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 :(
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.