Skip to content

Commit 38278be

Browse files
committed
only do 'failed to send update message' once per client
1 parent bc4fea2 commit 38278be

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

crates/core/src/client/client_connection.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ pub struct ClientConnectionSender {
7979
sendtx: mpsc::Sender<SerializableMessage>,
8080
abort_handle: AbortHandle,
8181
cancelled: AtomicBool,
82+
pub(crate) not_warned_failed_to_send_message: AtomicBool,
8283

8384
/// Handles on Prometheus metrics related to connections to this database.
8485
///
@@ -143,12 +144,14 @@ impl ClientConnectionSender {
143144

144145
let rx = MeteredReceiver::new(rx);
145146
let cancelled = AtomicBool::new(false);
147+
let not_warned_failed_to_send_message = AtomicBool::new(true);
146148
let sender = Self {
147149
id,
148150
config,
149151
sendtx,
150152
abort_handle,
151153
cancelled,
154+
not_warned_failed_to_send_message,
152155
metrics: None,
153156
};
154157
(sender, rx)
@@ -418,12 +421,14 @@ impl ClientConnection {
418421
let metrics = ClientConnectionMetrics::new(database_identity, config.protocol);
419422
let sendrx = MeteredReceiver::with_gauge(sendrx, metrics.sendtx_queue_size.clone());
420423

424+
let not_warned_failed_to_send_message = AtomicBool::new(true);
421425
let sender = Arc::new(ClientConnectionSender {
422426
id,
423427
config,
424428
sendtx,
425429
abort_handle,
426430
cancelled: AtomicBool::new(false),
431+
not_warned_failed_to_send_message,
427432
metrics: Some(metrics),
428433
});
429434
let this = Self {

crates/core/src/subscription/module_subscription_manager.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,9 @@ impl SendWorker {
15221522

15231523
fn send_to_client(client: &ClientConnectionSender, message: impl Into<SerializableMessage>) {
15241524
if let Err(e) = client.send_message(message) {
1525-
tracing::warn!(%client.id, "failed to send update message to client: {e}")
1525+
if client.not_warned_failed_to_send_message.fetch_and(false, Ordering::AcqRel) {
1526+
tracing::warn!(%client.id, "failed to send update message to client: {e}")
1527+
}
15261528
}
15271529
}
15281530

0 commit comments

Comments
 (0)