Skip to content

Conversation

@Svecco
Copy link

@Svecco Svecco commented Dec 7, 2025

Redirected from issue #46 , the progress:

  • implemented log rotation based on size and retention as the title;
  • implemented configurable attributes and imported breaking changes;
  • added units and integration test in logger.rs and integration mod;
  • added documentations and imported new dependencies, etc.

Plan:
Around the next several weekends, before Mid February.

  • ready for being merged;

@hubcio
Copy link
Contributor

hubcio commented Dec 7, 2025

I think changes in core/message_bus are not related to log retention, looks like merge problem.

Svecco added a commit to Svecco/iggy that referenced this pull request Dec 13, 2025
…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.
@Svecco Svecco marked this pull request as ready for review December 13, 2025 03:04
@Svecco
Copy link
Author

Svecco commented Dec 13, 2025

I think changes in core/message_bus are not related to log retention, looks like merge problem.

Yes, that was the case. I have just rebased it to the correct state.

Svecco added a commit to Svecco/iggy that referenced this pull request Dec 20, 2025
…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.
@Svecco Svecco requested review from hubcio and spetz December 20, 2025 12:28
@Svecco Svecco force-pushed the 46-size-logs branch 2 times, most recently from 8a52d32 to a1c8c0f Compare December 27, 2025 12:23
@Svecco
Copy link
Author

Svecco commented Dec 27, 2025

@hubcio @spetz I've just squashed commits into one.

Svecco added a commit to Svecco/iggy that referenced this pull request Jan 1, 2026
…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.
@Svecco Svecco requested a review from hubcio January 1, 2026 09:24
@Svecco Svecco force-pushed the 46-size-logs branch 2 times, most recently from 9180baf to b2ca864 Compare January 1, 2026 12:58
Copy link
Contributor

@hubcio hubcio left a 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)

Svecco added a commit to Svecco/iggy that referenced this pull request Jan 11, 2026
- implemented log rotation based on size and retention as the title;
- implemented configurable attributions and imported breaking changes;
- added units and integration test in logger.rs and intergration mod;
- added documentations and imported new dependencies, etc.

Details can be looked up at Apache Iggy apache#2452
@Svecco Svecco requested a review from hubcio January 11, 2026 03:56
@Svecco
Copy link
Author

Svecco commented Jan 11, 2026

Hi, I've completed some initial modifications and added integration tests.

I first manually observed the runtime behavior locally by running in the terminal:
RUST_LOG=trace cargo run --bin iggy-server -- --fresh --with-default-root-credentials &&
cargo run --bin iggy-bench -- -T 1000MB pp -p 1 quic
I verified that the current log rotation behavior is working as expected by monitoring with
watch -n 0.1 "eza -la ~/Apache/iggy/local_data/logs"

eza -la with 10:100
.rw-r--r--@ 2.4M svecco 11 Jan 13:10 iggy-server.log
.rw-r--r--@  10M svecco 11 Jan 13:04 iggy-server.log.1
.rw-r--r--@  10M svecco 11 Jan 13:04 iggy-server.log.2
.rw-r--r--@  10M svecco 11 Jan 13:04 iggy-server.log.3
.rw-r--r--@  10M svecco 11 Jan 13:04 iggy-server.log.4
.rw-r--r--@  10M svecco 11 Jan 13:04 iggy-server.log.5
.rw-r--r--@  10M svecco 11 Jan 13:04 iggy-server.log.6
.rw-r--r--@  10M svecco 11 Jan 13:03 iggy-server.log.7
.rw-r--r--@  10M svecco 11 Jan 13:03 iggy-server.log.8
.rw-r--r--@  10M svecco 11 Jan 13:03 iggy-server.log.9

Additionally, the result of the simple integration test cargo test -p integration server::specific::log_rotation_should_launch -- --nocapture execution seems fine, by generating sufficient logs by sending a large volume of messages to trigger the log rotation mechanism.

