Skip to content

feat: Delete Progress.PendingSnapshot and improve snapshot handling #243

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

Conversation

soma00333
Copy link

@soma00333 soma00333 commented Nov 27, 2024

Description

This PR addresses #124 by removing the unused Progress.PendingSnapshot field and improving snapshot handling in the Raft library.

What does this PR do?

  1. Removes Progress.PendingSnapshot

    • Deletes the unused PendingSnapshot field from the Progress struct
    • Simplifies state management and reduces code complexity
    • Removes all related code and comments
  2. Improves ReportSnapshot() API

    • Adds appliedSnapshotIndex parameter to track the actual applied snapshot index
    • Updates both node.go and rawnode.go implementations
    • Fixes incorrect documentation that claimed SnapshotFinish was a no-op
  3. Enhances MsgSnapStatus handling

    • Adds applied_snapshot_index field to the protobuf message
    • Implements OnSnapshotApplied() method for cleaner state updates
    • Improves state transition logic after snapshot application
    • Adds debug logging for better troubleshooting
  4. Optimizes state transitions

    • Directly transitions to StateReplicate when follower is caught up
    • Avoids unnecessary StateProbe phase when possible

Why is this needed?

The PendingSnapshot field was not being used effectively and added unnecessary complexity to the codebase. This change:

  • Simplifies the snapshot handling logic
  • Provides more flexibility for systems like CockroachDB that generate snapshots differently
  • Makes state transitions more predictable and efficient

Breaking Changes

⚠️ This is a breaking change targeted for v4.0.0

  • ReportSnapshot() now requires an appliedSnapshotIndex parameter
  • MsgSnapStatus message format has changed
  • Applications using these APIs will need to be updated

Testing

  • All existing tests pass
  • Added new test case for backward compatibility (when AppliedSnapshotIndex is 0)
  • Updated testdata files to reflect the changes

Related Issues

@k8s-ci-robot
Copy link

Hi @soma00333. Thanks for your PR.

I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@soma00333
Copy link
Author

@ahrtr
Hello, I hope you are doing good.
I handled one of the tickets in the v4.0.0 milestone.
Please take a look after you prepare the branch
Thank you

@serathius
Copy link
Member

cc @joshuazh-x
Can you help with review?

@soma00333
Copy link
Author

Thank you for checking this
I appreciate your help

@soma00333
Copy link
Author

/retest

@k8s-ci-robot
Copy link

@soma00333: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@soma00333 soma00333 force-pushed the feat/delete-pendingsnapshot branch from 48b6b6d to 2e13398 Compare June 23, 2025 12:00
@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: soma00333
Once this PR has been reviewed and has the lgtm label, please assign spzala for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@soma00333 soma00333 force-pushed the feat/delete-pendingsnapshot branch from 2e13398 to 800cd61 Compare June 23, 2025 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean up and improve snapshot handling
3 participants