Skip to content

Commit 1458c5a

Browse files
committed
LBPs: rate limit various warnings
There were some more warnings that were not rate-limited, which could flood the logs in case of misconfiguration. This commit adds rate limiting there, too.
1 parent a3923e4 commit 1458c5a

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

scylla/src/policies/load_balancing/default.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ use std::{fmt, sync::Arc, time::Duration};
2020
use tracing::debug;
2121
use uuid::Uuid;
2222

23+
const SANITY_CHECKS_WARNING_INTERVAL: std::time::Duration = std::time::Duration::from_secs(1);
24+
2325
#[derive(Clone, Copy)]
2426
enum NodeLocationCriteria<'a> {
2527
Any,
@@ -591,8 +593,6 @@ impl DefaultPolicy {
591593

592594
/// Checks for misconfiguration and warns if any is discovered.
593595
fn pick_sanity_checks(&self, routing_info: &ProcessedRoutingInfo, cluster: &ClusterState) {
594-
const SANITY_CHECKS_WARNING_INTERVAL: std::time::Duration =
595-
std::time::Duration::from_secs(1);
596596
if let Some(preferred_dc) = self.preferences.datacenter() {
597597
// Preferred DC + no datacenter failover + SimpleStrategy is an anti-pattern.
598598
if let Some(ref token_with_strategy) = routing_info.token_with_strategy {
@@ -677,7 +677,8 @@ You won't be able to execute any requests! This is most likely a misconfiguratio
677677
{
678678
nodes
679679
} else {
680-
tracing::warn!(
680+
warn_rate_limited!(
681+
SANITY_CHECKS_WARNING_INTERVAL,
681682
"Datacenter specified as the preferred one ({}) does not exist!",
682683
preferred_datacenter
683684
);

scylla/src/policies/load_balancing/single_target.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::sync::Arc;
44
use uuid::Uuid;
55

66
use crate::cluster::{ClusterState, Node, NodeRef};
7+
use crate::observability::warn_rate_limited;
78
use crate::routing::Shard;
89

910
use super::{LoadBalancingPolicy, RoutingInfo};
@@ -69,7 +70,8 @@ impl LoadBalancingPolicy for SingleTargetLoadBalancingPolicy {
6970
match node {
7071
Some(node) => Some((node, self.shard)),
7172
None => {
72-
tracing::warn!(
73+
warn_rate_limited!(
74+
std::time::Duration::from_secs(1),
7375
"SingleTargetLoadBalancingPolicy failed to find requested node {:?} in cluster metadata.",
7476
self.node_identifier
7577
);

0 commit comments

Comments
 (0)