Console
╭─ $ [svecco] ~/A/iggy git!(46-size-logs)
╰─ > cargo test -p integration server::specific::log_rotation_should_launch -- --nocapture
   Compiling libz-sys v1.1.23
   Compiling liblzma-sys v0.4.4
   Compiling hwlocality-sys v0.6.4
   Compiling libgit2-sys v0.18.3+1.9.2
   Compiling liblzma v0.4.5
   Compiling hwlocality v1.0.0-alpha.11
   Compiling compression-codecs v0.4.35
   Compiling async-compression v0.4.36
   Compiling async_zip v0.0.18
   Compiling git2 v0.20.3
   Compiling vergen-git2 v1.0.7
   Compiling server v0.6.1-edge.3 (/home/svecco/host/apache/iggy/core/server)
   Compiling integration v0.0.1 (/home/svecco/host/apache/iggy/core/integration)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 7.71s
     Running unittests src/lib.rs (target/debug/deps/integration-375a7f260e09ad62)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/mod.rs (target/debug/deps/mod-0f48c9a972f7dba1)

running 1 test
Log directory verified: local_data_136642763006894046097605999160554396417/logs
Succeeded Verified Log Rotation
test server::specific::log_rotation_should_launch ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1190 filtered out; finished in 2.12s

@Svecco
Copy link
Author

Svecco commented Jan 17, 2026

Current code testing status:

[PASSED] Integration Test Results
╭─ $ [svecco] ~/A/iggy git!(46-size-logs A3)
╰─ > cargo test -p integration server::specific::log_rotation_should_be_valid -- --nocapture
    Finished `test` profile [optimized + debuginfo] target(s) in 0.16s
     Running unittests src/lib.rs (target/debug/deps/integration-9d57aff619bd2457)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/mod.rs (target/debug/deps/mod-387fb84e60ea900b)

running 1 test

     Size <-> Path && server::specific::log_rotation_be_valid::log_unlimited_archives
   100 KB <-> local_data_114531713724849289516142664524967942913/logs/iggy-server.log.2
   100 KB <-> local_data_114531713724849289516142664524967942913/logs/iggy-server.log.1
   100 KB <-> local_data_114531713724849289516142664524967942913/logs/iggy-server.log

     Size <-> Path && server::specific::log_rotation_be_valid::log_unlimited_size
  1480 KB <-> local_data_245843854166441782392485338372069628673/logs/iggy-server.log

     Size <-> Path && server::specific::log_rotation_be_valid::log_regular_rotation
   100 KB <-> local_data_21035005109332760702119670078692891393/logs/iggy-server.log.4
   100 KB <-> local_data_21035005109332760702119670078692891393/logs/iggy-server.log.3
   100 KB <-> local_data_21035005109332760702119670078692891393/logs/iggy-server.log.2
   100 KB <-> local_data_21035005109332760702119670078692891393/logs/iggy-server.log.1
    77 KB <-> local_data_21035005109332760702119670078692891393/logs/iggy-server.log

     Size <-> Path && server::specific::log_rotation_be_valid::log_special_scenario
  1480 KB <-> local_data_114138328486065171976000052806670326529/logs/iggy-server.log

     Size <-> Path && server::specific::log_rotation_be_valid::log_unlimited_archives
   100 KB <-> local_data_114531713724849289516142664524967942913/logs/iggy-server.log.14
   100 KB <-> local_data_114531713724849289516142664524967942913/logs/iggy-server.log.13
   100 KB <-> local_data_114531713724849289516142664524967942913/logs/iggy-server.log.12
   100 KB <-> local_data_114531713724849289516142664524967942913/logs/iggy-server.log.11
   100 KB <-> local_data_114531713724849289516142664524967942913/logs/iggy-server.log.10
   100 KB <-> local_data_114531713724849289516142664524967942913/logs/iggy-server.log.9
   100 KB <-> local_data_114531713724849289516142664524967942913/logs/iggy-server.log.8
   100 KB <-> local_data_114531713724849289516142664524967942913/logs/iggy-server.log.7
   100 KB <-> local_data_114531713724849289516142664524967942913/logs/iggy-server.log.6
   100 KB <-> local_data_114531713724849289516142664524967942913/logs/iggy-server.log.5
   100 KB <-> local_data_114531713724849289516142664524967942913/logs/iggy-server.log.4
   100 KB <-> local_data_114531713724849289516142664524967942913/logs/iggy-server.log.3
   100 KB <-> local_data_114531713724849289516142664524967942913/logs/iggy-server.log.2
   100 KB <-> local_data_114531713724849289516142664524967942913/logs/iggy-server.log.1
    79 KB <-> local_data_114531713724849289516142664524967942913/logs/iggy-server.log

 [Passed] <-> log_unlimited_archives    <--------------------------------------------->


     Size <-> Path && server::specific::log_rotation_be_valid::log_unlimited_size
  1480 KB <-> local_data_245843854166441782392485338372069628673/logs/iggy-server.log

 [Passed] <-> log_unlimited_size        <--------------------------------------------->


     Size <-> Path && server::specific::log_rotation_be_valid::log_regular_rotation
   100 KB <-> local_data_21035005109332760702119670078692891393/logs/iggy-server.log.3
   100 KB <-> local_data_21035005109332760702119670078692891393/logs/iggy-server.log.2
   100 KB <-> local_data_21035005109332760702119670078692891393/logs/iggy-server.log.1
    78 KB <-> local_data_21035005109332760702119670078692891393/logs/iggy-server.log

 [Passed] <-> log_regular_rotation      <--------------------------------------------->


     Size <-> Path && server::specific::log_rotation_be_valid::log_special_scenario
  1480 KB <-> local_data_114138328486065171976000052806670326529/logs/iggy-server.log

 [Passed] <-> log_special_scenario      <--------------------------------------------->

