Skip to content

[ENH] Add a safety cutoff to the rust log service. #4535

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 2 commits into
base: main
Choose a base branch
from

Conversation

rescrv
Copy link
Contributor

@rescrv rescrv commented May 13, 2025

Description of changes

If a collection on the rust-based log has more than a
configuration-configurable number of records, shut it down hard no
matter what. This happens when compaction gets backlogged. By default,
no more than 1_000_000 can be on the log uncompacted. This is just a
placeholder that we can change.

Test plan

  • Tests pass locally with pytest for python, yarn test for js, cargo test for rust

Documentation Changes

N/A

@rescrv rescrv requested a review from sanketkedia May 13, 2025 16:55
Copy link

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 May 13, 2025

Safety Cutoff Mechanism for Rust Log Service

This PR adds a backpressure mechanism to prevent log service collections from accumulating too many uncompacted records. When a collection exceeds a configurable threshold (default 1,000,000 records), the system rejects further writes to that collection until compaction occurs. This protects the system from memory exhaustion when compaction falls behind.

Key Changes:
• Add backpressure mechanism that rejects writes when collections exceed record threshold
• Introduce configurable num_records_before_backpressure parameter (default: 1,000,000)
• Add backpressure tracking and enforcement in LogServer implementation

Affected Areas:
• Rust log service collection management
• Write operations to collections
• Log service configuration

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

@@ -434,6 +437,7 @@ impl DirtyMarker {
.into_iter()
.flat_map(Result::ok)
.collect::<HashMap<_, _>>();
Copy link
Contributor

Choose a reason for hiding this comment

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

[BestPractice]

Consider using explicit type parameters for HashMap collections. Use of the _ placeholder for type parameters reduces code clarity and can make it harder to understand the data structures being used.

Suggested change
.collect::<HashMap<_, _>>();
.collect::<HashMap<CollectionUuid, (Arc<Storage>, Option<Manifest>, Option<Witness>)>>();

Committable suggestion

Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

use std::future::Future;
use std::sync::Arc;
use std::sync::{Arc, Mutex};
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have adopted parking_lot across our codebase.

rescrv added 2 commits May 14, 2025 15:58
If a collection on the rust-based log has more than a
configuration-configurable number of records, shut it down hard no
matter what.  This happens when compaction gets backlogged.  By default,
no more than 1_000_000 can be on the log uncompacted.  This is just a
placeholder that we can change.
@rescrv rescrv requested a review from HammadB May 15, 2025 22:44
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