Allow JDBC connectors to retry on transient failures#19191
Allow JDBC connectors to retry on transient failures#19191hashhar merged 3 commits intotrinodb:masterfrom
Conversation
caadc2e to
992a02b
Compare
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/RetryingConnectionFactory.java
Outdated
Show resolved
Hide resolved
plugin/trino-oracle/src/main/java/io/trino/plugin/oracle/OracleClientModule.java
Outdated
Show resolved
Hide resolved
plugin/trino-oracle/src/main/java/io/trino/plugin/oracle/OracleClientModule.java
Outdated
Show resolved
Hide resolved
plugin/trino-oracle/src/main/java/io/trino/plugin/oracle/OracleClientModule.java
Outdated
Show resolved
Hide resolved
plugin/trino-oracle/src/main/java/io/trino/plugin/oracle/OracleClientModule.java
Outdated
Show resolved
Hide resolved
plugin/trino-oracle/src/main/java/io/trino/plugin/oracle/OracleClientModule.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/RetryingConnectionFactoryModule.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/RetryingConnectionFactory.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/RetryingConnectionFactory.java
Outdated
Show resolved
Hide resolved
a04c427 to
fd98944
Compare
fd98944 to
4f040f7
Compare
4f040f7 to
f7ff814
Compare
hashhar
left a comment
There was a problem hiding this comment.
some comments
right now the refactors look larger than the actual change and I can't be sure what is refactor vs what is required for the functionality
plugin/trino-oracle/src/main/java/io/trino/plugin/oracle/OracleClientModule.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/RetryingConnectionFactoryModule.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestRetryingConnectionFactory.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
looks like pre-exisiting logic that we only use RCF with non-pooled connections.
I don't know if it was intentional or not, so either we should add RCF to pooled connection factory as well or add a comment explaining why we only use RCF with non-pooled connections.
There was a problem hiding this comment.
Sorry, but this ask seems out of scope? This has only been revealed because I slightly refactor the existing code and how it is more evident what the logic is. The scope has been frozen before I started working. If there's a good reason that we should change it, then we will. But we need a good reason.
Acceptance criteria
- no new regressions
- unit tests for new framework that it actually retries
- it is possible to implement retry for any connector in future that fails sometimes to open a connection
- no custom retrying in any jdbc connector, all connectors use new framework
Let me know if I misunderstood AC laid out by @kokosing.
5266786 to
0ae9875
Compare
I have broken down the change into a few commits, so that it is clear where the refactor ends and where adding functionality starts. If this is still not helpful, let's have a call. |
0ae9875 to
dce2564
Compare
|
The commit titles are too long. Please see https://cbea.ms/git-commit/ |
plugin/trino-oracle/src/main/java/io/trino/plugin/oracle/OracleClientModule.java
Outdated
Show resolved
Hide resolved
dce2564 to
2c62916
Compare
Shortened commit messages and formatted the extended description to 72 chars column. |
plugin/trino-oracle/src/main/java/io/trino/plugin/oracle/OracleClientModule.java
Outdated
Show resolved
Hide resolved
plugin/trino-oracle/src/main/java/io/trino/plugin/oracle/OracleClientModule.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/RetryingConnectionFactory.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/RetryingConnectionFactory.java
Outdated
Show resolved
Hide resolved
|
How about PR title: Please provide PR description too and fill RN (release notes) form. |
9ad8864 to
f2c32b0
Compare
Thanks. I spent some time analyzing this, as your previous hint from slack was actually tracking the JdbcClient chain, rather than ConnectionFactory. But I figured it out by myself and it made me so proud :) Simplified the chain with Lazy and Stats. There's a separate commit. |
8638db0 to
9244f8c
Compare
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/LazyConnectionFactory.java
Outdated
Show resolved
Hide resolved
14167f5 to
24e316a
Compare
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/LazyConnectionFactory.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestLazyConnectionFactory.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestRetryingConnectionFactory.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestRetryingConnectionFactory.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestLazyConnectionFactory.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/RetryingConnectionFactoryModule.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestLazyConnectionFactory.java
Outdated
Show resolved
Hide resolved
24e316a to
0f67a87
Compare
Refactor TestRetryingConnectionFactory and TestLazyConnectionFactory to use Dependency Injection Motivation behind this change is to be able to later add dependent objects to tested class without a need for major changes in the test class itself.
0f67a87 to
da3f8ec
Compare
hashhar
left a comment
There was a problem hiding this comment.
The impl looks very good. I have no comments about it.
The only comment I have is about inspecting how the Guice map looks after the 2nd commit. From what I can tell we seem to have introduced duplication.
plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestRetryingConnectionFactory.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/ForLazyConnectionFactory.java
Show resolved
Hide resolved
|
For references here's the actual Guice map before and after change for both JdbcClient and ConnectionFactory BEFORE: AFTER: No change in JdbcClient tree after the change. |
|
@dominikzalewski can you please fill in the release notes template in the PR description since this would be a user visible change (even if not directly configurable). |
|
Fyi .. please check out the final release notes entry we added for future references and as an example. |
Description
RetryingConnectionFactory now has a pluggable JDBC-connector specific retry strategy. This PR applies this change only to Oracle.
Release notes
( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(X) Release notes are required, with the following suggested text:
All JDBC-based connectors are now always retrying (5 times for 30 seconds with a backoff) if opening a connection fails. By default this happens only if SQLTransientException is encountered. For backward compatibility, for Oracle this is overridden to SQLRecoverableException.