Sort epgsql errors into what a caller can do about them.
retryable: the statement or transaction failed and nothing was
committed; run it again (serialization failure 40001, deadlock 40P01).
YugabyteDB reports its transaction conflicts and read restarts as 40001.
connection_lost: the connection is gone (server shutdown 57P0x, any
class 08 connection exception, or a closed socket). Work in an open
transaction was not committed; a COMMIT in flight has an unknown outcome.
other: anything else, such as a constraint violation or bad SQL.
connect_failure/1 sorts the errors of a failed connect instead:
whether the host could not be reached at all, which leaves it out of new
connections, or answered and turned the connection away.
class() = retryable | connection_lost | other
connect_failure() = unreachable | rejected
| classify/1 | |
| code/1 | The SQLSTATE of a server error, or undefined. |
| connect_failure/1 | Why a connect failed, as the JDBC smart driver sorts it. |
| is_connection_lost/1 | |
| is_retryable/1 |
classify(Error::term()) -> class()
code(Error::term()) -> binary() | undefined
The SQLSTATE of a server error, or undefined.
connect_failure(Error::term()) -> connect_failure()
Why a connect failed, as the JDBC smart driver sorts it.
unreachable: no connection could be made to the host. These are the
failures pgjdbc reports as SQLSTATE 08001, CONNECTION_UNABLE_TO_CONNECT,
the only ones after which the smart driver marks a host down
(LoadBalanceService.getConnection). ConnectionFactoryImpl.openConnectionImpl
gives that state to every I/O failure while connecting: a refused or
timed-out TCP connect, a name that does not resolve, no route, and a
connection that drops before the session is ready. In epgsql and OTP terms:
econnrefused, timeout, etimedout, nxdomain, ehostunreach,
ehostdown, enetunreach, enetdown, econnreset, econnaborted,
epipe, enotconn and eaddrnotavail from the TCP connect, or from
reading the server's answer to the TLS request;closed, sock_closed and {sock_error, _}: the server closed the
socket, or it failed, during startup or authentication;{connection_lost, _}: eysql_conn lost the connection while
setting statement_timeout or checking target_session_attrs;probe_timeout and {probe_exit, _}: an eysql_cluster probe
that overran its time, or died with its connection;rejected: anything else. The server answered, and the connection
failed all the same: a failed login (invalid_password, 28P01, or
invalid_authorization_specification, 28000), a missing database
(3D000), too many connections (53300), a server starting up or shutting
down (57P03), any other server error, an authentication method epgsql
does not support, a server without TLS under ssl => required
(ssl_not_available, 08004 in pgjdbc), and a failed TLS handshake
({ssl_negotiation_failed, _}, which pgjdbc's MakeSSL.convert reports as
08006, CONNECTION_FAILURE, whatever the cause). pgjdbc skips such a host
for the rest of that one connection and does not mark it down.
is_connection_lost(Error::term()) -> boolean()
is_retryable(Error::term()) -> boolean()
Generated by EDoc