Skip to content

[ENH] Document magic constants throughout wal3/rust code #4778

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rescrv
Copy link
Contributor

@rescrv rescrv commented Jun 6, 2025

Description of changes

This PR documents the remaining magic constants throughout the
wal3/rust-log-service codebase. The constants are generally OK, but
some probably deserve configuration.

This also catches a case where initial_insertion_epoch_us would only
move forward, and adds a descriptive error message to the case where
time moves backwards.

Test plan

CI, but it's mostly comments.

Documentation Changes

N/A

Copy link

github-actions bot commented Jun 6, 2025

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

Copy link
Contributor

propel-code-bot bot commented Jun 6, 2025

Make Magic Constants Configurable and Document Their Use in wal3/rust-log-service

This PR audits all hardcoded magic constants throughout the wal3 and rust-log-service codebase, replacing several with configurable fields in the LogServerConfig struct. Previously hardcoded batch sizes, retry counts, timeouts, and similar values are now controlled via configuration options with sensible defaults. Some remaining magic constants are explicitly commented for future consideration, and a minor logic improvement ensures that time-related errors are handled more descriptively.

Key Changes:
• Replaced previously hardcoded magic constants (e.g., batch sizes, log keepalive durations, effectuate log transfer retries) in log-service with configuration fields, which now have serde defaults and descriptive documentation.
• Introduced new LogServerConfig fields: rollup_max_size, log_keep_alive, effectuate_log_transfer_batch_size, effectuate_log_transfer_retries, making numerous behaviors adjustable via configuration.
• Propagated these configurable values into relevant logic flows across logging, dirty log rolling, transfers, and compaction.
• Added TODOs/comments on remaining magic constants throughout wal3 (manifest.rs, writer.rs) for future configurability.
• Improved error handling for time moving backwards in LogService.

Affected Areas:
• rust/log-service/src/lib.rs
• rust/wal3/src/manifest.rs
• rust/wal3/src/writer.rs
• LogServerConfig definition and usage
• Compaction, log transfer, and dirty log handling logic

This summary was automatically generated by @propel-code-bot

@rescrv rescrv requested review from HammadB and Sicheng-Pan June 6, 2025 17:13
Copy link
Contributor

@Sicheng-Pan Sicheng-Pan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should leave a ticket to justify the magical constants or make them configurable

@rescrv rescrv force-pushed the rescrv/magic-constants branch from 9696333 to 4c1a075 Compare June 16, 2025 21:14
@rescrv rescrv force-pushed the rescrv/magic-constants branch from eff4ca6 to 690f80f Compare June 17, 2025 21:28
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.

2 participants