From 146ac42a3c1823d4a85924fa7b65d899f81e3a7e Mon Sep 17 00:00:00 2001 From: Marcelo Altmann Date: Mon, 9 Sep 2024 12:02:06 -0300 Subject: [PATCH] Addressed review comments. Fixed review comments in hosts and proxysql.cnf files. --- build/proxysql.cnf | 10 +++++----- src/hosts.rs | 18 +++++++++++------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/build/proxysql.cnf b/build/proxysql.cnf index a45afd7..08a0b4f 100644 --- a/build/proxysql.cnf +++ b/build/proxysql.cnf @@ -17,14 +17,14 @@ mysql_variables= monitor_password="noria" } -mysql_users: +mysql_users= ( { - username = "root" - password = "noria" - default_hostgroup = 1 + username="root" + password="noria" + default_hostgroup=1 max_connections=1000 default_schema="noria" - active = 1 + active=1 } ) diff --git a/src/hosts.rs b/src/hosts.rs index 38786d4..1110fae 100644 --- a/src/hosts.rs +++ b/src/hosts.rs @@ -6,13 +6,13 @@ use mysql::{prelude::Queryable, Conn, OptsBuilder}; /// Defines the possible status of a host #[derive(PartialEq, Clone, Copy)] pub enum HostStatus { - ///backend server is fully operational + /// backend server is fully operational Online, - //backend sever is temporarily taken out of use because of either too many connection errors in a time that was too short, or the replication lag exceeded the allowed threshold + /// backend sever is temporarily taken out of use because of either too many connection errors in a time that was too short, or the replication lag exceeded the allowed threshold Shunned, - //when a server is put into OFFLINE_SOFT mode, no new connections are created toward that server, while the existing connections are kept until they are returned to the connection pool or destructed. In other words, connections are kept in use until multiplexing is enabled again, for example when a transaction is completed. This makes it possible to gracefully detach a backend as long as multiplexing is efficient + /// when a server is put into OFFLINE_SOFT mode, no new connections are created toward that server, while the existing connections are kept until they are returned to the connection pool or destructed. In other words, connections are kept in use until multiplexing is enabled again, for example when a transaction is completed. This makes it possible to gracefully detach a backend as long as multiplexing is efficient OfflineSoft, - //when a server is put into OFFLINE_HARD mode, no new connections are created toward that server and the existing **free **connections are ** immediately dropped**, while backend connections currently associated with a client session are dropped as soon as the client tries to use them. This is equivalent to deleting the server from a hostgroup. Internally, setting a server in OFFLINE_HARD status is equivalent to deleting the server + /// when a server is put into OFFLINE_HARD mode, no new connections are created toward that server and the existing free connections are immediately dropped, while backend connections currently associated with a client session are dropped as soon as the client tries to use them. This is equivalent to deleting the server from a hostgroup. Internally, setting a server in OFFLINE_HARD status is equivalent to deleting the server OfflineHard, } @@ -203,14 +203,18 @@ impl Host { /// true if the query was cached successfully, false otherwise. pub fn cache_query(&mut self, query: &Query) -> Result { match &mut self.conn { - None => return Ok(false), + None => { + return Err(mysql::Error::IoError(std::io::Error::new( + std::io::ErrorKind::Other, + "Connection to Readyset host is not established", + ))) + } Some(conn) => { conn.query_drop(format!( "CREATE CACHE d_{} FROM {}", query.get_digest(), query.get_digest_text() - )) - .expect("Failed to create readyset cache"); + ))?; } } Ok(true)