Skip to content

Commit

Permalink
[raft] Add a session proto message for idempotency support (#6680)
Browse files Browse the repository at this point in the history
  • Loading branch information
luluz66 authored Jun 3, 2024
1 parent 515baa0 commit 9253e31
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions proto/raft.proto
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,25 @@ enum FinalizeOperation {
COMMIT = 2;
}

// A client session that is used to support idempotency on the raft state
// machine.
message Session {
// An unique identifier of the client session.
// Example: 018fcb2f-cfab-718b-974e-64907df56881
bytes id = 1;
// Each BatchCmdRequest has its unique <id, index>. The index is
// monotonically increasing.
// Example: 1717100891000000000
uint64 index = 2;
// A timestamp when the session will be cleaned up; and when the state machine
// can safely clean up the entry.
int64 expiry_usec = 3;

// Optional. The response associated with the command associated with the
// index.
optional bytes rsp_data = 4;
}

message BatchCmdRequest {
// Header will be validated by the state machine if set.
Header header = 1;
Expand All @@ -311,6 +330,9 @@ message BatchCmdRequest {

// Any post-commit hooks that should be run after a batch is *committed*.
repeated PostCommitHook post_commit_hooks = 5;

// Session is used to guarantee idempotency for writes on the state machine.
optional Session session = 6;
}

message BatchCmdResponse {
Expand Down Expand Up @@ -467,6 +489,9 @@ message Header {
// Reads will use LINEARIZABLE by default but STALE can be set if the client
// can tolerate stale data.
ConsistencyMode consistency_mode = 4;

// Session is used to guarantee idempotency for writes on the state machine.
optional Session session = 5;
}

message RangeSet {
Expand Down

0 comments on commit 9253e31

Please sign in to comment.