-
Notifications
You must be signed in to change notification settings - Fork 249
feat(server): implement log rotation based on size and retention #2452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
I think changes in |
…retention - Configurable maximum log size and retention period from server configuration - Optimized single directory traversal for collecting file information - Eliminated redundant metadata() calls for improved performance - Enhanced error handling with detailed logging for all failure cases - Merged directory traversals into a single operation to improve performance Fixes apache#46, detail changes can be found at apache#2452.
Yes, that was the case. I have just rebased it to the correct state. |
…retention - Configurable maximum log size and retention period from server configuration - Optimized single directory traversal for collecting file information - Eliminated redundant metadata() calls for improved performance - Enhanced error handling with detailed logging for all failure cases - Merged directory traversals into a single operation to improve performance Fixes apache#46, detail changes can be found at apache#2452.
8a52d32 to
a1c8c0f
Compare
…retention - Configurable maximum log size and retention period from server configuration - Optimized single directory traversal for collecting file information - Eliminated redundant metadata() calls for improved performance - Enhanced error handling with detailed logging for all failure cases - Merged directory traversals into a single operation to improve performance Fixes apache#46, detail changes can be found at apache#2452.
- Log directory creation functionality - Disk space checking feature - Log file count calculation - Log cleanup functions - Logging struct initialization - Fixed some problems
|
I deliberately set some values to conduct a simple test of the current log rotation functionality. Generally speaking, it should now be operating normally. Console2026-01-01T09:03:36.553786Z INFO shard-12 server::websocket::websocket_listener: WebSocket config: max_message_size: None, max_frame_size: None, accept_unmasked_frames: false
2026-01-01T09:03:37.523106Z DEBUG log-rotation server::log::logger: Starting log cleanup for directory: "local_data/logs", retention: 3600s, max_total_size: 4000000000 bytes, max_single_file_size: 512000000 bytes
2026-01-01T09:03:37.523237Z DEBUG log-rotation server::log::logger: Processed 4 log files from directory: "local_data/logs"
2026-01-01T09:03:37.523250Z DEBUG log-rotation server::log::logger: Mark old log file for remove: "local_data/logs/iggy-server.log.4"
2026-01-01T09:03:37.523260Z DEBUG log-rotation server::log::logger: Mark old log file for remove: "local_data/logs/iggy-server.log.1"
2026-01-01T09:03:37.523265Z DEBUG log-rotation server::log::logger: Mark old log file for remove: "local_data/logs/iggy-server.log.3"
2026-01-01T09:03:37.523270Z DEBUG log-rotation server::log::logger: Mark old log file for remove: "local_data/logs/iggy-server.log.2"
2026-01-01T09:03:37.530455Z DEBUG log-rotation server::log::logger: Removed log file: "local_data/logs/iggy-server.log.2"
2026-01-01T09:03:37.562069Z DEBUG log-rotation server::log::logger: Removed log file: "local_data/logs/iggy-server.log.3"
2026-01-01T09:03:37.569756Z DEBUG log-rotation server::log::logger: Removed log file: "local_data/logs/iggy-server.log.1"
2026-01-01T09:03:37.657651Z DEBUG log-rotation server::log::logger: Removed log file: "local_data/logs/iggy-server.log.4"
2026-01-01T09:03:37.657759Z INFO log-rotation server::log::logger: Completed log cleanup for directory: "local_data/logs". Removed 4 files.
2026-01-01T09:03:38.657860Z DEBUG log-rotation server::log::logger: Starting log cleanup for directory: "local_data/logs", retention: 3600s, max_total_size: 4000000000 bytes, max_single_file_size: 512000000 bytes
2026-01-01T09:03:38.657958Z DEBUG log-rotation server::log::logger: Processed 0 log files from directory: "local_data/logs"
2026-01-01T09:03:38.657972Z INFO log-rotation server::log::logger: Completed log cleanup for directory: "local_data/logs". Removed 0 files.
2026-01-01T09:03:39.658081Z DEBUG log-rotation server::log::logger: Starting log cleanup for directory: "local_data/logs", retention: 3600s, max_total_size: 4000000000 bytes, max_single_file_size: 512000000 bytes
2026-01-01T09:03:39.658171Z DEBUG log-rotation server::log::logger: Processed 0 log files from directory: "local_data/logs"
2026-01-01T09:03:39.658184Z INFO log-rotation server::log::logger: Completed log cleanup for directory: "local_data/logs". Removed 0 files.
2026-01-01T09:03:40.658282Z DEBUG log-rotation server::log::logger: Starting log cleanup for directory: "local_data/logs", retention: 3600s, max_total_size: 4000000000 bytes, max_single_file_size: 512000000 bytes
2026-01-01T09:03:40.658376Z DEBUG log-rotation server::log::logger: Processed 0 log files from directory: "local_data/logs"
2026-01-01T09:03:40.658389Z INFO log-rotation server::log::logger: Completed log cleanup for directory: "local_data/logs". Removed 0 files. |
…ssues - Rename variables (max_size => max_file_size, internal attributions) - Configure customize rotation check option and redirect default unwrap values - Fix prevention of active log file deletion - Optimize thread handling (graceful shutdown, thread communication) - Validate invalid configuration parameters - Sync e2e/server.toml configuration - Use full semantic versioning for dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested your code manually. In server.toml i changed settings to:
max_file_size = "1 MB"
max_total_size = "10 MB"
rotation_check_interval = "1 s"then I rebulilt server and started it via:
RUST_LOG=trace target/debug/iggy-server --with-default-root-credentials --fresh
and in other shell i run benchmark to generate logs:
target/debug/iggy-bench -T 1000MB pp -p 1 tcp
result:
I can never see more than 2 files, it looks like retention is ignored and 10 MB of max total size is not reached.
can you write integration test that would test for this scenario? see how TestServer is used, in integration module (e.g. core/integration/tests/server/specific.rs)
| } | ||
| } | ||
|
|
||
| info!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont print anything if 0 files were removed
Redirected from issue #46 , the progress:
_install_log_rotation_handlerfunction, which was previously marked astodo;cleanup_log_filesto delete logs based on the configured time threshold & size;metadata()calls by collecting data in single traversal;Before merge:
Plan:
Around the next several weekends.