test server::specific::log_rotation_should_be_valid ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 423 filtered out; finished in 1.77s

╭─ $ [svecco] ~/A/iggy git!(46-size-logs A3)
╰─ > t
Sun Jan 25 11:32:26 AM HKT 2026
[PASSED] Unit Tests Results
╭─ $ [svecco] ~/A/iggy git!(46-size-logs A3)
╰─ > cargo test -p server
    Finished `test` profile [optimized + debuginfo] target(s) in 0.15s
     Running unittests src/lib.rs (target/debug/deps/server-ae537d3f72a36a7d)

running 53 tests
test binary::command::tests::should_be_serialized_as_bytes_and_deserialized_from_bytes ... ok
test configs::sharding::tests::test_parse_count ... ok
test configs::sharding::tests::test_parse_range ... ok
test log::logger::tests::test_calculate_max_files ... ok
test configs::sharding::tests::test_parse_numa_explicit ... ok
test configs::sharding::tests::test_parse_all ... ok
test configs::sharding::tests::test_parse_numa_auto ... ok
test log::logger::tests::test_cleanup_log_files_functions ... ok
test log::logger::tests::test_disk_space_check ... ok
test log::logger::tests::test_logging_creation ... ok
test log::logger::tests::test_log_directory_creation ... ok
test shard::task_registry::registry::tests::test_oneshot_critical_failure ... ok
test shard::task_registry::registry::tests::test_oneshot_completion_detection ... ok
test shard::task_registry::shutdown::tests::test_child_token_child_trigger ... ok
test shard::task_registry::shutdown::tests::test_shutdown_trigger ... ok
test shard::task_registry::registry::tests::test_shutdown_prevents_spawning ... ok
test shard::task_registry::shutdown::tests::test_child_token_no_polling_overhead ... ok
test shard::task_registry::shutdown::tests::test_child_token_parent_trigger ... ok
test streaming::polling_consumer::tests::given_consumer_with_named_id_polling_consumer_should_be_created ... ok
test streaming::polling_consumer::tests::given_consumer_group_with_numeric_id_polling_consumer_group_should_be_created ... ok
test streaming::utils::address::tests::test_extract_ip_ipv4 ... ok
test streaming::utils::address::tests::test_extract_ip_ipv6 ... ok
test streaming::utils::address::tests::test_extract_ip_no_port ... ok
test streaming::utils::address::tests::test_extract_port_no_port ... ok
test versioning::tests::should_load_the_expected_version_from_package_definition ... ok
test versioning::tests::should_parse_basic_semantic_version ... ok
test streaming::utils::address::tests::test_extract_port ... ok
test versioning::tests::should_compare_versions_correctly ... ok
test versioning::tests::should_parse_semantic_version_with_build_metadata ... ok
test streaming::polling_consumer::tests::given_distinct_named_ids_unique_polling_consumer_ids_should_be_created ... ok
test versioning::tests::should_parse_semantic_version_with_alpha ... ok
test tcp::tcp_socket::tests::given_override_defaults_socket_should_be_configured ... ok
test versioning::tests::should_parse_semantic_version_with_prerelease ... ok
test versioning::tests::should_parse_semantic_version_with_prerelease_and_build_metadata ... ok
test versioning::tests::test_find_byte_in_range ... ok
test versioning::tests::test_const_parse_u32_range ... ok
test versioning::tests::test_find_byte_pos_or_len ... ok
test versioning::tests::test_semantic_version_current ... ok
test versioning::tests::test_const_str_slice ... ok
test versioning::tests::test_const_parse_u32_range_invalid - should panic ... ok
test versioning::tests::test_const_parse_u32_range_empty - should panic ... ok
test versioning::tests::should_parse_semver_on_compile_time ... ok
test streaming::deduplication::message_deduplicator::tests::message_deduplicator_should_insert_only_unique_identifiers ... ok
test streaming::polling_consumer::tests::given_consumer_with_numeric_id_polling_consumer_should_be_created ... ok
test shard::task_registry::shutdown::tests::test_sleep_or_shutdown_interrupted ... ok
test shard::task_registry::shutdown::tests::test_sleep_or_shutdown_completes ... ok
test streaming::users::user::tests::should_be_created_given_specific_status ... ok
test streaming::users::user::tests::given_root_user_data_and_credentials_should_be_valid ... ok
test shard::task_registry::registry::tests::test_timeout_error ... ok
test shard::task_registry::registry::tests::test_composite_timeout_insufficient ... ok
test shard::task_registry::registry::tests::test_composite_timeout ... ok
test shard::task_registry::registry::tests::test_periodic_last_tick_timeout ... ok
test streaming::deduplication::message_deduplicator::tests::message_deduplicator_should_evict_identifiers_after_given_time_to_live ... ok

