diff --git a/libs/postgres_ffi/src/relfile_utils.rs b/libs/postgres_ffi/src/relfile_utils.rs index 94498ee9a9..cc9d6470c0 100644 --- a/libs/postgres_ffi/src/relfile_utils.rs +++ b/libs/postgres_ffi/src/relfile_utils.rs @@ -5,7 +5,7 @@ use crate::pg_constants; use once_cell::sync::OnceCell; use regex::Regex; -#[derive(Debug, Clone, thiserror::Error, PartialEq)] +#[derive(Debug, Clone, thiserror::Error, PartialEq, Eq)] pub enum FilePathError { #[error("invalid relation fork name")] InvalidForkName, diff --git a/libs/postgres_ffi/src/xlog_utils.rs b/libs/postgres_ffi/src/xlog_utils.rs index 29b00c8d36..956f53ce85 100644 --- a/libs/postgres_ffi/src/xlog_utils.rs +++ b/libs/postgres_ffi/src/xlog_utils.rs @@ -80,12 +80,12 @@ pub fn XLogSegNoOffsetToRecPtr( #[allow(non_snake_case)] pub fn XLogFileName(tli: TimeLineID, logSegNo: XLogSegNo, wal_segsz_bytes: usize) -> String { - return format!( + format!( "{:>08X}{:>08X}{:>08X}", tli, logSegNo / XLogSegmentsPerXLogId(wal_segsz_bytes), logSegNo % XLogSegmentsPerXLogId(wal_segsz_bytes) - ); + ) } #[allow(non_snake_case)] diff --git a/libs/utils/src/bin_ser.rs b/libs/utils/src/bin_ser.rs index 70f54ea02f..42b45eeea0 100644 --- a/libs/utils/src/bin_ser.rs +++ b/libs/utils/src/bin_ser.rs @@ -265,7 +265,7 @@ mod tests { use serde::{Deserialize, Serialize}; use std::io::Cursor; - #[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct ShortStruct { a: u8, b: u32, @@ -286,7 +286,7 @@ mod tests { const SHORT2_ENC_LE: &[u8] = &[8, 0, 0, 3, 7]; const SHORT2_ENC_LE_TRAILING: &[u8] = &[8, 0, 0, 3, 7, 0xff, 0xff, 0xff]; - #[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct LongMsg { pub tag: u8, pub blockpos: u32, diff --git a/libs/utils/src/http/request.rs b/libs/utils/src/http/request.rs index 8e3d357397..4984d695fd 100644 --- a/libs/utils/src/http/request.rs +++ b/libs/utils/src/http/request.rs @@ -10,12 +10,10 @@ pub fn get_request_param<'a>( ) -> Result<&'a str, ApiError> { match request.param(param_name) { Some(arg) => Ok(arg), - None => { - return Err(ApiError::BadRequest(format!( - "no {} specified in path param", - param_name - ))) - } + None => Err(ApiError::BadRequest(format!( + "no {} specified in path param", + param_name + ))), } } diff --git a/libs/utils/src/lsn.rs b/libs/utils/src/lsn.rs index 3dab2a625c..1090f4c679 100644 --- a/libs/utils/src/lsn.rs +++ b/libs/utils/src/lsn.rs @@ -18,7 +18,7 @@ pub const XLOG_BLCKSZ: u32 = 8192; pub struct Lsn(pub u64); /// We tried to parse an LSN from a string, but failed -#[derive(Debug, PartialEq, thiserror::Error)] +#[derive(Debug, PartialEq, Eq, thiserror::Error)] #[error("LsnParseError")] pub struct LsnParseError; diff --git a/libs/utils/src/postgres_backend.rs b/libs/utils/src/postgres_backend.rs index 79dca96fcf..4d873bd5ac 100644 --- a/libs/utils/src/postgres_backend.rs +++ b/libs/utils/src/postgres_backend.rs @@ -50,7 +50,7 @@ pub trait Handler { /// PostgresBackend protocol state. /// XXX: The order of the constructors matters. -#[derive(Clone, Copy, PartialEq, PartialOrd)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd)] pub enum ProtoState { Initialization, Encrypted, diff --git a/libs/utils/src/pq_proto.rs b/libs/utils/src/pq_proto.rs index 3dcae4d0af..3f14acd50d 100644 --- a/libs/utils/src/pq_proto.rs +++ b/libs/utils/src/pq_proto.rs @@ -930,7 +930,7 @@ impl<'a> BeMessage<'a> { // Neon extension of postgres replication protocol // See NEON_STATUS_UPDATE_TAG_BYTE -#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub struct ReplicationFeedback { // Last known size of the timeline. Used to enforce timeline size limit. pub current_timeline_size: u64, diff --git a/libs/utils/src/seqwait.rs b/libs/utils/src/seqwait.rs index bc32f51b13..a531975d60 100644 --- a/libs/utils/src/seqwait.rs +++ b/libs/utils/src/seqwait.rs @@ -9,7 +9,7 @@ use std::sync::Mutex; use std::time::Duration; /// An error happened while waiting for a number -#[derive(Debug, PartialEq, thiserror::Error)] +#[derive(Debug, PartialEq, Eq, thiserror::Error)] #[error("SeqWaitError")] pub enum SeqWaitError { /// The wait timeout was reached diff --git a/libs/utils/tests/bin_ser_test.rs b/libs/utils/tests/bin_ser_test.rs index f357837a55..b995b61b78 100644 --- a/libs/utils/tests/bin_ser_test.rs +++ b/libs/utils/tests/bin_ser_test.rs @@ -4,7 +4,7 @@ use serde::Deserialize; use std::io::Read; use utils::bin_ser::LeSer; -#[derive(Debug, PartialEq, Deserialize)] +#[derive(Debug, PartialEq, Eq, Deserialize)] pub struct HeaderData { magic: u16, info: u16, diff --git a/libs/utils/tests/ssl_test.rs b/libs/utils/tests/ssl_test.rs index 907ef98aec..248400c2c1 100644 --- a/libs/utils/tests/ssl_test.rs +++ b/libs/utils/tests/ssl_test.rs @@ -30,6 +30,9 @@ static CERT: Lazy = Lazy::new(|| { }); #[test] +// [false-positive](https://github.com/rust-lang/rust-clippy/issues/9274), +// we resize the vector so doing some modifications after all +#[allow(clippy::read_zero_byte_vec)] fn ssl() { let (mut client_sock, server_sock) = make_tcp_pair(); diff --git a/pageserver/src/http/routes.rs b/pageserver/src/http/routes.rs index 1b1b4f99cb..81ecdb7404 100644 --- a/pageserver/src/http/routes.rs +++ b/pageserver/src/http/routes.rs @@ -167,7 +167,7 @@ fn local_timeline_info_from_repo_timeline( ) -> anyhow::Result { match repo_timeline { RepositoryTimeline::Loaded(timeline) => local_timeline_info_from_loaded_timeline( - &*timeline, + timeline, include_non_incremental_logical_size, include_non_incremental_physical_size, ), diff --git a/pageserver/src/layered_repository/disk_btree.rs b/pageserver/src/layered_repository/disk_btree.rs index dc8d7a2ad3..c130a42a8e 100644 --- a/pageserver/src/layered_repository/disk_btree.rs +++ b/pageserver/src/layered_repository/disk_btree.rs @@ -209,7 +209,7 @@ where reader: R, } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum VisitDirection { Forwards, Backwards, diff --git a/proxy/src/auth/backend.rs b/proxy/src/auth/backend.rs index b10ede8d5e..bb7e7ef67b 100644 --- a/proxy/src/auth/backend.rs +++ b/proxy/src/auth/backend.rs @@ -86,7 +86,7 @@ impl From for tokio_postgres::Config { /// * However, when we substitute `T` with [`ClientCredentials`], /// this helps us provide the credentials only to those auth /// backends which require them for the authentication process. -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum BackendType { /// Legacy Cloud API (V1) + link auth. LegacyConsole(T), diff --git a/proxy/src/compute.rs b/proxy/src/compute.rs index 896ef3588d..3bad36661b 100644 --- a/proxy/src/compute.rs +++ b/proxy/src/compute.rs @@ -65,8 +65,17 @@ impl NodeInfo { // require for our business. let mut connection_error = None; let ports = self.config.get_ports(); - for (i, host) in self.config.get_hosts().iter().enumerate() { - let port = ports.get(i).or_else(|| ports.get(0)).unwrap_or(&5432); + let hosts = self.config.get_hosts(); + // the ports array is supposed to have 0 entries, 1 entry, or as many entries as in the hosts array + if ports.len() > 1 && ports.len() != hosts.len() { + return Err(io::Error::new( + io::ErrorKind::Other, + format!("couldn't connect: bad compute config, ports and hosts entries' count does not match: {:?}", self.config), + )); + } + + for (i, host) in hosts.iter().enumerate() { + let port = ports.get(i).or_else(|| ports.first()).unwrap_or(&5432); let host = match host { Host::Tcp(host) => host.as_str(), Host::Unix(_) => continue, // unix sockets are not welcome here diff --git a/safekeeper/src/control_file_upgrade.rs b/safekeeper/src/control_file_upgrade.rs index 5e749796dd..91d2f61c10 100644 --- a/safekeeper/src/control_file_upgrade.rs +++ b/safekeeper/src/control_file_upgrade.rs @@ -40,7 +40,7 @@ struct SafeKeeperStateV1 { wal_start_lsn: Lsn, } -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct ServerInfoV2 { /// Postgres server version pub pg_version: u32, @@ -70,7 +70,7 @@ pub struct SafeKeeperStateV2 { pub wal_start_lsn: Lsn, } -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct ServerInfoV3 { /// Postgres server version pub pg_version: u32, diff --git a/safekeeper/src/safekeeper.rs b/safekeeper/src/safekeeper.rs index a9373cb584..88747f14e5 100644 --- a/safekeeper/src/safekeeper.rs +++ b/safekeeper/src/safekeeper.rs @@ -127,7 +127,7 @@ impl AcceptorState { /// Information about Postgres. Safekeeper gets it once and then verifies /// all further connections from computes match. -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct ServerInfo { /// Postgres server version pub pg_version: u32, diff --git a/safekeeper/src/send_wal.rs b/safekeeper/src/send_wal.rs index 7439d6a8f6..4a9c56859f 100644 --- a/safekeeper/src/send_wal.rs +++ b/safekeeper/src/send_wal.rs @@ -36,7 +36,7 @@ const NEON_STATUS_UPDATE_TAG_BYTE: u8 = b'z'; type FullTransactionId = u64; /// Hot standby feedback received from replica -#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub struct HotStandbyFeedback { pub ts: TimestampTz, pub xmin: FullTransactionId,