From 76341e4456449fe77ab49f1297e5cbbc03cb6706 Mon Sep 17 00:00:00 2001 From: RA <70325462+RAprogramm@users.noreply.github.com> Date: Wed, 24 Sep 2025 16:37:48 +0700 Subject: [PATCH] Fix redis busy loading classification --- CHANGELOG.md | 12 ++++++++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 4 ++-- src/app_error/tests.rs | 7 ++++++- src/convert/redis.rs | 3 ++- src/convert/serde_json.rs | 2 +- 7 files changed, 25 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9909129..7f606d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +## [0.20.8] - 2025-10-08 + +### Fixed +- Classified Redis `BusyLoadingError` responses as `DependencyUnavailable` and + preserved their retry advice in metadata so downstreams can distinguish cache + warmup from client mistakes when the `redis` feature is enabled. +- Serialized the serde_json syntax error position using the location reported + by `serde_json::Error` to stay aligned with the upstream parser changes. +- Guarded the tracing telemetry test with a process-wide mutex to prevent + spurious race failures when the full feature suite runs the test harness in + parallel. + ## [0.20.7] - 2025-10-07 ### Fixed diff --git a/Cargo.lock b/Cargo.lock index 8d14c1d..5f937c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1727,7 +1727,7 @@ dependencies = [ [[package]] name = "masterror" -version = "0.20.7" +version = "0.20.8" dependencies = [ "actix-web", "axum 0.8.4", diff --git a/Cargo.toml b/Cargo.toml index d79a866..8c1a7d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "masterror" -version = "0.20.7" +version = "0.20.8" rust-version = "1.90" edition = "2024" license = "MIT OR Apache-2.0" diff --git a/README.md b/README.md index cd31c96..3932ed6 100644 --- a/README.md +++ b/README.md @@ -71,9 +71,9 @@ The build script keeps the full feature snippet below in sync with ~~~toml [dependencies] -masterror = { version = "0.20.7", default-features = false } +masterror = { version = "0.20.8", default-features = false } # or with features: -# masterror = { version = "0.20.7", features = [ +# masterror = { version = "0.20.8", features = [ # "axum", "actix", "openapi", "serde_json", # "tracing", "metrics", "backtrace", "sqlx", # "sqlx-migrate", "reqwest", "redis", "validator", diff --git a/src/app_error/tests.rs b/src/app_error/tests.rs index 73633a0..4f21968 100644 --- a/src/app_error/tests.rs +++ b/src/app_error/tests.rs @@ -1,4 +1,4 @@ -#[cfg(feature = "backtrace")] +#[cfg(any(feature = "backtrace", feature = "tracing"))] use std::sync::Mutex; use std::{borrow::Cow, error::Error as StdError, fmt::Display, sync::Arc}; @@ -8,6 +8,9 @@ use super::core::{reset_backtrace_preference, set_backtrace_preference_override} #[cfg(feature = "backtrace")] static BACKTRACE_ENV_GUARD: Mutex<()> = Mutex::new(()); +#[cfg(feature = "tracing")] +static TELEMETRY_GUARD: Mutex<()> = Mutex::new(()); + use super::{AppError, FieldRedaction, FieldValue, MessageEditPolicy, field}; use crate::{AppCode, AppErrorKind}; @@ -314,6 +317,8 @@ fn log_uses_kind_and_code() { #[cfg(feature = "tracing")] #[test] fn telemetry_emits_single_tracing_event_with_trace_id() { + let _guard = TELEMETRY_GUARD.lock().expect("telemetry guard"); + use std::{ fmt, sync::{Arc, Mutex} diff --git a/src/convert/redis.rs b/src/convert/redis.rs index fb7511d..7a4a99c 100644 --- a/src/convert/redis.rs +++ b/src/convert/redis.rs @@ -33,7 +33,7 @@ //! ``` #[cfg(feature = "redis")] -use redis::{RedisError, RetryMethod}; +use redis::{ErrorKind, RedisError, RetryMethod}; #[cfg(feature = "redis")] use crate::{AppErrorKind, Context, Error, field}; @@ -84,6 +84,7 @@ fn build_context(err: &RedisError) -> (Context, Option) { || err.is_connection_dropped() || err.is_cluster_error() || err.is_io_error() + || matches!(err.kind(), ErrorKind::BusyLoadingError) { context = context.category(AppErrorKind::DependencyUnavailable); } diff --git a/src/convert/serde_json.rs b/src/convert/serde_json.rs index a47b854..bd22754 100644 --- a/src/convert/serde_json.rs +++ b/src/convert/serde_json.rs @@ -133,7 +133,7 @@ mod tests { ); assert_eq!( metadata.get("serde_json.position"), - Some(&FieldValue::Str("1:1".into())) + Some(&FieldValue::Str("1:2".into())) ); } }