From cf9e4ab3f1a7ad7f4d54891bf9833da3b93e3583 Mon Sep 17 00:00:00 2001 From: WenyXu Date: Mon, 12 Oct 2026 11:19:14 +0000 Subject: [PATCH] style: preserve local error variant imports in retry hints Signed-off-by: WenyXu --- src/common/meta/src/error.rs | 88 +++++++++++------------ src/datanode/src/error.rs | 52 +++++++------- src/metric-engine/src/error.rs | 40 ++++++----- src/mito2/src/error.rs | 126 +++++++++++++++++---------------- 4 files changed, 154 insertions(+), 152 deletions(-) diff --git a/src/common/meta/src/error.rs b/src/common/meta/src/error.rs index 24159a825c2..297af792799 100644 --- a/src/common/meta/src/error.rs +++ b/src/common/meta/src/error.rs @@ -1343,62 +1343,62 @@ impl ErrorExt for Error { } fn retry_hint(&self) -> RetryHint { + use Error::*; + match self { - Error::RetryLater { source, .. } => match source.retry_hint() { + RetryLater { source, .. } => match source.retry_hint() { RetryHint::RetryAfterRouteRefresh => RetryHint::RetryAfterRouteRefresh, RetryHint::Retryable | RetryHint::NonRetryable => RetryHint::Retryable, }, - Error::GetLatestCacheRetryExceeded { .. } - | Error::NoLeader { .. } - | Error::ElectionNoLeader { .. } - | Error::ElectionLeaderLeaseExpired { .. } - | Error::ElectionLeaderLeaseChanged { .. } => RetryHint::Retryable, - Error::ConnectEtcd { error, .. } - | Error::EtcdFailed { error, .. } - | Error::EtcdTxnFailed { error, .. } => retry_hint_from_etcd_error(error), - Error::WriteObject { error, .. } | Error::ReadObject { error, .. } => { + GetLatestCacheRetryExceeded { .. } + | NoLeader { .. } + | ElectionNoLeader { .. } + | ElectionLeaderLeaseExpired { .. } + | ElectionLeaderLeaseChanged { .. } => RetryHint::Retryable, + ConnectEtcd { error, .. } | EtcdFailed { error, .. } | EtcdTxnFailed { error, .. } => { + retry_hint_from_etcd_error(error) + } + WriteObject { error, .. } | ReadObject { error, .. } => { retry_hint_from_opendal_error(error) } - Error::BuildKafkaClient { error, .. } - | Error::BuildKafkaCtrlClient { error, .. } - | Error::KafkaPartitionClient { error, .. } - | Error::KafkaGetOffset { error, .. } - | Error::ProduceRecord { error, .. } - | Error::CreateKafkaWalTopic { error, .. } => rskafka_client_error_to_retry_hint(error), - Error::SubmitProcedure { source, .. } - | Error::QueryProcedure { source, .. } - | Error::WaitProcedure { source, .. } - | Error::StartProcedureManager { source, .. } - | Error::StopProcedureManager { source, .. } - | Error::RegisterProcedureLoader { source, .. } - | Error::PutPoison { source, .. } - | Error::ProcedureStateReceiver { source, .. } => source.retry_hint(), - Error::External { source, .. } - | Error::ResponseExceededSizeLimit { source, .. } - | Error::OperateDatanode { source, .. } - | Error::AbortProcedure { source, .. } - | Error::RegisterRepartitionProcedureLoader { source, .. } - | Error::CreateRepartitionProcedure { source, .. } - | Error::PersistRepartitionGcRequirement { source, .. } => source.retry_hint(), - Error::Table { source, .. } => source.retry_hint(), - Error::ConvertAlterTableRequest { source, .. } => source.retry_hint(), - Error::ConvertColumnDef { source, .. } => source.retry_hint(), - Error::GetCache { source, .. } => source.retry_hint(), + BuildKafkaClient { error, .. } + | BuildKafkaCtrlClient { error, .. } + | KafkaPartitionClient { error, .. } + | KafkaGetOffset { error, .. } + | ProduceRecord { error, .. } + | CreateKafkaWalTopic { error, .. } => rskafka_client_error_to_retry_hint(error), + SubmitProcedure { source, .. } + | QueryProcedure { source, .. } + | WaitProcedure { source, .. } + | StartProcedureManager { source, .. } + | StopProcedureManager { source, .. } + | RegisterProcedureLoader { source, .. } + | PutPoison { source, .. } + | ProcedureStateReceiver { source, .. } => source.retry_hint(), + External { source, .. } + | ResponseExceededSizeLimit { source, .. } + | OperateDatanode { source, .. } + | AbortProcedure { source, .. } + | RegisterRepartitionProcedureLoader { source, .. } + | CreateRepartitionProcedure { source, .. } + | PersistRepartitionGcRequirement { source, .. } => source.retry_hint(), + Table { source, .. } => source.retry_hint(), + ConvertAlterTableRequest { source, .. } => source.retry_hint(), + ConvertColumnDef { source, .. } => source.retry_hint(), + GetCache { source, .. } => source.retry_hint(), #[cfg(feature = "pg_kvbackend")] - Error::PostgresExecution { error, .. } | Error::PostgresTransaction { error, .. } => { + PostgresExecution { error, .. } | PostgresTransaction { error, .. } => { retry_hint_from_postgres_error(error) } #[cfg(feature = "pg_kvbackend")] - Error::GetPostgresClient { error, .. } => retry_hint_from_postgres_pool_error(error), + GetPostgresClient { error, .. } => retry_hint_from_postgres_pool_error(error), #[cfg(feature = "mysql_kvbackend")] - Error::MySqlExecution { error, .. } - | Error::CreateMySqlPool { error, .. } - | Error::AcquireMySqlClient { error, .. } - | Error::MySqlTransaction { error, .. } => retry_hint_from_sqlx_error(error), + MySqlExecution { error, .. } + | CreateMySqlPool { error, .. } + | AcquireMySqlClient { error, .. } + | MySqlTransaction { error, .. } => retry_hint_from_sqlx_error(error), #[cfg(any(feature = "pg_kvbackend", feature = "mysql_kvbackend"))] - Error::RdsTransactionRetryFailed { .. } | Error::SqlExecutionTimeout { .. } => { - RetryHint::Retryable - } + RdsTransactionRetryFailed { .. } | SqlExecutionTimeout { .. } => RetryHint::Retryable, _ => RetryHint::NonRetryable, } } diff --git a/src/datanode/src/error.rs b/src/datanode/src/error.rs index e51c438939e..3f61d4b3d76 100644 --- a/src/datanode/src/error.rs +++ b/src/datanode/src/error.rs @@ -558,38 +558,36 @@ impl ErrorExt for Error { } fn retry_hint(&self) -> RetryHint { + use Error::*; + match self { - Error::RegionNotReady { .. } | Error::RegionNotFound { .. } => { - RetryHint::RetryAfterRouteRefresh - } - Error::RegionBusy { .. } - | Error::ConcurrentQueryLimiterClosed { .. } - | Error::ConcurrentQueryLimiterTimeout { .. } => RetryHint::Retryable, - Error::NewPlanDecoder { source, .. } | Error::ExecuteLogicalPlan { source, .. } => { + RegionNotReady { .. } | RegionNotFound { .. } => RetryHint::RetryAfterRouteRefresh, + RegionBusy { .. } + | ConcurrentQueryLimiterClosed { .. } + | ConcurrentQueryLimiterTimeout { .. } => RetryHint::Retryable, + NewPlanDecoder { source, .. } | ExecuteLogicalPlan { source, .. } => { source.retry_hint() } - Error::HandleHeartbeatResponse { source, .. } | Error::GetMetadata { source, .. } => { + HandleHeartbeatResponse { source, .. } | GetMetadata { source, .. } => { source.retry_hint() } - Error::DecodeLogicalPlan { source, .. } => source.retry_hint(), - Error::Delete { source, .. } => source.retry_hint(), - Error::AsyncTaskExecute { source, .. } => source.retry_hint(), - Error::StartServer { source, .. } | Error::ShutdownServer { source, .. } => { - source.retry_hint() - } - Error::OpenLogStore { source, .. } => source.retry_hint(), - Error::MetaClientInit { source, .. } => source.retry_hint(), - Error::HandleRegionRequest { source, .. } - | Error::GetRegionMetadata { source, .. } - | Error::HandleBatchOpenRequest { source, .. } - | Error::HandleBatchDdlRequest { source, .. } - | Error::StopRegionEngine { source, .. } => source.retry_hint(), - Error::FindLogicalRegions { source, .. } => source.retry_hint(), - Error::BuildMitoEngine { source, .. } => source.retry_hint(), - Error::GcMitoEngine { source, .. } => source.retry_hint(), - Error::BuildMetricEngine { source, .. } => source.retry_hint(), - Error::ListStorageSsts { source, .. } => source.retry_hint(), - Error::ObjectStore { source, .. } => source.retry_hint(), + DecodeLogicalPlan { source, .. } => source.retry_hint(), + Delete { source, .. } => source.retry_hint(), + AsyncTaskExecute { source, .. } => source.retry_hint(), + StartServer { source, .. } | ShutdownServer { source, .. } => source.retry_hint(), + OpenLogStore { source, .. } => source.retry_hint(), + MetaClientInit { source, .. } => source.retry_hint(), + HandleRegionRequest { source, .. } + | GetRegionMetadata { source, .. } + | HandleBatchOpenRequest { source, .. } + | HandleBatchDdlRequest { source, .. } + | StopRegionEngine { source, .. } => source.retry_hint(), + FindLogicalRegions { source, .. } => source.retry_hint(), + BuildMitoEngine { source, .. } => source.retry_hint(), + GcMitoEngine { source, .. } => source.retry_hint(), + BuildMetricEngine { source, .. } => source.retry_hint(), + ListStorageSsts { source, .. } => source.retry_hint(), + ObjectStore { source, .. } => source.retry_hint(), _ => RetryHint::NonRetryable, } } diff --git a/src/metric-engine/src/error.rs b/src/metric-engine/src/error.rs index 25bc76b7e55..f9d61d6af31 100644 --- a/src/metric-engine/src/error.rs +++ b/src/metric-engine/src/error.rs @@ -483,29 +483,31 @@ impl ErrorExt for Error { } fn retry_hint(&self) -> RetryHint { + use Error::*; + match self { - Error::PhysicalRegionNotFound { .. } | Error::LogicalRegionNotFound { .. } => { + PhysicalRegionNotFound { .. } | LogicalRegionNotFound { .. } => { RetryHint::RetryAfterRouteRefresh } - Error::CreateMitoRegion { source, .. } - | Error::OpenMitoRegion { source, .. } - | Error::CleanUpMitoRegion { source, .. } - | Error::BatchOpenMitoRegion { source, .. } - | Error::BatchCatchupMitoRegion { source, .. } - | Error::CloseMitoRegion { source, .. } - | Error::MitoReadOperation { source, .. } - | Error::MitoWriteOperation { source, .. } - | Error::MitoFlushOperation { source, .. } - | Error::MitoTruncateOperation { source, .. } - | Error::MitoSyncOperation { source, .. } - | Error::MitoEnterStagingOperation { source, .. } - | Error::MitoCopyRegionFromOperation { source, .. } - | Error::MitoEditRegion { source, .. } => source.retry_hint(), + CreateMitoRegion { source, .. } + | OpenMitoRegion { source, .. } + | CleanUpMitoRegion { source, .. } + | BatchOpenMitoRegion { source, .. } + | BatchCatchupMitoRegion { source, .. } + | CloseMitoRegion { source, .. } + | MitoReadOperation { source, .. } + | MitoWriteOperation { source, .. } + | MitoFlushOperation { source, .. } + | MitoTruncateOperation { source, .. } + | MitoSyncOperation { source, .. } + | MitoEnterStagingOperation { source, .. } + | MitoCopyRegionFromOperation { source, .. } + | MitoEditRegion { source, .. } => source.retry_hint(), - Error::EncodePrimaryKey { source, .. } => source.retry_hint(), - Error::CollectRecordBatchStream { source, .. } => source.retry_hint(), - Error::StartRepeatedTask { source, .. } => source.retry_hint(), - Error::CacheGet { source, .. } => source.retry_hint(), + EncodePrimaryKey { source, .. } => source.retry_hint(), + CollectRecordBatchStream { source, .. } => source.retry_hint(), + StartRepeatedTask { source, .. } => source.retry_hint(), + CacheGet { source, .. } => source.retry_hint(), _ => RetryHint::NonRetryable, } diff --git a/src/mito2/src/error.rs b/src/mito2/src/error.rs index 0066b8db47c..ef4c847f758 100644 --- a/src/mito2/src/error.rs +++ b/src/mito2/src/error.rs @@ -1636,83 +1636,85 @@ impl ErrorExt for Error { } fn retry_hint(&self) -> RetryHint { + use Error::*; + match self { - Error::PartitionExprVersionMismatch { .. } - | Error::RegionNotFound { .. } - | Error::RejectWrite { .. } - | Error::RegionState { + PartitionExprVersionMismatch { .. } + | RegionNotFound { .. } + | RejectWrite { .. } + | RegionState { state: RegionRoleState::Follower, .. } => RetryHint::RetryAfterRouteRefresh, - Error::ReadParquet { .. } - | Error::WriteParquet { .. } - | Error::Download { .. } - | Error::Upload { .. } - | Error::RegionState { .. } - | Error::UpdateManifest { .. } - | Error::RegionStopped { .. } - | Error::RegionBusy { .. } - | Error::ManualCompactionAlreadyRunning { .. } - | Error::FlushableRegionState { .. } - | Error::ManifestDeltaNotFound { .. } => RetryHint::Retryable, + ReadParquet { .. } + | WriteParquet { .. } + | Download { .. } + | Upload { .. } + | RegionState { .. } + | UpdateManifest { .. } + | RegionStopped { .. } + | RegionBusy { .. } + | ManualCompactionAlreadyRunning { .. } + | FlushableRegionState { .. } + | ManifestDeltaNotFound { .. } => RetryHint::Retryable, - Error::OpenDal { error, .. } - | Error::DeleteSsts { error, .. } - | Error::DeleteIndex { error, .. } - | Error::DeleteIndexes { error, .. } => retry_hint_from_opendal_error(error), + OpenDal { error, .. } + | DeleteSsts { error, .. } + | DeleteIndex { error, .. } + | DeleteIndexes { error, .. } => retry_hint_from_opendal_error(error), - Error::WriteWal { source, .. } - | Error::ReadWal { source, .. } - | Error::DeleteWal { source, .. } - | Error::WaitWalDurable { source, .. } - | Error::FetchManifests { source, .. } - | Error::External { source, .. } => source.retry_hint(), + WriteWal { source, .. } + | ReadWal { source, .. } + | DeleteWal { source, .. } + | WaitWalDurable { source, .. } + | FetchManifests { source, .. } + | External { source, .. } => source.retry_hint(), - Error::OpenRegion { source, .. } - | Error::WriteGroup { source, .. } - | Error::FlushRegion { source, .. } - | Error::BuildIndexAsync { source, .. } - | Error::CompactRegion { source, .. } - | Error::EditRegion { source, .. } - | Error::ScanSeries { source, .. } - | Error::PruneFile { source, .. } => source.retry_hint(), + OpenRegion { source, .. } + | WriteGroup { source, .. } + | FlushRegion { source, .. } + | BuildIndexAsync { source, .. } + | CompactRegion { source, .. } + | EditRegion { source, .. } + | ScanSeries { source, .. } + | PruneFile { source, .. } => source.retry_hint(), - Error::DataTypeMismatch { source, .. } - | Error::ConvertVector { source, .. } - | Error::ConvertValue { source, .. } - | Error::IndexOptions { source, .. } - | Error::CastVector { source, .. } => source.retry_hint(), + DataTypeMismatch { source, .. } + | ConvertVector { source, .. } + | ConvertValue { source, .. } + | IndexOptions { source, .. } + | CastVector { source, .. } => source.retry_hint(), - Error::BuildIndexApplier { source, .. } - | Error::PushIndexValue { source, .. } - | Error::ApplyInvertedIndex { source, .. } - | Error::IndexFinish { source, .. } => source.retry_hint(), + BuildIndexApplier { source, .. } + | PushIndexValue { source, .. } + | ApplyInvertedIndex { source, .. } + | IndexFinish { source, .. } => source.retry_hint(), - Error::ApplyBloomFilterIndex { source, .. } - | Error::PushBloomFilterValue { source, .. } - | Error::BloomFilterFinish { source, .. } => source.retry_hint(), + ApplyBloomFilterIndex { source, .. } + | PushBloomFilterValue { source, .. } + | BloomFilterFinish { source, .. } => source.retry_hint(), - Error::PuffinReadBlob { source, .. } - | Error::PuffinAddBlob { source, .. } - | Error::PuffinInitStager { source, .. } - | Error::PuffinBuildReader { source, .. } - | Error::PuffinPurgeStager { source, .. } => source.retry_hint(), + PuffinReadBlob { source, .. } + | PuffinAddBlob { source, .. } + | PuffinInitStager { source, .. } + | PuffinBuildReader { source, .. } + | PuffinPurgeStager { source, .. } => source.retry_hint(), - Error::CreateFulltextCreator { source, .. } - | Error::FulltextPushText { source, .. } - | Error::FulltextFinish { source, .. } - | Error::ApplyFulltextIndex { source, .. } => source.retry_hint(), + CreateFulltextCreator { source, .. } + | FulltextPushText { source, .. } + | FulltextFinish { source, .. } + | ApplyFulltextIndex { source, .. } => source.retry_hint(), - Error::InvalidRegionRequest { source, .. } => source.retry_hint(), - Error::InvalidPartitionExpr { source, .. } => source.retry_hint(), - Error::RecordBatch { source, .. } => source.retry_hint(), - Error::GetSchemaMetadata { source, .. } => source.retry_hint(), - Error::CompactionMemoryExhausted { source, .. } => source.retry_hint(), - Error::ConvertBulkWalEntry { source, .. } => source.retry_hint(), - Error::Encode { source, .. } | Error::Decode { source, .. } => source.retry_hint(), + InvalidRegionRequest { source, .. } => source.retry_hint(), + InvalidPartitionExpr { source, .. } => source.retry_hint(), + RecordBatch { source, .. } => source.retry_hint(), + GetSchemaMetadata { source, .. } => source.retry_hint(), + CompactionMemoryExhausted { source, .. } => source.retry_hint(), + ConvertBulkWalEntry { source, .. } => source.retry_hint(), + Encode { source, .. } | Decode { source, .. } => source.retry_hint(), #[cfg(feature = "enterprise")] - Error::ScanExternalRange { source, .. } => source.retry_hint(), + ScanExternalRange { source, .. } => source.retry_hint(), _ => RetryHint::NonRetryable, }