-
Notifications
You must be signed in to change notification settings - Fork 312
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
feat(dup): implement server handling of duplicate rpc (part 1) #456
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
levy5307
reviewed
Jan 9, 2020
/// Generates timetag in host endian. | ||
inline uint64_t generate_timetag(uint64_t timestamp, uint8_t cluster_id, bool delete_tag) | ||
{ | ||
return timestamp << 8u | cluster_id << 1u | delete_tag; |
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.
这个delete_tag有啥用了?我记得我看到文档了,但是现在找不到了。
在这段代码上要不要加上说明?
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.
这块的注释后续会在下个PR补上
levy5307
approved these changes
Jan 13, 2020
hycdong
approved these changes
Jan 13, 2020
Closed
neverchanje
pushed a commit
that referenced
this pull request
Mar 31, 2020
acelyc111
pushed a commit
that referenced
this pull request
Jun 23, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
This PR implements server handling of
duplicate_rpc
. There's a document in Chinese that may help for understanding the changes: https://pegasus-kv.github.io/2019/06/09/duplication-design.html#%E9%9B%86%E7%BE%A4%E9%97%B4%E5%86%99%E5%86%B2%E7%AA%81What is changed and how it works?
After a write replicated by 2PC, it will be applied via
pegasus_server_impl::on_batched_write_requests
.Then if
pegasus_server_write::on_batched_write_requests
decodes this write asduplicate_rpc
, it will passes down topegasus_write_service::duplicate
.pegasus_write_service::duplicate
will unwrap the real content of the mutation (inraw_message
), a MULTI_PUT e.g, then apply the write to RocksDB.In order to resolve collision (two clusters write on the same key) we introduce
timetag
for each write:Normally the write with newer timestamp replaces the older, but when the timestamps are identical (rare case, where the write is both written to cluster A and cluster B), we use
cluster_id
to compare which is the larger. We define a concepttimetag
, which is the composition oftimestamp
andcluster_id
.remote_timetag
to compare the "local timestag" (the timetag stored in rocksdb value).timetag
fromdb_write_context::timestamp
, and compares with the local timetag.Both types of write can be written to rocksdb only when their timetag is larger.
Obviously the comparison of timetag requires a DB read before write because the old value is needed. If our user accepts lower level consistency, this overhead can be eliminated with
verfiy_timetag=false
.Check List
Tests