-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[ENH] Update fork log validation #5778
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
Conversation
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
|
Relax validation when forking logs to only check existing compaction cursor Small fix in Key Changes• Replaced mandatory Affected Areas• This summary was automatically generated by @propel-code-bot |
| } | ||
| if offset != max_offset { | ||
|
|
||
| let cursor = cursor.unwrap_or(LogPosition::from_offset(1)); |
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.
[BestPractice]
For clarity and to avoid potential confusion from variable shadowing, consider using a different name for the unwrapped cursor. The variable cursor is used as an Option<LogPosition>, then shadowed inside the if let as a LogPosition, and then shadowed again here as a LogPosition. Using a new name like effective_cursor would make the type change explicit and the code easier to follow.
For example:
let effective_cursor = cursor.unwrap_or(LogPosition::from_offset(1));
if effective_cursor != max_offset {
let mark_dirty = MarkDirty {
collection_id: target_collection_id,
dirty_log: self.dirty_log.clone(),
};
let _ = mark_dirty
.mark_dirty(effective_cursor, (max_offset - effective_cursor) as usize)
.await;
}
let compaction_offset = (effective_cursor - 1u64).offset();
let enumeration_offset = (max_offset - 1u64).offset();
tracing::event!(Level::INFO, compaction_offset, enumeration_offset);Context for Agents
[**BestPractice**]
For clarity and to avoid potential confusion from variable shadowing, consider using a different name for the unwrapped cursor. The variable `cursor` is used as an `Option<LogPosition>`, then shadowed inside the `if let` as a `LogPosition`, and then shadowed again here as a `LogPosition`. Using a new name like `effective_cursor` would make the type change explicit and the code easier to follow.
For example:
```rust
let effective_cursor = cursor.unwrap_or(LogPosition::from_offset(1));
if effective_cursor != max_offset {
let mark_dirty = MarkDirty {
collection_id: target_collection_id,
dirty_log: self.dirty_log.clone(),
};
let _ = mark_dirty
.mark_dirty(effective_cursor, (max_offset - effective_cursor) as usize)
.await;
}
let compaction_offset = (effective_cursor - 1u64).offset();
let enumeration_offset = (max_offset - 1u64).offset();
tracing::event!(Level::INFO, compaction_offset, enumeration_offset);
```
File: rust/log-service/src/lib.rs
Line: 1486
Description of changes
Summarize the changes made by this PR.
Test plan
How are these changes tested?
pytestfor python,yarn testfor js,cargo testfor rustMigration plan
Are there any migrations, or any forwards/backwards compatibility changes needed in order to make sure this change deploys reliably?
Observability plan
What is the plan to instrument and monitor this change?
Documentation Changes
Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the _docs section?_