test result: ok. 53 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.60s

     Running unittests src/main.rs (target/debug/deps/iggy_server-f0fdff7a9aab04fb)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests server

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

╭─ $ [svecco] ~/A/iggy git!(46-size-logs A3)
╰─ > t
Sun Jan 25 11:32:54 AM HKT 2026
Server && Bench Side Commands List
╭─ $ [svecco] ~/A/iggy git!(46-size-logs)
╰─ > RUST_LOG=trace cargo run --bin iggy-server -- --fresh --with-default-root-credentials

╭─ $ [svecco] ~/A/iggy git!(46-size-logs)
╰─ > cargo run --bin iggy-bench -- -T 5000MB pp -p 5 quic

╭─ $ [svecco] ~/A/iggy git!(46-size-logs)
╰─ > set -x IGGY_CONFIG_PATH /home/svecco/Apache/.env/server.toml;

╭─ $ [svecco] ~/A/iggy git!(46-size-logs A2)
╰─ > cargo test -p integration server::specific::log_rotation_should_be_valid -- --nocapture

Svecco added a commit to Svecco/iggy that referenced this pull request Jan 17, 2026
- implemented log rotation based on size and retention as the title;
- implemented configurable attributions and imported breaking changes;
- added units and integration test in logger.rs and intergration mod;
- added documentations and imported new dependencies, etc.

Details can be looked up at Apache Iggy apache#2452
@Svecco Svecco requested a review from hubcio January 18, 2026 04:03
Svecco added a commit to Svecco/iggy that referenced this pull request Jan 24, 2026
- implemented log rotation based on size and retention as the title;
- implemented configurable attributions and imported breaking changes;
- added units and integration test in logger.rs and intergration mod;
- added documentations and imported new dependencies, etc.

Details can be looked up at Apache Iggy apache#2452
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants