-
Notifications
You must be signed in to change notification settings - Fork 399
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
Attach addition context to every proposals #59
Conversation
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.
rest LGTM
src/raw_node.rs
Outdated
@@ -257,6 +257,11 @@ impl<T: Storage> RawNode<T> { | |||
|
|||
// Propose proposes data be appended to the raft log. | |||
pub fn propose(&mut self, data: Vec<u8>, sync_log: bool) -> Result<()> { | |||
self.propose_with_context(data, sync_log, 0) |
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.
I suggest to remove sync_log
from the propose
signature, since it's part of the context, which should be handled by users.
can you give an example of how can we use this feature? |
So we can add more flags to context without the cost of deserializing data field. This is a more generic solutions to flag sync-log and what #50 tries to add. The final solution should be using lazy deserialization of protobuf directly, so that user can put any context to the data field instead of coupling with raft-rs's proto definition. But there seems no rust implementation yet. |
proto/eraftpb.proto
Outdated
@@ -12,6 +12,7 @@ message Entry { | |||
uint64 index = 3; | |||
bytes data = 4; | |||
bool sync_log = 5; | |||
uint64 context = 6; |
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.
The context type is uint64, which is very confused.
@siddontang A concrete example can be found at tikv/tikv#3045, split commands put a flag into the context, so we don't need to deserialize the data field to get types of commands. @ngaut It is somewhat confusing, it could be |
u64 is not enough if we want to support more contexts later. |
I prefer using bytes here, and we can use lazy decode in our own logic. We can also remove sync-log flag. |
Any updates? |
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.
rest LGTM
src/raw_node.rs
Outdated
@@ -256,29 +256,27 @@ impl<T: Storage> RawNode<T> { | |||
} | |||
|
|||
// Propose proposes data be appended to the raft log. | |||
pub fn propose(&mut self, data: Vec<u8>, sync_log: bool) -> Result<()> { | |||
pub fn propose(&mut self, data: Vec<u8>, context: Vec<u8>) -> Result<()> { |
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.
context
should go first.
proto/eraftpb.proto
Outdated
@@ -12,6 +12,7 @@ message Entry { | |||
uint64 index = 3; | |||
bytes data = 4; | |||
bool sync_log = 5; |
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.
maybe we can add a comment to deprecate sync log here.
Rest LGTM |
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.
LGTM
LGTM |
It is helpful for special proposals when we want to trace them.