mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-08 14:23:13 +00:00
422e0ad768
rename_all_missing_source_still_warns and rename_all_real_failure_still_warns
assert that `warn_reliable_rename_failure` emitted its WARN, but that is a
single production callsite shared with tests that call rename_all *without*
installing a subscriber — rename_all_missing_source_returns_file_not_found,
two tests above, is one of them.
tracing caches each callsite's Interest process-globally and the first thread
to reach a callsite fixes that value; while at most one dispatcher is
registered, tracing-core derives it from the registering thread's own
subscriber, and registration is once-only. When the subscriber-less sibling
wins, the callsite is cached as Interest::never() and the WARN never fires,
so the assertion sees empty output:
ordinary missing-source failures must keep the WARN, got:
Reproduced at 3/25 with `disk::os::tests::rename_all_missing_source` (both
tests), against 0/20 for the victim alone. Fixed by pinning callsite interest
inside warn_capture(), so every current and future user of that helper is
covered rather than just the two tests that happen to fail today.
pin_callsite_interest_for_test() moves from cluster::rpc::background_monitor
to a new crate-level test_tracing module: it is domain-neutral and now has
consumers in two unrelated subsystems, and disk::os should not have to reach
into a cluster::rpc test helper.
Verified: repro filter 0/30 (was 3/25); disk::os:: 0/12; cluster::rpc:: 0/12
and its poisoner pair 0/15, confirming the moved helper still holds.
Follow-up to #5438. Closes the last item in #5439.
99 lines
2.9 KiB
Rust
99 lines
2.9 KiB
Rust
// Copyright 2024 RustFS Team
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
/// Scope-based hotpath measurement for `#[async_trait]` methods, where
|
|
/// `#[cfg_attr(feature = "hotpath", hotpath::measure)]` would only time the boxed-future construction.
|
|
/// The guard records wall time from this statement until the enclosing
|
|
/// (desugared) async block completes, including early returns via `?`.
|
|
#[cfg(feature = "hotpath")]
|
|
#[macro_export]
|
|
macro_rules! hp_guard {
|
|
($label:expr) => {
|
|
let _hotpath_scope_guard = ::hotpath::functions::build_measurement_guard_sync($label, false);
|
|
};
|
|
}
|
|
|
|
#[cfg(not(feature = "hotpath"))]
|
|
#[macro_export]
|
|
macro_rules! hp_guard {
|
|
($label:expr) => {};
|
|
}
|
|
|
|
pub mod api;
|
|
mod bucket;
|
|
mod cache_value;
|
|
mod cluster;
|
|
mod config;
|
|
mod core;
|
|
mod crash_inject;
|
|
mod data_movement;
|
|
mod data_usage;
|
|
mod diagnostics;
|
|
mod disk;
|
|
mod erasure;
|
|
mod error;
|
|
mod io_support;
|
|
pub(crate) mod layout;
|
|
mod multipart_listing;
|
|
mod object_api;
|
|
mod runtime;
|
|
mod services;
|
|
mod set_disk;
|
|
mod storage_api_contracts;
|
|
mod store;
|
|
|
|
// pub mod checksum;
|
|
mod client;
|
|
mod event;
|
|
|
|
use rustfs_concurrency::WorkloadAdmissionSnapshotProvider;
|
|
use std::sync::Arc;
|
|
|
|
pub type WorkloadAdmissionSnapshotProviderRef = Arc<dyn WorkloadAdmissionSnapshotProvider + Send + Sync>;
|
|
|
|
pub fn set_workload_admission_snapshot_provider(
|
|
provider: WorkloadAdmissionSnapshotProviderRef,
|
|
) -> std::result::Result<(), WorkloadAdmissionSnapshotProviderRef> {
|
|
runtime::sources::set_workload_admission_snapshot_provider(provider)
|
|
}
|
|
|
|
/// Request shutdown of all long-lived peer/disk background monitor tasks.
|
|
///
|
|
/// Call this during graceful shutdown, *before* the Tokio runtime is dropped, so
|
|
/// each monitor future (and the `tracing::Span` it holds) is dropped while the
|
|
/// runtime and tracing subscriber are still alive. This avoids the
|
|
/// thread-local-storage `on_close` panic that can otherwise abort the process
|
|
/// during worker-thread teardown (issue #4264). Idempotent and cheap.
|
|
pub fn shutdown_background_monitors() {
|
|
cluster::rpc::shutdown_background_monitors();
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod rio_tests {
|
|
#[test]
|
|
fn uses_expected_rio_backend() {
|
|
let expected = if cfg!(feature = "rio-v2") { "rio-v2" } else { "legacy-rio" };
|
|
assert_eq!(crate::io_support::rio::backend_name(), expected);
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
pub(crate) mod ecstore_validation_blackbox;
|
|
|
|
#[cfg(test)]
|
|
pub(crate) mod test_metrics;
|
|
|
|
#[cfg(test)]
|
|
pub(crate) mod test_tracing;
|