diff --git a/crates/client-api/src/lib.rs b/crates/client-api/src/lib.rs index 7fd6f238128..aeaf03055af 100644 --- a/crates/client-api/src/lib.rs +++ b/crates/client-api/src/lib.rs @@ -146,7 +146,7 @@ impl Host { .await .map_err(|_| (StatusCode::NOT_FOUND, "module not found".to_string()))?; - tracing::info!(sql = body); + tracing::debug!(sql = body); let mut header = vec![]; let sql_start = std::time::Instant::now(); let sql_span = tracing::trace_span!("execute_sql", total_duration = tracing::field::Empty,); diff --git a/crates/client-api/src/routes/database.rs b/crates/client-api/src/routes/database.rs index 8c13f3975c2..b15f72a1e7c 100644 --- a/crates/client-api/src/routes/database.rs +++ b/crates/client-api/src/routes/database.rs @@ -26,7 +26,7 @@ use derive_more::From; use futures::TryStreamExt; use http::StatusCode; use http_body_util::BodyExt; -use log::{info, warn}; +use log::{debug, info, warn}; use serde::Deserialize; use spacetimedb::auth::identity::ConnectionAuthCtx; use spacetimedb::database_logger::DatabaseLogger; @@ -1254,7 +1254,7 @@ pub async fn pre_publish PrettyPrintStyle::AnsiColor => AutoMigratePrettyPrintStyle::AnsiColor, }; - info!("planning migration for database {database_identity}"); + debug!("planning migration for database {database_identity}"); let migrate_plan = ctx .migrate_plan( DatabaseDef { @@ -1278,7 +1278,7 @@ pub async fn pre_publish plan, major_version_upgrade, } => { - info!( + debug!( "planned auto-migration of database {} from {} to {}", database_identity, old_module_hash, new_module_hash ); diff --git a/crates/client-api/src/routes/subscribe.rs b/crates/client-api/src/routes/subscribe.rs index df1aa15d21d..165216202e8 100644 --- a/crates/client-api/src/routes/subscribe.rs +++ b/crates/client-api/src/routes/subscribe.rs @@ -269,11 +269,11 @@ where Err(e) => { let cause = match &e { ClientConnectedError::Rejected(_) => { - log::info!("websocket: Rejecting connection for {client_log_string} due to rejection from client_connected reducer: {e}"); + log::debug!("websocket: Rejecting connection for {client_log_string} due to rejection from client_connected reducer: {e}"); ClientRejectCause::ClientConnectedRejected } ClientConnectedError::OutOfEnergy => { - log::info!("websocket: Rejecting connection for {client_log_string} due to out of energy error from client_connected reducer: {e}"); + log::debug!("websocket: Rejecting connection for {client_log_string} due to out of energy error from client_connected reducer: {e}"); ClientRejectCause::OutOfEnergy } ClientConnectedError::DBError(_) | ClientConnectedError::ReducerCall(_) => { @@ -570,7 +570,7 @@ async fn ws_client_actor_inner( let _ = unordered_tx.send(msg); }) .await; - log::info!("Client connection ended: {client_id}"); + log::trace!("Client connection ended: {client_id}"); } /// The main `select!` loop of the websocket client actor. @@ -734,7 +734,7 @@ async fn ws_main_loop( // Exit if we haven't heard from the client for too long. _ = &mut idle_timer => { - log::warn!("Client {} timed out", state.client_id); + log::debug!("Client {} timed out", state.client_id); WORKER_METRICS .ws_clients_idle_timed_out .with_label_values(&state.database) @@ -1001,7 +1001,7 @@ fn ws_recv_queue( reason: Utf8Bytes::from_static("too many requests"), }); let on_message_after_close = move |client_id| { - log::warn!("client {client_id} sent message after close or error"); + log::debug!("client {client_id} sent message after close or error"); }; let max_incoming_queue_length = state.config.incoming_queue_length.get(); diff --git a/crates/core/src/client/client_connection.rs b/crates/core/src/client/client_connection.rs index 41f28df4190..ed33e29b533 100644 --- a/crates/core/src/client/client_connection.rs +++ b/crates/core/src/client/client_connection.rs @@ -22,6 +22,7 @@ use derive_more::From; use futures::prelude::*; use log::warn; use prometheus::{Histogram, IntCounter, IntGauge}; +use scopeguard::ScopeGuard; use spacetimedb_auth::identity::{ConnectionAuthCtx, SpacetimeIdentityClaims}; use spacetimedb_client_api_messages::websocket::{common as ws_common, v1 as ws_v1, v2 as ws_v2}; use spacetimedb_durability::{DurableOffset, TxOffset}; @@ -884,7 +885,7 @@ impl ClientConnection { let _gauge_guard = module_info.metrics.connected_clients.inc_scope(); module_info.metrics.ws_clients_spawned.inc(); - scopeguard::defer! { + let abort_guard = scopeguard::guard((), |_| { let database_identity = module_info.database_identity; module_info.metrics.ws_clients_aborted.inc(); // This is always called for to make sure `ws_clients_aborted` is incremented, but we only want to log a warning here @@ -892,9 +893,10 @@ impl ClientConnection { if actor_disconnect_recorder.record(ClientDisconnectCause::Unknown) { log::warn!("websocket connection aborted for client identity `{client_identity}` and database identity `{database_identity}`"); } - }; + }); - fut.await + fut.await; + ScopeGuard::into_inner(abort_guard); }) .abort_handle(); diff --git a/crates/core/src/host/wasm_common/module_host_actor.rs b/crates/core/src/host/wasm_common/module_host_actor.rs index ad2c6886a63..1d6db3763fd 100644 --- a/crates/core/src/host/wasm_common/module_host_actor.rs +++ b/crates/core/src/host/wasm_common/module_host_actor.rs @@ -1819,13 +1819,6 @@ fn log_reducer_error( .with_label_values(&replica_ctx.database_identity, module_hash, reducer) .inc(); - log::info!( - "reducer `{}` of database `{}` returned error: {}", - reducer, - replica_ctx.database_identity, - message - ); - let record = Record { ts: chrono::DateTime::from_timestamp_micros(timestamp.to_micros_since_unix_epoch()).unwrap(), function: Some(reducer), diff --git a/crates/core/src/subscription/module_subscription_manager.rs b/crates/core/src/subscription/module_subscription_manager.rs index c82b5c311e9..7a167b3cde8 100644 --- a/crates/core/src/subscription/module_subscription_manager.rs +++ b/crates/core/src/subscription/module_subscription_manager.rs @@ -2169,7 +2169,7 @@ fn send_to_client_v1( message: impl Into, ) { if let Err(e) = client.send_message(tx_offset, OutboundMessage::V1(message.into())) { - tracing::warn!(%client.id, "failed to send update message to client: {e}") + tracing::debug!(%client.id, "failed to send update message to client: {e}") } } fn send_to_client( @@ -2180,7 +2180,7 @@ fn send_to_client( ) { tracing::trace!(client = %client.id, tx_offset, "send_to_client"); if let Err(e) = client.send_message(tx_offset, message) { - tracing::warn!(%client.id, "failed to send update message to client: {e}") + tracing::debug!(%client.id, "failed to send update message to client: {e}") } } diff --git a/crates/datastore/src/locking_tx_datastore/state_view.rs b/crates/datastore/src/locking_tx_datastore/state_view.rs index 3d20e5e50d9..818e7cbb264 100644 --- a/crates/datastore/src/locking_tx_datastore/state_view.rs +++ b/crates/datastore/src/locking_tx_datastore/state_view.rs @@ -311,7 +311,7 @@ pub trait StateView { } fn get_jwt_payload(&self, connection_id: ConnectionId) -> Result> { - log::info!("Getting JWT payload for connection id: {}", connection_id.to_hex()); + log::trace!("Getting JWT payload for connection id: {}", connection_id.to_hex()); let mut buf: Vec = Vec::new(); self.iter_by_col_eq( ST_CONNECTION_CREDENTIALS_ID, diff --git a/crates/pg/src/pg_server.rs b/crates/pg/src/pg_server.rs index 15170a35866..b6f848e0e71 100644 --- a/crates/pg/src/pg_server.rs +++ b/crates/pg/src/pg_server.rs @@ -378,7 +378,7 @@ where let factory_ref = factory.clone(); tokio::spawn(async move { process_socket(stream, None, factory_ref).await.inspect_err(|err|{ - log::error!("PG: Error processing socket: {err:?}"); + log::warn!("PG: Error processing socket: {err:?}"); }) }); }