Skip to content

Add helper code to make it easier to retry on connection failures. #673

@aelfric

Description

@aelfric

Feature Request

Is your feature request related to a problem? Please describe

This is somewhat related to #644 - the SPI defines transient errors vs non transient errors such that a non-transient error cannot be recovered. It seems like most or all connection failures might benefit from a retry. In order to express this logic today, we need to look into the sqlState of the exception and check its error code prefix.

In the current state, we need to need to propagate our own definitions of SQL error codes across multiple applications using this driver in order to express the retry logic we'd like to have.

Describe the solution you'd like

Code like this already exists inside this driver. But it returns a generic non-transient resource exception. Based on the definition in the SPI, I'm not sure that all connection failures should be considered non-transient, but even so,

Would it be possible to either define (and expose) an error specific to connection failures and or introduce some utility method like what is done in the JDBC driver.

Describe alternatives you've considered

The alternative is to continue copying this code across our projects or writing our own small utility library for it.

Teachability, Documentation, Adoption, Migration Strategy

Introducing a new exception type might be considered a breaking change, but I think introducing the utility method like in the JDBC driver could be explained through JavaDoc and the readme for this project might benefit from an example that talks specifically about retry logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions