Skip to content
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

Why is MsgSnapStatus considered a local message? #502

Open
gmoshkin opened this issue Apr 19, 2023 · 3 comments
Open

Why is MsgSnapStatus considered a local message? #502

gmoshkin opened this issue Apr 19, 2023 · 3 comments
Labels
Question A question to be answered.

Comments

@gmoshkin
Copy link

I was wondering, why raft-rs doesn't support sending snapshot status messages via the buit-in message channel. The doc-comments state that the application must report back to the leader about the snapshot status, but there doesn't seem to be a way to do it by means of the provided api. Looks like I have to implement my own separate way to pass a message from a follower to the leader that the snapshot was processed (or failed to be processed).

If I try sending a message with type MsgSnapStatus to the leader, it will be ignored because it is considered a "local" message:
https://github.com/tikv/raft-rs/blob/master/src/raw_node.rs#L402-L411

So my question is, what is the reason for MsgSnapStatus being a local message? Why can't it be sent from a follower to the leader?

@BusyJay
Copy link
Member

BusyJay commented Apr 20, 2023

the application must report back to the leader about the snapshot status

raft-rs doesn't control how the snapshot is sent. Instead, it's up to application to choose the best way to send out a snapshot (via a different connection than the log replication, for example). The flow control in raft-rs will stop sending any logs to follower as follower can't process any of them until snapshot is restored. So application needs to tell raft-rs explicitly the snapshot is sent by calling report_snapshot. After that, raft-rs will start detect if follower has fully processed the snapshot and then decide sending a snapshot again or sending logs.

@BusyJay BusyJay added the Question A question to be answered. label Apr 20, 2023
@gmoshkin
Copy link
Author

Thanks for the reply!

So am I correct to understand that the only reason RawNode::step rejects the MsgSnapReport is because you want the snapshot to be handled more explicitly than any other message? And RawNode::report_snapshot must be called instead of step to make it more explicit, that snapshot applying is a special operation?

@BusyJay
Copy link
Member

BusyJay commented Apr 20, 2023

It's not just about explicitly. Raft message should be a blackbox to application, any fields inside the messages are implementation details. is_local_message is just a helper to detect programming errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question A question to be answered.
Projects
None yet
Development

No branches or pull requests

2 participants