From 337ac04205e4c519ba555b42f00e91e7a69e3d76 Mon Sep 17 00:00:00 2001 From: Conrad Ludgate Date: Mon, 17 Mar 2025 09:13:51 +0000 Subject: [PATCH 1/5] clippy --fix --- compute_tools/src/catalog.rs | 7 +++---- compute_tools/src/spec_apply.rs | 2 +- libs/postgres_backend/src/lib.rs | 7 +++---- libs/postgres_backend/tests/simple_select.rs | 4 ++-- libs/pq_proto/src/framed.rs | 2 +- libs/pq_proto/src/lib.rs | 2 +- libs/proxy/postgres-protocol2/src/authentication/sasl.rs | 4 ++-- libs/remote_storage/src/azure_blob.rs | 5 ++--- libs/remote_storage/tests/test_real_s3.rs | 2 +- 9 files changed, 16 insertions(+), 19 deletions(-) diff --git a/compute_tools/src/catalog.rs b/compute_tools/src/catalog.rs index db3e07e086b8..daffe970d4fd 100644 --- a/compute_tools/src/catalog.rs +++ b/compute_tools/src/catalog.rs @@ -99,11 +99,11 @@ pub async fn get_database_schema( .spawn()?; let stdout = cmd.stdout.take().ok_or_else(|| { - std::io::Error::new(std::io::ErrorKind::Other, "Failed to capture stdout.") + std::io::Error::other("Failed to capture stdout.") })?; let stderr = cmd.stderr.take().ok_or_else(|| { - std::io::Error::new(std::io::ErrorKind::Other, "Failed to capture stderr.") + std::io::Error::other("Failed to capture stderr.") })?; let mut stdout_reader = FramedRead::new(stdout, BytesCodec::new()); @@ -128,8 +128,7 @@ pub async fn get_database_schema( } }); - return Err(SchemaDumpError::IO(std::io::Error::new( - std::io::ErrorKind::Other, + return Err(SchemaDumpError::IO(std::io::Error::other( "failed to start pg_dump", ))); } diff --git a/compute_tools/src/spec_apply.rs b/compute_tools/src/spec_apply.rs index 2be6458fb41c..e7d67f6ac524 100644 --- a/compute_tools/src/spec_apply.rs +++ b/compute_tools/src/spec_apply.rs @@ -419,7 +419,7 @@ impl ComputeNode { .iter() .filter_map(|val| val.parse::().ok()) .map(|val| if val > 1 { val - 1 } else { 1 }) - .last() + .next_back() .unwrap_or(3) } } diff --git a/libs/postgres_backend/src/lib.rs b/libs/postgres_backend/src/lib.rs index a0a891f0dc1a..654dde8da642 100644 --- a/libs/postgres_backend/src/lib.rs +++ b/libs/postgres_backend/src/lib.rs @@ -5,7 +5,6 @@ #![deny(unsafe_code)] #![deny(clippy::undocumented_unsafe_blocks)] use std::future::Future; -use std::io::ErrorKind; use std::net::SocketAddr; use std::os::fd::{AsRawFd, RawFd}; use std::pin::Pin; @@ -227,7 +226,7 @@ impl MaybeWriteOnly { match self { MaybeWriteOnly::Full(framed) => framed.read_startup_message().await, MaybeWriteOnly::WriteOnly(_) => { - Err(io::Error::new(ErrorKind::Other, "reading from write only half").into()) + Err(io::Error::other("reading from write only half").into()) } MaybeWriteOnly::Broken => panic!("IO on invalid MaybeWriteOnly"), } @@ -237,7 +236,7 @@ impl MaybeWriteOnly { match self { MaybeWriteOnly::Full(framed) => framed.read_message().await, MaybeWriteOnly::WriteOnly(_) => { - Err(io::Error::new(ErrorKind::Other, "reading from write only half").into()) + Err(io::Error::other("reading from write only half").into()) } MaybeWriteOnly::Broken => panic!("IO on invalid MaybeWriteOnly"), } @@ -975,7 +974,7 @@ impl AsyncWrite for CopyDataWriter<'_, IO> { .write_message_noflush(&BeMessage::CopyData(buf)) // write_message only writes to the buffer, so it can fail iff the // message is invaid, but CopyData can't be invalid. - .map_err(|_| io::Error::new(ErrorKind::Other, "failed to serialize CopyData"))?; + .map_err(|_| io::Error::other("failed to serialize CopyData"))?; Poll::Ready(Ok(buf.len())) } diff --git a/libs/postgres_backend/tests/simple_select.rs b/libs/postgres_backend/tests/simple_select.rs index 907ef9eed3b4..3b1624ef32ce 100644 --- a/libs/postgres_backend/tests/simple_select.rs +++ b/libs/postgres_backend/tests/simple_select.rs @@ -85,8 +85,8 @@ static KEY: Lazy> = Lazy::new(|| { static CERT: Lazy> = Lazy::new(|| { let mut cursor = Cursor::new(include_bytes!("cert.pem")); - let cert = rustls_pemfile::certs(&mut cursor).next().unwrap().unwrap(); - cert + + rustls_pemfile::certs(&mut cursor).next().unwrap().unwrap() }); // test that basic select with ssl works diff --git a/libs/pq_proto/src/framed.rs b/libs/pq_proto/src/framed.rs index 8e216d0f44ad..4e5e48ecf585 100644 --- a/libs/pq_proto/src/framed.rs +++ b/libs/pq_proto/src/framed.rs @@ -35,7 +35,7 @@ impl ConnectionError { pub fn into_io_error(self) -> io::Error { match self { ConnectionError::Io(io) => io, - ConnectionError::Protocol(pe) => io::Error::new(io::ErrorKind::Other, pe.to_string()), + ConnectionError::Protocol(pe) => io::Error::other(pe.to_string()), } } } diff --git a/libs/pq_proto/src/lib.rs b/libs/pq_proto/src/lib.rs index e435ffbf7e05..e7afc6456401 100644 --- a/libs/pq_proto/src/lib.rs +++ b/libs/pq_proto/src/lib.rs @@ -257,7 +257,7 @@ pub enum ProtocolError { impl ProtocolError { /// Proxy stream.rs uses only io::Error; provide it. pub fn into_io_error(self) -> io::Error { - io::Error::new(io::ErrorKind::Other, self.to_string()) + io::Error::other(self.to_string()) } } diff --git a/libs/proxy/postgres-protocol2/src/authentication/sasl.rs b/libs/proxy/postgres-protocol2/src/authentication/sasl.rs index 27e05e24ec4a..7eb5f7d34d66 100644 --- a/libs/proxy/postgres-protocol2/src/authentication/sasl.rs +++ b/libs/proxy/postgres-protocol2/src/authentication/sasl.rs @@ -212,7 +212,7 @@ impl ScramSha256 { password, channel_binding, } => (nonce, password, channel_binding), - _ => return Err(io::Error::new(io::ErrorKind::Other, "invalid SCRAM state")), + _ => return Err(io::Error::other("invalid SCRAM state")), }; let message = @@ -291,7 +291,7 @@ impl ScramSha256 { server_key, auth_message, } => (server_key, auth_message), - _ => return Err(io::Error::new(io::ErrorKind::Other, "invalid SCRAM state")), + _ => return Err(io::Error::other("invalid SCRAM state")), }; let message = diff --git a/libs/remote_storage/src/azure_blob.rs b/libs/remote_storage/src/azure_blob.rs index dee61a410d7d..18146c5464d5 100644 --- a/libs/remote_storage/src/azure_blob.rs +++ b/libs/remote_storage/src/azure_blob.rs @@ -801,8 +801,7 @@ where // that support needs to be hacked in. // // including {self:?} into the message would be useful, but unsure how to unproject. - _ => std::task::Poll::Ready(Err(std::io::Error::new( - std::io::ErrorKind::Other, + _ => std::task::Poll::Ready(Err(std::io::Error::other( "cloned or initial values cannot be read", ))), } @@ -855,7 +854,7 @@ where }; Err(azure_core::error::Error::new( azure_core::error::ErrorKind::Io, - std::io::Error::new(std::io::ErrorKind::Other, msg), + std::io::Error::other(msg), )) } diff --git a/libs/remote_storage/tests/test_real_s3.rs b/libs/remote_storage/tests/test_real_s3.rs index 6996bb27ae25..d38e13fd0517 100644 --- a/libs/remote_storage/tests/test_real_s3.rs +++ b/libs/remote_storage/tests/test_real_s3.rs @@ -558,7 +558,7 @@ async fn upload_large_enough_file( ) -> usize { let header = bytes::Bytes::from_static("remote blob data content".as_bytes()); let body = bytes::Bytes::from(vec![0u8; 1024]); - let contents = std::iter::once(header).chain(std::iter::repeat(body).take(128)); + let contents = std::iter::once(header).chain(std::iter::repeat_n(body, 128)); let len = contents.clone().fold(0, |acc, next| acc + next.len()); From 8eb9a804a1bded0aafcca8d38730138dfc468c3e Mon Sep 17 00:00:00 2001 From: Conrad Ludgate Date: Mon, 17 Mar 2025 09:25:55 +0000 Subject: [PATCH 2/5] clippy --fix again --- compute_tools/src/catalog.rs | 16 +++++++++------- control_plane/storcon_cli/src/main.rs | 2 +- libs/postgres_backend/tests/simple_select.rs | 2 +- pageserver/src/task_mgr.rs | 3 +-- pageserver/src/tenant.rs | 7 ++----- .../src/tenant/layer_map/layer_coverage.rs | 2 +- .../tenant/storage_layer/batch_split_writer.rs | 2 +- .../inmemory_layer/vectored_dio_read.rs | 2 +- pageserver/src/tenant/timeline.rs | 2 +- proxy/src/cancellation.rs | 7 +------ proxy/src/proxy/tests/mod.rs | 5 ++--- safekeeper/src/timeline_eviction.rs | 5 ++--- safekeeper/tests/misc_test.rs | 2 +- storage_controller/src/heartbeater.rs | 4 ++-- storage_controller/src/main.rs | 4 +--- storage_controller/src/tenant_shard.rs | 2 +- storage_scrubber/src/find_large_objects.rs | 2 +- 17 files changed, 29 insertions(+), 40 deletions(-) diff --git a/compute_tools/src/catalog.rs b/compute_tools/src/catalog.rs index daffe970d4fd..082ba62b8e99 100644 --- a/compute_tools/src/catalog.rs +++ b/compute_tools/src/catalog.rs @@ -98,13 +98,15 @@ pub async fn get_database_schema( .kill_on_drop(true) .spawn()?; - let stdout = cmd.stdout.take().ok_or_else(|| { - std::io::Error::other("Failed to capture stdout.") - })?; - - let stderr = cmd.stderr.take().ok_or_else(|| { - std::io::Error::other("Failed to capture stderr.") - })?; + let stdout = cmd + .stdout + .take() + .ok_or_else(|| std::io::Error::other("Failed to capture stdout."))?; + + let stderr = cmd + .stderr + .take() + .ok_or_else(|| std::io::Error::other("Failed to capture stderr."))?; let mut stdout_reader = FramedRead::new(stdout, BytesCodec::new()); let stderr_reader = BufReader::new(stderr); diff --git a/control_plane/storcon_cli/src/main.rs b/control_plane/storcon_cli/src/main.rs index c503697acca1..e6e78acf03c2 100644 --- a/control_plane/storcon_cli/src/main.rs +++ b/control_plane/storcon_cli/src/main.rs @@ -941,7 +941,7 @@ async fn main() -> anyhow::Result<()> { let mut node_to_fill_descs = Vec::new(); for desc in node_descs { - let to_drain = nodes.iter().any(|id| *id == desc.id); + let to_drain = nodes.contains(&desc.id); if to_drain { node_to_drain_descs.push(desc); } else { diff --git a/libs/postgres_backend/tests/simple_select.rs b/libs/postgres_backend/tests/simple_select.rs index 3b1624ef32ce..75ca12301463 100644 --- a/libs/postgres_backend/tests/simple_select.rs +++ b/libs/postgres_backend/tests/simple_select.rs @@ -85,7 +85,7 @@ static KEY: Lazy> = Lazy::new(|| { static CERT: Lazy> = Lazy::new(|| { let mut cursor = Cursor::new(include_bytes!("cert.pem")); - + rustls_pemfile::certs(&mut cursor).next().unwrap().unwrap() }); diff --git a/pageserver/src/task_mgr.rs b/pageserver/src/task_mgr.rs index 9cc604f86d54..d4873e60a10f 100644 --- a/pageserver/src/task_mgr.rs +++ b/pageserver/src/task_mgr.rs @@ -219,8 +219,7 @@ pageserver_runtime!(MGMT_REQUEST_RUNTIME, "mgmt request worker"); pageserver_runtime!(WALRECEIVER_RUNTIME, "walreceiver worker"); pageserver_runtime!(BACKGROUND_RUNTIME, "background op worker"); // Bump this number when adding a new pageserver_runtime! -// SAFETY: it's obviously correct -const NUM_MULTIPLE_RUNTIMES: NonZeroUsize = unsafe { NonZeroUsize::new_unchecked(4) }; +const NUM_MULTIPLE_RUNTIMES: NonZeroUsize = NonZeroUsize::new(4).unwrap(); #[derive(Debug, Clone, Copy)] pub struct PageserverTaskId(u64); diff --git a/pageserver/src/tenant.rs b/pageserver/src/tenant.rs index e7d8ed75ed84..af89df4da4ae 100644 --- a/pageserver/src/tenant.rs +++ b/pageserver/src/tenant.rs @@ -3681,7 +3681,7 @@ impl Tenant { } } } - TenantState::Active { .. } => { + TenantState::Active => { return Ok(()); } TenantState::Broken { reason, .. } => { @@ -4387,10 +4387,7 @@ impl Tenant { .to_string(); fail::fail_point!("tenant-config-before-write", |_| { - Err(std::io::Error::new( - std::io::ErrorKind::Other, - "tenant-config-before-write", - )) + Err(std::io::Error::other("tenant-config-before-write")) }); // Convert the config to a toml file. diff --git a/pageserver/src/tenant/layer_map/layer_coverage.rs b/pageserver/src/tenant/layer_map/layer_coverage.rs index cf0085c07190..a42ac92973b8 100644 --- a/pageserver/src/tenant/layer_map/layer_coverage.rs +++ b/pageserver/src/tenant/layer_map/layer_coverage.rs @@ -53,7 +53,7 @@ impl LayerCoverage { /// /// Complexity: O(log N) fn add_node(&mut self, key: i128) { - let value = match self.nodes.range(..=key).last() { + let value = match self.nodes.range(..=key).next_back() { Some((_, Some(v))) => Some(v.clone()), Some((_, None)) => None, None => None, diff --git a/pageserver/src/tenant/storage_layer/batch_split_writer.rs b/pageserver/src/tenant/storage_layer/batch_split_writer.rs index fd50e4805de4..29ada15c369a 100644 --- a/pageserver/src/tenant/storage_layer/batch_split_writer.rs +++ b/pageserver/src/tenant/storage_layer/batch_split_writer.rs @@ -366,7 +366,7 @@ impl SplitDeltaLayerWriter { ) .await?; let (start_key, prev_delta_writer) = - std::mem::replace(&mut self.inner, Some((key, next_delta_writer))).unwrap(); + self.inner.replace((key, next_delta_writer)).unwrap(); self.batches.add_unfinished_delta_writer( prev_delta_writer, start_key..key, diff --git a/pageserver/src/tenant/storage_layer/inmemory_layer/vectored_dio_read.rs b/pageserver/src/tenant/storage_layer/inmemory_layer/vectored_dio_read.rs index 90455fd0cabd..ea354fc716d6 100644 --- a/pageserver/src/tenant/storage_layer/inmemory_layer/vectored_dio_read.rs +++ b/pageserver/src/tenant/storage_layer/inmemory_layer/vectored_dio_read.rs @@ -766,7 +766,7 @@ mod tests { rand::Rng::fill(&mut rand::thread_rng(), &mut dst_slice[len..]); // to discover bugs Ok((dst, len)) } - Err(e) => Err(std::io::Error::new(std::io::ErrorKind::Other, e)), + Err(e) => Err(std::io::Error::other(e)), } } } diff --git a/pageserver/src/tenant/timeline.rs b/pageserver/src/tenant/timeline.rs index 75f9225302e6..5bfbf6512f66 100644 --- a/pageserver/src/tenant/timeline.rs +++ b/pageserver/src/tenant/timeline.rs @@ -2231,7 +2231,7 @@ impl Timeline { .await .expect("holding a reference to self"); } - TimelineState::Active { .. } => { + TimelineState::Active => { return Ok(()); } TimelineState::Broken { .. } | TimelineState::Stopping => { diff --git a/proxy/src/cancellation.rs b/proxy/src/cancellation.rs index 8263e5aa2aa8..d6a7406f67c9 100644 --- a/proxy/src/cancellation.rs +++ b/proxy/src/cancellation.rs @@ -425,12 +425,7 @@ impl CancelClosure { &mut mk_tls, &self.hostname, ) - .map_err(|e| { - CancelError::IO(std::io::Error::new( - std::io::ErrorKind::Other, - e.to_string(), - )) - })?; + .map_err(|e| CancelError::IO(std::io::Error::other(e.to_string())))?; self.cancel_token.cancel_query_raw(socket, tls).await?; debug!("query was cancelled"); diff --git a/proxy/src/proxy/tests/mod.rs b/proxy/src/proxy/tests/mod.rs index 2c3e70138d9e..2268e60d257d 100644 --- a/proxy/src/proxy/tests/mod.rs +++ b/proxy/src/proxy/tests/mod.rs @@ -568,7 +568,7 @@ fn helper_create_cached_node_info(cache: &'static NodeInfoCache) -> CachedNodeIn fn helper_create_connect_info( mechanism: &TestConnectMechanism, ) -> auth::Backend<'static, ComputeCredentials> { - let user_info = auth::Backend::ControlPlane( + auth::Backend::ControlPlane( MaybeOwned::Owned(ControlPlaneClient::Test(Box::new(mechanism.clone()))), ComputeCredentials { info: ComputeUserInfo { @@ -578,8 +578,7 @@ fn helper_create_connect_info( }, keys: ComputeCredentialKeys::Password("password".into()), }, - ); - user_info + ) } fn config() -> ComputeConfig { diff --git a/safekeeper/src/timeline_eviction.rs b/safekeeper/src/timeline_eviction.rs index 06ccb32d03a1..84c636daf627 100644 --- a/safekeeper/src/timeline_eviction.rs +++ b/safekeeper/src/timeline_eviction.rs @@ -35,7 +35,7 @@ impl Manager { next_event: &Option, state: &StateSnapshot, ) -> bool { - let ready = self.backup_task.is_none() + self.backup_task.is_none() && self.recovery_task.is_none() && self.wal_removal_task.is_none() && self.partial_backup_task.is_none() @@ -61,8 +61,7 @@ impl Manager { .unwrap() .flush_lsn .segment_number(self.wal_seg_size) - == self.last_removed_segno + 1; - ready + == self.last_removed_segno + 1 } /// Evict the timeline to remote storage. Returns whether the eviction was successful. diff --git a/safekeeper/tests/misc_test.rs b/safekeeper/tests/misc_test.rs index 8e54d2bb868e..3acf9f72c4d0 100644 --- a/safekeeper/tests/misc_test.rs +++ b/safekeeper/tests/misc_test.rs @@ -116,7 +116,7 @@ fn test_many_tx() -> anyhow::Result<()> { } None }) - .last() + .next_back() .unwrap(); let initdb_lsn = 21623024; diff --git a/storage_controller/src/heartbeater.rs b/storage_controller/src/heartbeater.rs index 524225c14a71..732c4ea443f8 100644 --- a/storage_controller/src/heartbeater.rs +++ b/storage_controller/src/heartbeater.rs @@ -253,7 +253,7 @@ impl HeartBeat for HeartbeaterTask PageserverState::WarmingUp { .. } => { warming_up += 1; } - PageserverState::Offline { .. } => offline += 1, + PageserverState::Offline => offline += 1, PageserverState::Available { .. } => {} } } @@ -391,7 +391,7 @@ impl HeartBeat for HeartbeaterTask offline += 1, + SafekeeperState::Offline => offline += 1, SafekeeperState::Available { .. } => {} } } diff --git a/storage_controller/src/main.rs b/storage_controller/src/main.rs index 1a7f9a236660..ff9cb6c5ccf6 100644 --- a/storage_controller/src/main.rs +++ b/storage_controller/src/main.rs @@ -285,10 +285,8 @@ impl Secrets { fn load_secret(cli: &Option, env_name: &str) -> Option { if let Some(v) = cli { Some(v.clone()) - } else if let Ok(v) = std::env::var(env_name) { - Some(v) } else { - None + std::env::var(env_name).ok() } } } diff --git a/storage_controller/src/tenant_shard.rs b/storage_controller/src/tenant_shard.rs index f6b748844a47..8424c65aba4c 100644 --- a/storage_controller/src/tenant_shard.rs +++ b/storage_controller/src/tenant_shard.rs @@ -622,7 +622,7 @@ impl TenantShard { .collect::>(); attached_locs.sort_by_key(|i| i.1); - if let Some((node_id, _gen)) = attached_locs.into_iter().last() { + if let Some((node_id, _gen)) = attached_locs.into_iter().next_back() { self.intent.set_attached(scheduler, Some(*node_id)); } diff --git a/storage_scrubber/src/find_large_objects.rs b/storage_scrubber/src/find_large_objects.rs index efb05fb55eaa..a4ca68d378e3 100644 --- a/storage_scrubber/src/find_large_objects.rs +++ b/storage_scrubber/src/find_large_objects.rs @@ -18,7 +18,7 @@ enum LargeObjectKind { impl LargeObjectKind { fn from_key(key: &str) -> Self { - let fname = key.split('/').last().unwrap(); + let fname = key.split('/').next_back().unwrap(); let Ok((layer_name, _generation)) = parse_layer_object_name(fname) else { return LargeObjectKind::Other; From b39ccc1616bd8ceb988da52f7e0cd8505e7a3716 Mon Sep 17 00:00:00 2001 From: Conrad Ludgate Date: Mon, 17 Mar 2025 09:38:44 +0000 Subject: [PATCH 3/5] manually fix the rest of the nightly lints --- .../postgres-protocol2/src/authentication/sasl.rs | 5 +---- libs/utils/src/crashsafe.rs | 9 +++------ pageserver/src/http/routes.rs | 12 ++++++------ pageserver/src/tenant.rs | 2 ++ pageserver/src/tenant/blob_io.rs | 7 ++----- pageserver/src/tenant/block_io.rs | 8 ++------ pageserver/src/tenant/mgr.rs | 2 +- .../src/tenant/remote_timeline_client/index.rs | 2 +- .../src/tenant/storage_layer/merge_iterator.rs | 1 + pageserver/src/tenant/timeline.rs | 1 + pageserver/src/tenant/upload_queue.rs | 1 + .../owned_buffers_io/aligned_buffer/buffer_mut.rs | 4 ++-- .../owned_buffers_io/aligned_buffer/raw.rs | 4 ++-- proxy/src/serverless/conn_pool_lib.rs | 1 + safekeeper/src/timeline.rs | 1 + storage_broker/src/bin/storage_broker.rs | 6 ++++++ storage_broker/src/lib.rs | 1 + 17 files changed, 34 insertions(+), 33 deletions(-) diff --git a/libs/proxy/postgres-protocol2/src/authentication/sasl.rs b/libs/proxy/postgres-protocol2/src/authentication/sasl.rs index 7eb5f7d34d66..2daf9a80d453 100644 --- a/libs/proxy/postgres-protocol2/src/authentication/sasl.rs +++ b/libs/proxy/postgres-protocol2/src/authentication/sasl.rs @@ -301,10 +301,7 @@ impl ScramSha256 { let verifier = match parsed { ServerFinalMessage::Error(e) => { - return Err(io::Error::new( - io::ErrorKind::Other, - format!("SCRAM error: {}", e), - )); + return Err(io::Error::other(format!("SCRAM error: {}", e))); } ServerFinalMessage::Verifier(verifier) => verifier, }; diff --git a/libs/utils/src/crashsafe.rs b/libs/utils/src/crashsafe.rs index 290a5b26863a..215fa36df49b 100644 --- a/libs/utils/src/crashsafe.rs +++ b/libs/utils/src/crashsafe.rs @@ -81,12 +81,9 @@ pub fn path_with_suffix_extension( } pub fn fsync_file_and_parent(file_path: &Utf8Path) -> io::Result<()> { - let parent = file_path.parent().ok_or_else(|| { - io::Error::new( - io::ErrorKind::Other, - format!("File {file_path:?} has no parent"), - ) - })?; + let parent = file_path + .parent() + .ok_or_else(|| io::Error::other(format!("File {file_path:?} has no parent")))?; fsync(file_path)?; fsync(parent)?; diff --git a/pageserver/src/http/routes.rs b/pageserver/src/http/routes.rs index 5a13fb1387b0..361cc8af4e27 100644 --- a/pageserver/src/http/routes.rs +++ b/pageserver/src/http/routes.rs @@ -3356,11 +3356,11 @@ async fn put_tenant_timeline_import_basebackup( let broker_client = state.broker_client.clone(); - let mut body = StreamReader::new(request.into_body().map(|res| { - res.map_err(|error| { - std::io::Error::new(std::io::ErrorKind::Other, anyhow::anyhow!(error)) - }) - })); + let mut body = StreamReader::new( + request + .into_body() + .map(|res| res.map_err(|error| std::io::Error::other(anyhow::anyhow!(error)))), + ); tenant.wait_to_become_active(ACTIVE_TENANT_TIMEOUT).await?; @@ -3433,7 +3433,7 @@ async fn put_tenant_timeline_import_wal( let mut body = StreamReader::new(request.into_body().map(|res| { res.map_err(|error| { - std::io::Error::new(std::io::ErrorKind::Other, anyhow::anyhow!(error)) + std::io::Error::other( anyhow::anyhow!(error)) }) })); diff --git a/pageserver/src/tenant.rs b/pageserver/src/tenant.rs index af89df4da4ae..d3373b9c5a7c 100644 --- a/pageserver/src/tenant.rs +++ b/pageserver/src/tenant.rs @@ -915,6 +915,7 @@ enum StartCreatingTimelineResult { Idempotent(Arc), } +#[expect(clippy::large_enum_variant, reason = "TODO")] enum TimelineInitAndSyncResult { ReadyToActivate(Arc), NeedsSpawnImportPgdata(TimelineInitAndSyncNeedsSpawnImportPgdata), @@ -1001,6 +1002,7 @@ enum CreateTimelineCause { Delete, } +#[expect(clippy::large_enum_variant, reason = "TODO")] enum LoadTimelineCause { Attach, Unoffload, diff --git a/pageserver/src/tenant/blob_io.rs b/pageserver/src/tenant/blob_io.rs index ff9a7e57b61c..b0b2a16c2f94 100644 --- a/pageserver/src/tenant/blob_io.rs +++ b/pageserver/src/tenant/blob_io.rs @@ -15,7 +15,7 @@ //! len >= 128: 1CCCXXXX XXXXXXXX XXXXXXXX XXXXXXXX //! use std::cmp::min; -use std::io::{Error, ErrorKind}; +use std::io::Error; use async_compression::Level; use bytes::{BufMut, BytesMut}; @@ -331,10 +331,7 @@ impl BlobWriter { return ( ( io_buf.slice_len(), - Err(Error::new( - ErrorKind::Other, - format!("blob too large ({len} bytes)"), - )), + Err(Error::other(format!("blob too large ({len} bytes)"))), ), srcbuf, ); diff --git a/pageserver/src/tenant/block_io.rs b/pageserver/src/tenant/block_io.rs index 66c586daffdc..67231556262f 100644 --- a/pageserver/src/tenant/block_io.rs +++ b/pageserver/src/tenant/block_io.rs @@ -216,12 +216,8 @@ impl<'a> FileBlockReader<'a> { match cache .read_immutable_buf(self.file_id, blknum, ctx) .await - .map_err(|e| { - std::io::Error::new( - std::io::ErrorKind::Other, - format!("Failed to read immutable buf: {e:#}"), - ) - })? { + .map_err(|e| std::io::Error::other(format!("Failed to read immutable buf: {e:#}")))? + { ReadBufResult::Found(guard) => Ok(guard.into()), ReadBufResult::NotFound(write_guard) => { // Read the page from disk into the buffer diff --git a/pageserver/src/tenant/mgr.rs b/pageserver/src/tenant/mgr.rs index 61ad682a1479..ac81b8e3d771 100644 --- a/pageserver/src/tenant/mgr.rs +++ b/pageserver/src/tenant/mgr.rs @@ -58,7 +58,7 @@ use crate::{InitializationOrder, TEMP_FILE_SUFFIX}; /// For a tenant that appears in TenantsMap, it may either be /// - `Attached`: has a full Tenant object, is elegible to service -/// reads and ingest WAL. +/// reads and ingest WAL. /// - `Secondary`: is only keeping a local cache warm. /// /// Secondary is a totally distinct state rather than being a mode of a `Tenant`, because diff --git a/pageserver/src/tenant/remote_timeline_client/index.rs b/pageserver/src/tenant/remote_timeline_client/index.rs index 5635cf32681e..a5cd8989aa4a 100644 --- a/pageserver/src/tenant/remote_timeline_client/index.rs +++ b/pageserver/src/tenant/remote_timeline_client/index.rs @@ -130,7 +130,7 @@ impl IndexPart { /// Version history /// - 2: added `deleted_at` /// - 3: no longer deserialize `timeline_layers` (serialized format is the same, but timeline_layers - /// is always generated from the keys of `layer_metadata`) + /// is always generated from the keys of `layer_metadata`) /// - 4: timeline_layers is fully removed. /// - 5: lineage was added /// - 6: last_aux_file_policy is added. diff --git a/pageserver/src/tenant/storage_layer/merge_iterator.rs b/pageserver/src/tenant/storage_layer/merge_iterator.rs index 76cdddd06a8b..545c8747884b 100644 --- a/pageserver/src/tenant/storage_layer/merge_iterator.rs +++ b/pageserver/src/tenant/storage_layer/merge_iterator.rs @@ -59,6 +59,7 @@ impl LayerIterRef<'_> { /// 1. Unified iterator for image and delta layers. /// 2. `Ord` for use in [`MergeIterator::heap`] (for the k-merge). /// 3. Lazy creation of the real delta/image iterator. +#[expect(clippy::large_enum_variant, reason = "TODO")] pub(crate) enum IteratorWrapper<'a> { NotLoaded { ctx: &'a RequestContext, diff --git a/pageserver/src/tenant/timeline.rs b/pageserver/src/tenant/timeline.rs index 5bfbf6512f66..2a1d2851812e 100644 --- a/pageserver/src/tenant/timeline.rs +++ b/pageserver/src/tenant/timeline.rs @@ -1025,6 +1025,7 @@ pub(crate) enum ShutdownMode { Hard, } +#[expect(clippy::large_enum_variant, reason = "TODO")] enum ImageLayerCreationOutcome { /// We generated an image layer Generated { diff --git a/pageserver/src/tenant/upload_queue.rs b/pageserver/src/tenant/upload_queue.rs index d5dc9666ce6b..b581bcbd020a 100644 --- a/pageserver/src/tenant/upload_queue.rs +++ b/pageserver/src/tenant/upload_queue.rs @@ -302,6 +302,7 @@ pub struct UploadQueueStoppedDeletable { pub(super) deleted_at: SetDeletedFlagProgress, } +#[expect(clippy::large_enum_variant, reason = "TODO")] pub enum UploadQueueStopped { Deletable(UploadQueueStoppedDeletable), Uninitialized, diff --git a/pageserver/src/virtual_file/owned_buffers_io/aligned_buffer/buffer_mut.rs b/pageserver/src/virtual_file/owned_buffers_io/aligned_buffer/buffer_mut.rs index df5c911e502a..3ee1a3c1620e 100644 --- a/pageserver/src/virtual_file/owned_buffers_io/aligned_buffer/buffer_mut.rs +++ b/pageserver/src/virtual_file/owned_buffers_io/aligned_buffer/buffer_mut.rs @@ -25,8 +25,8 @@ impl AlignedBufferMut> { /// * `align` must be a power of two, /// /// * `capacity`, when rounded up to the nearest multiple of `align`, - /// must not overflow isize (i.e., the rounded value must be - /// less than or equal to `isize::MAX`). + /// must not overflow isize (i.e., the rounded value must be + /// less than or equal to `isize::MAX`). pub fn with_capacity(capacity: usize) -> Self { AlignedBufferMut { raw: RawAlignedBuffer::with_capacity(capacity), diff --git a/pageserver/src/virtual_file/owned_buffers_io/aligned_buffer/raw.rs b/pageserver/src/virtual_file/owned_buffers_io/aligned_buffer/raw.rs index 97a6c4049a62..d2737724112f 100644 --- a/pageserver/src/virtual_file/owned_buffers_io/aligned_buffer/raw.rs +++ b/pageserver/src/virtual_file/owned_buffers_io/aligned_buffer/raw.rs @@ -37,8 +37,8 @@ impl RawAlignedBuffer> { /// * `align` must be a power of two, /// /// * `capacity`, when rounded up to the nearest multiple of `align`, - /// must not overflow isize (i.e., the rounded value must be - /// less than or equal to `isize::MAX`). + /// must not overflow isize (i.e., the rounded value must be + /// less than or equal to `isize::MAX`). pub fn with_capacity(capacity: usize) -> Self { let align = ConstAlign::; let layout = Layout::from_size_align(capacity, align.align()).expect("Invalid layout"); diff --git a/proxy/src/serverless/conn_pool_lib.rs b/proxy/src/serverless/conn_pool_lib.rs index 77b548cc43a7..fb5b44d84932 100644 --- a/proxy/src/serverless/conn_pool_lib.rs +++ b/proxy/src/serverless/conn_pool_lib.rs @@ -47,6 +47,7 @@ impl ConnInfo { } #[derive(Clone)] +#[expect(clippy::large_enum_variant, reason = "TODO")] pub(crate) enum ClientDataEnum { Remote(ClientDataRemote), Local(ClientDataLocal), diff --git a/safekeeper/src/timeline.rs b/safekeeper/src/timeline.rs index d3c841ec0905..bf175ab2b603 100644 --- a/safekeeper/src/timeline.rs +++ b/safekeeper/src/timeline.rs @@ -137,6 +137,7 @@ impl Drop for WriteGuardSharedState<'_> { /// Usually it holds SafeKeeper, but it also supports offloaded timeline state. In this /// case, SafeKeeper is not available (because WAL is not present on disk) and all /// operations can be done only with control file. +#[expect(clippy::large_enum_variant, reason = "TODO")] pub enum StateSK { Loaded(SafeKeeper), Offloaded(Box>), diff --git a/storage_broker/src/bin/storage_broker.rs b/storage_broker/src/bin/storage_broker.rs index cc33ec20ff1a..cf41899c55d9 100644 --- a/storage_broker/src/bin/storage_broker.rs +++ b/storage_broker/src/bin/storage_broker.rs @@ -96,6 +96,7 @@ enum Message { impl Message { /// Convert proto message to internal message. + #[expect(clippy::result_large_err, reason = "TODO")] pub fn from(proto_msg: TypedMessage) -> Result { match proto_msg.r#type() { MessageType::SafekeeperTimelineInfo => Ok(Message::SafekeeperTimelineInfo( @@ -127,6 +128,7 @@ impl Message { } /// Get the tenant_timeline_id from the message. + #[expect(clippy::result_large_err, reason = "TODO")] pub fn tenant_timeline_id(&self) -> Result, Status> { match self { Message::SafekeeperTimelineInfo(msg) => Ok(msg @@ -185,6 +187,7 @@ enum SubscriptionKey { impl SubscriptionKey { /// Parse protobuf subkey (protobuf doesn't have fixed size bytes, we get vectors). + #[expect(clippy::result_large_err, reason = "TODO")] pub fn from_proto_subscription_key(key: ProtoSubscriptionKey) -> Result { match key { ProtoSubscriptionKey::All(_) => Ok(SubscriptionKey::All), @@ -195,6 +198,7 @@ impl SubscriptionKey { } /// Parse from FilterTenantTimelineId + #[expect(clippy::result_large_err, reason = "TODO")] pub fn from_proto_filter_tenant_timeline_id( opt: Option<&FilterTenantTimelineId>, ) -> Result { @@ -385,6 +389,7 @@ impl Registry { } /// Send msg to relevant subscribers. + #[expect(clippy::result_large_err, reason = "TODO")] pub fn send_msg(&self, msg: &Message) -> Result<(), Status> { PROCESSED_MESSAGES_TOTAL.inc(); @@ -436,6 +441,7 @@ struct Publisher { impl Publisher { /// Send msg to relevant subscribers. + #[expect(clippy::result_large_err, reason = "TODO")] pub fn send_msg(&mut self, msg: &Message) -> Result<(), Status> { self.registry.send_msg(msg) } diff --git a/storage_broker/src/lib.rs b/storage_broker/src/lib.rs index 55d411f607fb..ac474676eb65 100644 --- a/storage_broker/src/lib.rs +++ b/storage_broker/src/lib.rs @@ -79,6 +79,7 @@ impl BrokerClientChannel { } // parse variable length bytes from protobuf +#[expect(clippy::result_large_err, reason = "TODO")] pub fn parse_proto_ttid(proto_ttid: &ProtoTenantTimelineId) -> Result { let tenant_id = TenantId::from_slice(&proto_ttid.tenant_id) .map_err(|e| Status::new(Code::InvalidArgument, format!("malformed tenant_id: {}", e)))?; From aa41fb6a12560c8e654cd4086e70dda868159df6 Mon Sep 17 00:00:00 2001 From: Conrad Ludgate Date: Mon, 17 Mar 2025 09:40:11 +0000 Subject: [PATCH 4/5] mark expectations as allow for the sake of compatibility --- pageserver/src/tenant.rs | 4 ++-- .../src/tenant/storage_layer/merge_iterator.rs | 2 +- pageserver/src/tenant/timeline.rs | 2 +- pageserver/src/tenant/upload_queue.rs | 2 +- proxy/src/serverless/conn_pool_lib.rs | 2 +- safekeeper/src/timeline.rs | 2 +- storage_broker/src/bin/storage_broker.rs | 12 ++++++------ storage_broker/src/lib.rs | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pageserver/src/tenant.rs b/pageserver/src/tenant.rs index d3373b9c5a7c..8c99c5e9603b 100644 --- a/pageserver/src/tenant.rs +++ b/pageserver/src/tenant.rs @@ -915,7 +915,7 @@ enum StartCreatingTimelineResult { Idempotent(Arc), } -#[expect(clippy::large_enum_variant, reason = "TODO")] +#[allow(clippy::large_enum_variant, reason = "TODO")] enum TimelineInitAndSyncResult { ReadyToActivate(Arc), NeedsSpawnImportPgdata(TimelineInitAndSyncNeedsSpawnImportPgdata), @@ -1002,7 +1002,7 @@ enum CreateTimelineCause { Delete, } -#[expect(clippy::large_enum_variant, reason = "TODO")] +#[allow(clippy::large_enum_variant, reason = "TODO")] enum LoadTimelineCause { Attach, Unoffload, diff --git a/pageserver/src/tenant/storage_layer/merge_iterator.rs b/pageserver/src/tenant/storage_layer/merge_iterator.rs index 545c8747884b..55db9fe06a32 100644 --- a/pageserver/src/tenant/storage_layer/merge_iterator.rs +++ b/pageserver/src/tenant/storage_layer/merge_iterator.rs @@ -59,7 +59,7 @@ impl LayerIterRef<'_> { /// 1. Unified iterator for image and delta layers. /// 2. `Ord` for use in [`MergeIterator::heap`] (for the k-merge). /// 3. Lazy creation of the real delta/image iterator. -#[expect(clippy::large_enum_variant, reason = "TODO")] +#[allow(clippy::large_enum_variant, reason = "TODO")] pub(crate) enum IteratorWrapper<'a> { NotLoaded { ctx: &'a RequestContext, diff --git a/pageserver/src/tenant/timeline.rs b/pageserver/src/tenant/timeline.rs index 2a1d2851812e..de41a707065a 100644 --- a/pageserver/src/tenant/timeline.rs +++ b/pageserver/src/tenant/timeline.rs @@ -1025,7 +1025,7 @@ pub(crate) enum ShutdownMode { Hard, } -#[expect(clippy::large_enum_variant, reason = "TODO")] +#[allow(clippy::large_enum_variant, reason = "TODO")] enum ImageLayerCreationOutcome { /// We generated an image layer Generated { diff --git a/pageserver/src/tenant/upload_queue.rs b/pageserver/src/tenant/upload_queue.rs index b581bcbd020a..be1b55ffa3ef 100644 --- a/pageserver/src/tenant/upload_queue.rs +++ b/pageserver/src/tenant/upload_queue.rs @@ -302,7 +302,7 @@ pub struct UploadQueueStoppedDeletable { pub(super) deleted_at: SetDeletedFlagProgress, } -#[expect(clippy::large_enum_variant, reason = "TODO")] +#[allow(clippy::large_enum_variant, reason = "TODO")] pub enum UploadQueueStopped { Deletable(UploadQueueStoppedDeletable), Uninitialized, diff --git a/proxy/src/serverless/conn_pool_lib.rs b/proxy/src/serverless/conn_pool_lib.rs index fb5b44d84932..42a3ea17a248 100644 --- a/proxy/src/serverless/conn_pool_lib.rs +++ b/proxy/src/serverless/conn_pool_lib.rs @@ -47,7 +47,7 @@ impl ConnInfo { } #[derive(Clone)] -#[expect(clippy::large_enum_variant, reason = "TODO")] +#[allow(clippy::large_enum_variant, reason = "TODO")] pub(crate) enum ClientDataEnum { Remote(ClientDataRemote), Local(ClientDataLocal), diff --git a/safekeeper/src/timeline.rs b/safekeeper/src/timeline.rs index bf175ab2b603..62f0aa70a26a 100644 --- a/safekeeper/src/timeline.rs +++ b/safekeeper/src/timeline.rs @@ -137,7 +137,7 @@ impl Drop for WriteGuardSharedState<'_> { /// Usually it holds SafeKeeper, but it also supports offloaded timeline state. In this /// case, SafeKeeper is not available (because WAL is not present on disk) and all /// operations can be done only with control file. -#[expect(clippy::large_enum_variant, reason = "TODO")] +#[allow(clippy::large_enum_variant, reason = "TODO")] pub enum StateSK { Loaded(SafeKeeper), Offloaded(Box>), diff --git a/storage_broker/src/bin/storage_broker.rs b/storage_broker/src/bin/storage_broker.rs index cf41899c55d9..9e8d3fae1be4 100644 --- a/storage_broker/src/bin/storage_broker.rs +++ b/storage_broker/src/bin/storage_broker.rs @@ -96,7 +96,7 @@ enum Message { impl Message { /// Convert proto message to internal message. - #[expect(clippy::result_large_err, reason = "TODO")] + #[allow(clippy::result_large_err, reason = "TODO")] pub fn from(proto_msg: TypedMessage) -> Result { match proto_msg.r#type() { MessageType::SafekeeperTimelineInfo => Ok(Message::SafekeeperTimelineInfo( @@ -128,7 +128,7 @@ impl Message { } /// Get the tenant_timeline_id from the message. - #[expect(clippy::result_large_err, reason = "TODO")] + #[allow(clippy::result_large_err, reason = "TODO")] pub fn tenant_timeline_id(&self) -> Result, Status> { match self { Message::SafekeeperTimelineInfo(msg) => Ok(msg @@ -187,7 +187,7 @@ enum SubscriptionKey { impl SubscriptionKey { /// Parse protobuf subkey (protobuf doesn't have fixed size bytes, we get vectors). - #[expect(clippy::result_large_err, reason = "TODO")] + #[allow(clippy::result_large_err, reason = "TODO")] pub fn from_proto_subscription_key(key: ProtoSubscriptionKey) -> Result { match key { ProtoSubscriptionKey::All(_) => Ok(SubscriptionKey::All), @@ -198,7 +198,7 @@ impl SubscriptionKey { } /// Parse from FilterTenantTimelineId - #[expect(clippy::result_large_err, reason = "TODO")] + #[allow(clippy::result_large_err, reason = "TODO")] pub fn from_proto_filter_tenant_timeline_id( opt: Option<&FilterTenantTimelineId>, ) -> Result { @@ -389,7 +389,7 @@ impl Registry { } /// Send msg to relevant subscribers. - #[expect(clippy::result_large_err, reason = "TODO")] + #[allow(clippy::result_large_err, reason = "TODO")] pub fn send_msg(&self, msg: &Message) -> Result<(), Status> { PROCESSED_MESSAGES_TOTAL.inc(); @@ -441,7 +441,7 @@ struct Publisher { impl Publisher { /// Send msg to relevant subscribers. - #[expect(clippy::result_large_err, reason = "TODO")] + #[allow(clippy::result_large_err, reason = "TODO")] pub fn send_msg(&mut self, msg: &Message) -> Result<(), Status> { self.registry.send_msg(msg) } diff --git a/storage_broker/src/lib.rs b/storage_broker/src/lib.rs index ac474676eb65..7b36f5e9483c 100644 --- a/storage_broker/src/lib.rs +++ b/storage_broker/src/lib.rs @@ -79,7 +79,7 @@ impl BrokerClientChannel { } // parse variable length bytes from protobuf -#[expect(clippy::result_large_err, reason = "TODO")] +#[allow(clippy::result_large_err, reason = "TODO")] pub fn parse_proto_ttid(proto_ttid: &ProtoTenantTimelineId) -> Result { let tenant_id = TenantId::from_slice(&proto_ttid.tenant_id) .map_err(|e| Status::new(Code::InvalidArgument, format!("malformed tenant_id: {}", e)))?; From c6372b1c1bbaad8eaf54b66af842a1fca5fed1de Mon Sep 17 00:00:00 2001 From: Conrad Ludgate Date: Mon, 31 Mar 2025 16:22:26 +0100 Subject: [PATCH 5/5] trigger ci