Page MenuHomePhorge

D15409.1765035805.diff
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

D15409.1765035805.diff

diff --git a/services/backup/src/config.rs b/services/backup/src/config.rs
--- a/services/backup/src/config.rs
+++ b/services/backup/src/config.rs
@@ -26,6 +26,14 @@
#[arg(env = "REMOVE_OLD_BACKUPS")]
#[arg(long, default_value_t = false)]
pub remove_old_backups: bool,
+ /// WebSocket frame size limit
+ #[arg(env = "WS_FRAME_SIZE")]
+ #[arg(long, default_value_t = 16_777_216)]
+ pub ws_frame_size: usize,
+ /// Log size threshold for warning logs
+ #[arg(env = "LOG_SIZE_THRESHOLD_FOR_LOGGING")]
+ #[arg(long, default_value_t = 5_242_880)]
+ pub log_size_threshold_for_logging: usize,
}
/// Stores configuration parsed from command-line arguments
diff --git a/services/backup/src/constants.rs b/services/backup/src/constants.rs
--- a/services/backup/src/constants.rs
+++ b/services/backup/src/constants.rs
@@ -3,7 +3,6 @@
pub const MPSC_CHANNEL_BUFFER_CAPACITY: usize = 1;
pub const ID_SEPARATOR: &str = ":";
pub const ATTACHMENT_HOLDER_SEPARATOR: &str = ";";
-pub const WS_FRAME_SIZE: usize = 1_048_576; // 1MiB
pub const LOG_DEFAULT_PAGE_SIZE: i32 = 20;
pub const LOG_BACKUP_ID_SEPARATOR: &str = "#";
diff --git a/services/backup/src/database/log_item.rs b/services/backup/src/database/log_item.rs
--- a/services/backup/src/database/log_item.rs
+++ b/services/backup/src/database/log_item.rs
@@ -1,4 +1,5 @@
-use crate::constants::{log_table::attr, LOG_BACKUP_ID_SEPARATOR};
+use crate::constants::{error_types, log_table::attr, LOG_BACKUP_ID_SEPARATOR};
+use crate::CONFIG;
use aws_sdk_dynamodb::types::AttributeValue;
use comm_lib::{
blob::{
@@ -13,7 +14,7 @@
},
};
use std::collections::HashMap;
-use tracing::debug;
+use tracing::{debug, error};
#[derive(Clone, Debug)]
pub struct LogItem {
@@ -39,6 +40,21 @@
log_id = ?self.log_id,
"Log content exceeds DDB item size limit, moving to blob storage"
);
+
+ // Check if log size exceeds threshold for logging
+ if let Ok(log_size) = calculate_size_in_db(&self.clone().into()) {
+ if log_size > CONFIG.log_size_threshold_for_logging {
+ error!(
+ errorType = error_types::WS_ERROR,
+ "Large log detected - backupID={}, logID={}, size={} bytes ({:.1} MB)",
+ self.backup_id,
+ self.log_id,
+ log_size,
+ log_size as f64 / 1_048_576.0
+ );
+ }
+ }
+
self.content.move_to_blob(blob_client).await
}
diff --git a/services/backup/src/http/handlers/log.rs b/services/backup/src/http/handlers/log.rs
--- a/services/backup/src/http/handlers/log.rs
+++ b/services/backup/src/http/handlers/log.rs
@@ -1,4 +1,5 @@
-use crate::constants::{error_types, WS_FRAME_SIZE};
+use crate::config::CONFIG;
+use crate::constants::error_types;
use crate::database::{log_item::LogItem, DatabaseClient};
use actix::fut::ready;
use actix::{Actor, ActorContext, ActorFutureExt, AsyncContext, StreamHandler};
@@ -43,7 +44,7 @@
&req,
stream,
)
- .frame_size(WS_FRAME_SIZE)
+ .frame_size(CONFIG.ws_frame_size)
.start()
}

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 6, 3:43 PM (18 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5839309
Default Alt Text
D15409.1765035805.diff (2 KB)

Event Timeline