connection
ModuleWhether an error means the connection to the database was lost.
Contents
Constants
LOST_CONNECTION_MESSAGESThe library's own lost-connection messages, checked after Swoole's.SWOOLE_LOST_CONNECTION_MESSAGESMessages of errors caused by a lost connection, as Swoole lists them (`Swoole\Database\DetectsLostConnections::ERROR_MESSAGES`, in the Swoole library bundled with the dev image's extension).use utopia_database::connection::has_error;Rust
pub fn has_error(message: impl AsRef<[u8]>) -> boolWhether an error with message was caused by a lost connection: the
message contains one of SWOOLE_LOST_CONNECTION_MESSAGES or
LOST_CONNECTION_MESSAGES (case-sensitively, bytes as they are).
Rust
use utopia_database::connection::has_error;
assert!(has_error("SQLSTATE[08006] [7] server closed the connection unexpectedly"));
assert!(has_error("Max connect timeout reached"));
assert!(!has_error("SQLSTATE[23505]: Unique violation"));Rust
pub const LOST_CONNECTION_MESSAGES: &[&str] = &["Max connect timeout reached"]The library's own lost-connection messages, checked after Swoole's.
Rust
pub const SWOOLE_LOST_CONNECTION_MESSAGES: &[&str] = &[ "server has gone away", "Server has gone away", "no connection to the server", "Lost connection", "is dead or not enabled", "Error while sending", "decryption failed or bad record mac", "server closed the connection unexpectedly", "SSL connection has been closed unexpectedly", "Error writing data to the connection", "Resource deadlock avoided", "Transaction() on null", "child connection forced to terminate due to client_idle_limit", "query_wait_timeout", "reset by peer", "Physical connection is not usable", "TCP Provider: Error code 0x68", "ORA-03113", "ORA-03114", "Packets out of order. Expected", "Adaptive Server connection failed", "Communication link failure", "connection is no longer usable", "Login timeout expired", "SQLSTATE[HY000] [2002] Connection refused", "running with the --read-only option so it cannot execute this statement", "The connection is broken and recovery is not possible. The connection is marked by the client driver as unrecoverable. No attempt was made to restore the connection.", "SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Try again", "SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known",Messages of errors caused by a lost connection, as Swoole lists them
(Swoole\Database\DetectsLostConnections::ERROR_MESSAGES, in the Swoole
library bundled with the dev image's extension).