Skip to content

Conversation

@Sicheng-Pan
Copy link
Contributor

@Sicheng-Pan Sicheng-Pan commented Oct 31, 2025

Description of changes

Summarize the changes made by this PR.

  • Improvements & Bug fixes
    • Update the fork log validation logic. We only validate that the compaction cursor is in the range of copied logs if it exists. Previously, we enforce this validation by assuming the compaction cursor is 1, which is not likely the case.
  • New functionality
    • N/A

Test plan

How are these changes tested?

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

Migration 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?_

@github-actions
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 Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Sicheng-Pan Sicheng-Pan marked this pull request as ready for review October 31, 2025 01:29
@propel-code-bot
Copy link
Contributor

Relax validation when forking logs to only check existing compaction cursor

Small fix in fork_logs handler of the Rust log-service. Validation now only checks that the compaction cursor lies inside the copied manifest when the cursor actually exists. Earlier logic unconditionally assumed a cursor at offset 1, causing false failures when the cursor had not yet been written.

Key Changes

• Replaced mandatory offset variable with optional cursor (Option<LogPosition>).
• During copy: pass cursor.unwrap_or(LogPosition::from_offset(1)) to wal3::copy.
• Post-copy validation: new if let Some(cursor) block checks cursor against first_copied_offset and max_offset; skipped when cursor is None.
• Adjusted dirty-marking and response offsets to use normalized cursor.

Affected Areas

rust/log-service/src/lib.rsfork_logs RPC implementation

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

}
if offset != max_offset {

let cursor = cursor.unwrap_or(LogPosition::from_offset(1));
Copy link
Contributor

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

@sanketkedia sanketkedia enabled auto-merge (squash) October 31, 2025 20:19
@sanketkedia sanketkedia merged commit 285a4d8 into main Oct 31, 2025
123 of 125 checks passed
@Sicheng-Pan Sicheng-Pan deleted the 10-30-_enh_update_fork_log_validation branch November 1, 2025 06:27
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.

4 participants