-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Update TransactionUtil::CheckKeyForConflict to also use timestamps #9162
Conversation
This pull request was exported from Phabricator. Differential Revision: D31567960 |
db/db_impl/db_impl.cc
Outdated
@@ -4409,6 +4422,7 @@ Status DBImpl::GetLatestSequenceForKey(SuperVersion* sv, const Slice& key, | |||
|
|||
if (*seq != kMaxSequenceNumber) { | |||
// Found a sequence number, no need to check immutable memtables | |||
assert(0 == ts_sz || *timestamp != std::string(ts_sz, '\xff')); |
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 think we could extend these assertions a bit (and move them out of their corresponding if
blocks) to check that if we have not found a sequence number yet, the timestamp has not been updated, e.g.:
assert(!ts_sz || (*seq != kMaxSequenceNumber && *timestamp != std::string(ts_sz, '\xff')) || (*seq == kMaxSequenceNumber && *timestamp == std::string(ts_sz, '\xff')));
|
||
std::string key_str; | ||
PutFixed64(&key_str, key); | ||
std::reverse(key_str.begin(), key_str.end()); |
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.
Just curious: why do we reverse the key here?
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.
We reverse it so that we can do memcmp on key_strs.
This pull request was exported from Phabricator. Differential Revision: D31567960 |
ae4e005
to
687148a
Compare
…acebook#9162) Summary: Pull Request resolved: facebook#9162 Existing TransactionUtil::CheckKeyForConflict() performs only seq-based conflict checking. If user-defined timestamp is enabled, it should perform conflict checking based on timestamps too. Update TransactionUtil::CheckKey-related methods to verify the timestamp of the latest version of a key is smaller than the read timestamp. Note that CheckKeysForConflict() is not updated since it's used only by optimistic transaction, and we do not plan to update it in this upcoming batch of diffs. Existing GetLatestSequenceForKey() returns the sequence of the latest version of a specific user key. Since we support user-defined timestamp, we need to update this method to also return the timestamp (if enabled) of the latest version of the key. This will be needed for snapshot validation. Reviewed By: ltamasi Differential Revision: D31567960 fbshipit-source-id: 8478594f34e10e0e993255d4f715f870511d639f
This pull request was exported from Phabricator. Differential Revision: D31567960 |
687148a
to
acd75e2
Compare
Thanks @ltamasi for the review! |
This pull request has been merged in 2035798. |
Summary:
Existing TransactionUtil::CheckKeyForConflict() performs only seq-based
conflict checking. If user-defined timestamp is enabled, it should perform
conflict checking based on timestamps too.
Update TransactionUtil::CheckKey-related methods to verify the timestamp of the
latest version of a key is smaller than the read timestamp. Note that
CheckKeysForConflict() is not updated since it's used only by optimistic
transaction, and we do not plan to update it in this upcoming batch of diffs.
Existing GetLatestSequenceForKey() returns the sequence of the latest
version of a specific user key. Since we support user-defined timestamp, we
need to update this method to also return the timestamp (if enabled) of the
latest version of the key. This will be needed for snapshot validation.
Differential Revision: D31567960